コード例 #1
0
        private void GenerateJunctionsCarriageWay()
        {
            if (Junctions == null || Junctions.Count == 0)
            {
                return;
            }

            var allJunctionArcs = new List <Curve>();

            foreach (var junction in Junctions)
            {
                var arcs = junction.Generate();
                if (arcs == null)
                {
                    continue;
                }

                allJunctionArcs.AddRange(arcs);
            }

            if (allJunctionArcs.Count == 0)
            {
                return;
            }

            var db = Application.DocumentManager.MdiActiveDocument.Database;

            using (var acTrans = TransactionFactory.CreateFromNew())
            {
                var blockTable       = (BlockTable)acTrans.GetObject(db.BlockTableId, OpenMode.ForRead);
                var blockTableRecord = (BlockTableRecord)acTrans.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                foreach (var arc in allJunctionArcs)
                {
                    arc.Layer = Constants.LAYER_DEF_POINTS;

                    JunctionOffsetCollection.Add(blockTableRecord.AppendEntity(arc));
                    acTrans.AddNewlyCreatedDBObject(arc, true);
                }

                acTrans.Commit();
            }
        }
コード例 #2
0
        private void RemoveOffsets()
        {
            using (var acTrans = TransactionFactory.CreateFromNew())
            {
                foreach (ObjectId obj in JunctionOffsetCollection.Collection)
                {
                    if (!obj.IsErased)
                    {
                        acTrans.GetObject(obj, OpenMode.ForWrite, true).Erase();
                    }
                }

                JunctionOffsetCollection.Clear();

                if (Roads != null && Roads.Count > 0)
                {
                    Roads.ForEach(r => r.Reset());
                }
                acTrans.Commit();
            }
        }