private void assignTargets()
        {
            // These will return empty collections because the
            // Corridor object has not been built yet.
            //
            // SubassemblyTargetInfoCollection targets =
            //      _corridor.GetTargets();
            // SubassemblytargetInfoCollection targets =
            //      _baseline.GetTargets();

            // Getting the targets from the BaselineRegion
            // works because it access the information from
            // the specified Assembly object when creating the
            // BaselineRegion.
            //
            SubassemblyTargetInfoCollection targets =
                _region.GetTargets();

            foreach (SubassemblyTargetInfo target in targets)
            {
                assignTarget(target);
            }
            // The collection is empty if retrieved from the
            // Corridor or Baseline object; therefore these
            // calls will do nothing.
            //
            // _corridor.SetTargets(targets);
            // _baseline.SetTargets(targets);

            // Regions allow you to specify the targets.
            //
            _region.SetTargets(targets);
        }
Exemple #2
0
        public Corridor IzradaPera(Alignment alig, Profile profi)
        {
            if (alig != null && profi != null)
            {
                Transaction tr  = doc.TransactionManager.StartTransaction();
                string      ime = "Okomito pero " + brojPera.ToString();

                Alignment os   = alig;
                ObjectId  osId = os.ObjectId;

                Profile  niveleta   = profi;
                ObjectId niveletaId = niveleta.ObjectId;

                Assembly tijeloPera   = TijeloPera();
                ObjectId tijeloPeraId = tijeloPera.ObjectId;

                Assembly zerro   = NultiAss();
                ObjectId zerroId = zerro.ObjectId;

                Assembly glavaPera   = GlavaPera();
                ObjectId glavaPeraId = glavaPera.ObjectId;

                Autodesk.Civil.DatabaseServices.Surface targetSurface = EGSurface();
                ObjectId targetSurfaceId = targetSurface.ObjectId;

                ObjectId novoPeroId = civDoc.CorridorCollection.Add(ime, "Niveleta " + ime, osId, niveletaId);
                Corridor novoPero   = tr.GetObject(novoPeroId, OpenMode.ForWrite) as Corridor;

                BaselineRegionCollection blRegColl     = novoPero.Baselines[0].BaselineRegions;
                BaselineRegion           regTijeloPera = blRegColl.Add("Tijelo pera", tijeloPeraId, alig.StartingStation, DuljinaPera);
                BaselineRegion           regGlavaPera  = blRegColl.Add("GlavaPera", glavaPeraId, DuljinaPera, DuljinaPera + Math.PI * SirinaKrune / 2);
                BaselineRegion           reg0          = blRegColl.Add("0", zerroId, regGlavaPera.EndStation, alig.EndingStation);

                // corridor frequency nije otvoren u API dokumentaciji
                // jedini način da malo progustim izradu
                for (int i = 10; i < DuljinaPera; i += 10)
                {
                    regTijeloPera.AddStation(i, "Stacionaza " + i.ToString());
                }

                for (double i = 0.1; i < (Math.PI * SirinaKrune / 2); i += 0.3)
                {
                    regGlavaPera.AddStation(DuljinaPera + i, "Stacionaza " + i.ToString());
                }

                BaselineRegionCollection blRColl = novoPero.Baselines[0].BaselineRegions;
                foreach (BaselineRegion blReg in blRColl)
                {
                    SubassemblyTargetInfoCollection targets = blReg.GetTargets();
                    foreach (SubassemblyTargetInfo target in targets)
                    {
                        if (target.TargetType == SubassemblyLogicalNameType.Surface)
                        {
                            var ids = new ObjectIdCollection();
                            ids.Add(targetSurfaceId);
                            target.TargetIds = ids;
                        }
                    }

                    blReg.SetTargets(targets);
                }

                novoPero.Rebuild();

                tr.Commit();

                return(novoPero);
            }

            else
            {
                ed.WriteMessage($"Na stacionazi {0} nije moguća izgradnja pera", Stacionaza);
                return(null);
            }
        }