private static ScheduleTable CreateScheduleTable(UiData uiData, ObjectId propertySetDefinitionId, ObjectId styleId, Transaction trans)
        {
            Database         db  = ScheduleSample.GetDatabase();
            BlockTableRecord btr = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;

            ScheduleTable scheduleTable = new ScheduleTable();

            scheduleTable.SetToStandard(db);
            scheduleTable.SetDatabaseDefaults(db);
            scheduleTable.StyleId = styleId;
            scheduleTable.SetDefaultLayer();

            btr.AppendEntity(scheduleTable);
            trans.AddNewlyCreatedDBObject(scheduleTable, true);

            ObjectIdCollection selectionSet = new ObjectIdCollection();

            foreach (List <ObjectId> idSetByObjectType in uiData.classObjectIdsMap.Values)
            {
                foreach (ObjectId id in idSetByObjectType)
                {
                    selectionSet.Add(id);
                }
            }

            scheduleTable.SetSelectionSet(selectionSet, new ObjectIdCollection());
            scheduleTable.AutomaticUpdate = true;

            return(scheduleTable);
        }
        public static void listallfjvblocks()
        {
            DocumentCollection docCol   = Application.DocumentManager;
            Database           localDb  = docCol.MdiActiveDocument.Database;
            Document           doc      = docCol.MdiActiveDocument;
            CivilDocument      civilDoc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument;

            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                using (Transaction tx = localDb.TransactionManager.StartTransaction())
                    using (Database symbolerDB = new Database(false, true))
                    {
                        try
                        {
                            System.Data.DataTable fjvKomponenter = CsvReader.ReadCsvToDataTable(
                                @"X:\AutoCAD DRI - 01 Civil 3D\FJV Komponenter.csv", "FjvKomponenter");

                            symbolerDB.ReadDwgFile(@"X:\0371-1158 - Gentofte Fase 4 - Dokumenter\01 Intern\" +
                                                   @"02 Tegninger\01 Autocad\Autocad\01 Views\0.0 Fælles\Symboler.dwg",
                                                   System.IO.FileShare.Read, true, "");

                            ObjectIdCollection ids = new ObjectIdCollection();

                            BlockTable bt = tx.GetObject(localDb.BlockTableId, OpenMode.ForRead) as BlockTable;

                            using (Transaction symbTx = symbolerDB.TransactionManager.StartTransaction())
                            {
                                BlockTable symbBt = symbTx.GetObject(symbolerDB.BlockTableId, OpenMode.ForRead) as BlockTable;

                                foreach (oid Oid in bt)
                                {
                                    BlockTableRecord btr = tx.GetObject(Oid, OpenMode.ForWrite) as BlockTableRecord;

                                    if (ReadStringParameterFromDataTable(btr.Name, fjvKomponenter, "Navn", 0) != null &&
                                        ReadStringParameterFromDataTable(btr.Name, fjvKomponenter, "Type", 0) == "Reduktion" &&
                                        bt.Has(btr.Name))
                                    {
                                        prdDbg(btr.Name);
                                    }
                                }
                                symbTx.Commit();
                            }
                        }
                        catch (System.Exception ex)
                        {
                            tx.Abort();
                            ed.WriteMessage(ex.Message);
                            throw;
                        }

                        tx.Commit();
                    };
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(ex.Message);
            }
        }
Exemple #3
0
        public static Parcel ByNumber(Autodesk.AutoCAD.DynamoNodes.Document document, Site siteObject, int parcelNumber)
        {
            Autodesk.Civil.DatabaseServices.Parcel retParcel = null;
            //get the current document and database
            AcadApp.Document doc = document.AcDocument;
            Database         db  = doc.Database;

            Autodesk.Civil.DatabaseServices.Site site = (Autodesk.Civil.DatabaseServices.Site)siteObject._curCivilObject;
            Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection parcelIds = site.GetParcelIds();
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId objectId in parcelIds)
                {
                    retParcel = (Autodesk.Civil.DatabaseServices.Parcel)trans.GetObject(objectId, OpenMode.ForRead);
                    if (retParcel.Number != parcelNumber)
                    {
                        retParcel = null;
                    }
                    else
                    {
                        return(new Parcel(retParcel, true));
                    }
                }
            }
            return(null);
        }
Exemple #4
0
        static public ObjectIdCollection PickObjectSet(string tips)
        {
            Editor editor = GetEditor();
            PromptSelectionOptions options = new PromptSelectionOptions();

            options.MessageForAdding  = tips;
            options.MessageForRemoval = "Remove objects from selection";
            options.AllowDuplicates   = false;
            options.RejectObjectsFromNonCurrentSpace = true;
            options.RejectObjectsOnLockedLayers      = true;
            options.RejectPaperspaceViewport         = true;
            ObjectIdCollection ids = new ObjectIdCollection();

            PromptSelectionResult result = editor.GetSelection(options);

            if (result.Status == PromptStatus.OK)
            {
                SelectionSet set = result.Value;
                foreach (SelectedObject obj in set)
                {
                    ids.Add(obj.ObjectId);
                }
            }

            return(ids);
        }
Exemple #5
0
        public ObjectId GetSiteId(ObjectId surfaceId)
        {
            var site = ObjectId.Null;

            using (Transaction tr = CivilApplicationManager.StartTransaction())

            {
                Autodesk.AutoCAD.DatabaseServices.Database db = CivilApplicationManager.WorkingDatabase;
                var doc = CivilDocument.GetCivilDocument(db);
                ObjectIdCollection siteIds = doc.GetSiteIds();
                if (siteIds != null && siteIds.Count != 0)
                {
                    site = (from s in siteIds.Cast <ObjectId>()
                            select s).FirstOrDefault();
                }

                if (site == ObjectId.Null)
                {
                    site = C3DLandDb.Site.Create(doc, "Site-ALL");
                }

                tr.Commit();
            }
            return(site);
        }
        private static void SetDrawOrderInBlock(App.Document dwg, Db.ObjectId blkId)
        {
            using (Db.Transaction tran =
                       dwg.TransactionManager.StartTransaction())
            {
                Db.BlockReference bref = (Db.BlockReference)tran.GetObject(
                    blkId, Db.OpenMode.ForRead);

                Db.BlockTableRecord bdef = (Db.BlockTableRecord)tran.GetObject(
                    bref.BlockTableRecord, Db.OpenMode.ForWrite);

                Db.DrawOrderTable doTbl = (Db.DrawOrderTable)tran.GetObject(
                    bdef.DrawOrderTableId, Db.OpenMode.ForWrite);

                Db.ObjectIdCollection col = new Db.ObjectIdCollection();
                foreach (Db.ObjectId id in bdef)
                {
                    if (id.ObjectClass == Rtm.RXObject.GetClass(typeof(Db.Wipeout)))
                    {
                        col.Add(id);
                    }
                }

                if (col.Count > 0)
                {
                    doTbl.MoveToBottom(col);
                }


                tran.Commit();
            }
        }
Exemple #7
0
        References(string label, AcDb.ObjectId val)
            :   base(label)
        {
            m_val = val;

            if (m_val.IsNull == false)
            {
                using (TransactionHelper trHlp = new TransactionHelper(m_val.Database)) {
                    trHlp.Start();

                    AcDb.DBObject dbObj = trHlp.Transaction.GetObject(m_val, AcDb.OpenMode.ForRead);

                    MgdDbg.Utils.ReferenceFiler filer = new MgdDbg.Utils.ReferenceFiler();
                    dbObj.DwgOut(filer);

                    trHlp.Commit();

                    m_hardPointerIds   = filer.m_hardPointerIds;
                    m_softPointerIds   = filer.m_softPointerIds;
                    m_hardOwnershipIds = filer.m_hardOwnershipIds;
                    m_softOwnershipIds = filer.m_softOwnershipIds;
                }

                if ((m_hardPointerIds.Count == 0) && (m_softPointerIds.Count == 0) && (m_hardOwnershipIds.Count == 0) && (m_softOwnershipIds.Count == 0))
                {
                    m_hasRefs = false;
                }
                else
                {
                    m_hasRefs = true;
                }
            }
        }
Exemple #8
0
        public void ShowSample()
        {
            ObjectIdCollection ids = PickObjectSet("Please pick the objects to be scheduled:");

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

            Dictionary <RXClass, List <ObjectId> > classDictionary           = new Dictionary <RXClass, List <ObjectId> >();
            Dictionary <RXClass, List <ObjectId> > ineligibleClassDictionary = new Dictionary <RXClass, List <ObjectId> >();
            StringCollection eligibleClassNames = new StringCollection();

            eligibleClassNames.AddRange(PropertyDataServices.FindEligibleClassNames());
            foreach (ObjectId id in ids)
            {
                if (!eligibleClassNames.Contains(id.ObjectClass.Name))
                {
                    if (!ineligibleClassDictionary.ContainsKey(id.ObjectClass))
                    {
                        ineligibleClassDictionary[id.ObjectClass] = new List <ObjectId>();
                    }

                    ineligibleClassDictionary[id.ObjectClass].Add(id);
                }
                else
                {
                    if (!classDictionary.ContainsKey(id.ObjectClass))
                    {
                        classDictionary[id.ObjectClass] = new List <ObjectId>();
                    }

                    classDictionary[id.ObjectClass].Add(id);
                }
            }

            if (classDictionary.Keys.Count == 0)
            {
                GetEditor().WriteMessage("No eligible object is selected. Schedule table sample will now quit.");
                return;
            }

            UiData runtimeData = new UiData();

            runtimeData.classObjectIdsMap           = classDictionary;
            runtimeData.ineligibleClassObjectIdsMap = ineligibleClassDictionary;
            WizardSheetPropertySetDefinition sheetPsd = new WizardSheetPropertySetDefinition();
            WizardSheetScheduleTableStyle    sheetSts = new WizardSheetScheduleTableStyle();
            WizardSheetSummary sheetSummary           = new WizardSheetSummary();
            WizardManager      wizard = new WizardManager();

            wizard.AddSheet(sheetPsd);
            wizard.AddSheet(sheetSts);
            wizard.AddSheet(sheetSummary);
            wizard.RuntimeData = runtimeData;
            if (wizard.ShowWizard() == System.Windows.Forms.DialogResult.OK)
            {
                ScheduleTableCreateResult result = ScheduleTableCreateEx.CreateScheduleTable(runtimeData);
            }
        }
Exemple #9
0
        public static IList <PolylineChildren> CreatePolylineChildren(ACADDB.ObjectIdCollection polylines)
        {
            IList <PolylineChildren> children = new List <PolylineChildren>();

            foreach (ACADDB.ObjectId polyoid in polylines)
            {
                ACADDB.ObjectIdCollection collection  = null;
                Point2dCollection         innerpoints = null;
                Point2dCollection         outerpoints = null;

                outerpoints = PlineToPoints(polyoid);
                collection  = new ACADDB.ObjectIdCollection();

                //Is Polyline within Outer Polyline
                foreach (ACADDB.ObjectId polyline in polylines)
                {
                    innerpoints = PlineToPoints(polyline);
                    if (PointUtilities.PointInPolyline(outerpoints, innerpoints))
                    {
                        collection.Add(polyline);
                    }
                }
                children.Add(new PolylineChildren(polyoid, collection));
            }


            return(children);
        }
 private void _verifyObjectTypeIs(Type requestedType)
 {
     acaddb.ObjectIdCollection node =
         m_TestDocument.NodeProvider.GetNode(m_RequestedType);
     acaddb.ObjectId id     = node[0];
     c3ddb.Entity    entity = id.GetObject(acaddb.OpenMode.ForRead)
                              as c3ddb.Entity;
     Assert.AreEqual(requestedType, entity.GetType(),
                     "Incorrect node returned.");
 }
Exemple #11
0
 AddObjectIdCollectionToTree(AcDb.ObjectIdCollection objIds)
 {
     // initialize the tree control with the ObjectId of each item
     for (int i = 0; i < objIds.Count; i++)
     {
         TreeNode tmpNode = new TreeNode(MgdDbg.Utils.AcadUi.ObjToTypeAndHandleStr(objIds[i]));
         tmpNode.Tag = objIds[i];
         m_tvObjs.Nodes.Add(tmpNode);
     }
 }
Exemple #12
0
        private static ACADDB.ObjectIdCollection RefreshSelectionOfPolylines(ACADDB.ObjectIdCollection collection)
        {
            if (collection != null)
            {
                collection.Clear();
            }

            return(Process.GetIdsByTypeTypeValue(
                       "POLYLINE", "LWPOLYLINE", "POLYLINE2D", "POLYLINE3d"));
        }
        void StreamCollectClipBodiesSample()
        {
            Database db     = GetDatabase();
            Editor   editor = GetEditor();

            editor.WriteMessage("* StreamCollectClipBodies *\n");
            editor.WriteMessage("StreamCollectClipBodies clips all geometry pushed in against the supplied body.\n");
            editor.WriteMessage("Pick some objects in the current drawing and then pick an mass element to define the clipping boundary. The collected graphics will be highlighted in the current view.\n");

            ObjectIdCollection ids = PickObjectSet("Please pick the objects to be clipped");

            if (ids.Count == 0)
            {
                editor.WriteMessage("No object is picked\n");
                return;
            }

            ObjectId massElemId = PickObject(typeof(MassElement), true, "Please pick a mass element to define the clipping boundary");

            if (massElemId.IsNull)
            {
                editor.WriteMessage("A mass element is needed to define the clipping boundary.\n");
                return;
            }

            StreamCollectClipBodies stream = new StreamCollectClipBodies(db);
            // You may tell the stream to retain bodies instead of turning bodies into shells.
            // stream.SetRetainBodies(true);
            // But now we use the default setting, which uses shell as output.
            TransactionManager tm = db.TransactionManager;

            using (Transaction trans = tm.StartTransaction())
            {
                MassElement     masselem = trans.GetObject(massElemId, OpenMode.ForRead) as MassElement;
                AecModeler.Body body     = masselem.Body.Transform(masselem.Ecs);
                stream.SetBodyClipVolume(body);

                stream.PushDisplayParameters(DictionaryDisplayConfiguration.GetStandardDisplayConfiguration(db), trans);

                foreach (ObjectId id in ids)
                {
                    Entity entity = trans.GetObject(id, OpenMode.ForRead) as Entity;
                    stream.Stream(entity);
                }

                stream.PopDisplayParameters();
                trans.Commit();
            }

            GraphicsStorage[] gsCollection = stream.GetCollectedGraphics();
            foreach (GraphicsStorage gs in gsCollection)
            {
                HighlightGraphics(gs);
            }
        }
    ////////////////////////////
    //// Display Rep
    ////
    //// list all the display reps for MassElem and MassGroup for the current display config.
    ////////////////////////////

    private void DisplayReps()
    {
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\n====================================================\n");
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Get All the AecDbMassElem/Massgroup Display Reps for the current display config\n");
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("====================================================\n");

        Database    db    = Application.DocumentManager.MdiActiveDocument.Database;
        Transaction trans = db.TransactionManager.StartTransaction();

        Autodesk.AutoCAD.EditorInput.Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

        DisplaySet         ds  = new DisplaySet();
        ObjectIdCollection ids = DisplayRepresentationManager.GetActiveDisplayRepresentationSets(db);

        ed.WriteMessage("# of active display sets = " + ids.Count + "\n");

        DisplaySet acds = new DisplaySet();

        try
        {
            //  loop through the active disp sets (i.e., disp sets of active dis confid.)
            foreach (ObjectId id in ids)
            {
                acds = trans.GetObject(id, OpenMode.ForRead) as DisplaySet;
                foreach (ObjectId drid in acds.DisplayRepresentationIds)
                {
                    DisplayRepresentation dr = trans.GetObject(drid, OpenMode.ForRead) as DisplayRepresentation;
                    dr = trans.GetObject(drid, OpenMode.ForRead) as DisplayRepresentation;
                    RXClass rc = dr.WorksWith;
                    if (rc.Name == "AecDbMassElem" || rc.Name == "AecDbMassGroup")
                    {
                        if (ds.DisplayRepresentationIds.Contains(drid))
                        {
                            continue;
                        }
                        else
                        {
                            ds.DisplayRepresentationIds.Add(drid);
                            ListDisplayRep(dr);
                        }
                    }
                }
            }
            trans.Commit();
        }
        catch (System.Exception)
        {
            trans.Abort();
        }
        finally
        {
            trans.Dispose();
        }
        return;
    }
Exemple #15
0
 public void AddStandardBreakline(ObjectId SurfaceId, ObjectId polyId, string name)
 {
     using (Transaction tr = CivilApplicationManager.StartTransaction())
     {
         C3DLandDb.TinSurface surface  = SurfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
         ObjectIdCollection   entities = new ObjectIdCollection();
         entities.Add(polyId);
         surface.BreaklinesDefinition.AddStandardBreaklines(entities, 1.0, 1.0, 1.0, 0.0);
         tr.Commit();
     }
 }
Exemple #16
0
        public static IList <Point2dCollection> PlineToPoints(ACADDB.ObjectIdCollection collection)
        {
            IList <Point2dCollection> boundary = new List <Point2dCollection>();

            foreach (ACADDB.ObjectId pline in collection)
            {
                boundary.Add(SimplifyPolylines.Commands.GetPoint2dFromPolylines(pline));
            }

            return(boundary);
        }
Exemple #17
0
        public Breaklines(DateTime time, IList <string> listDwgs)
        {
            #region Assign Fields

            _time        = time;
            _drawingName = "";
            //_listDwgs = new List<string>(listDwgs);
            _polylines     = new List <Polyline3d>();
            _originalPolys = new ObjectIdCollection();

            #endregion
        }
        void StreamCollectMaterialsSample()
        {
            Database db     = GetDatabase();
            Editor   editor = GetEditor();

            editor.WriteMessage("* StreamCollectMaterials *\n");
            editor.WriteMessage("StreamCollectMaterials collects bodies of the specified materials from the entities pushed into the stream.\n");
            editor.WriteMessage("Pick some objects in the current drawing. The bodies with materials specifed will be highlighted. And bodies with the same material are displayed in one color.\n");

            StreamCollectMaterials stream = new StreamCollectMaterials(db);
            // StreamCollectMaterials needs the users to specify the materials they're interested in by setting the MaterialFilter property.
            // Here we add all the material ids in the current drawing to the filter collection.
            DictionaryMaterialDefinition dictMaterials = new DictionaryMaterialDefinition(db);

            stream.MaterialFilter = dictMaterials.Records;
            // To combine the bodies with the same material instead of traversing the body chain
            stream.CombineBodies = true;

            ObjectIdCollection ids = PickObjectSet();

            if (ids.Count == 0)
            {
                editor.WriteMessage("No object is picked\n");
                return;
            }

            TransactionManager tm = db.TransactionManager;

            using (Transaction trans = tm.StartTransaction())
            {
                stream.PushDisplayParameters(DictionaryDisplayConfiguration.GetStandardDisplayConfiguration(db), trans);

                foreach (ObjectId id in ids)
                {
                    Entity entity = trans.GetObject(id, OpenMode.ForRead) as Entity;
                    stream.Stream(entity);
                }

                stream.PopDisplayParameters();
                trans.Commit();
            }

            ids = stream.MaterialIds;
            int color = 1;

            foreach (ObjectId id in ids)
            {
                AecModeler.Body body = stream.GetBody(id);
                HighlightBody(body, color++);
            }
        }
Exemple #19
0
        //[CommandMethod("DWG_Open")]
        public static void OpenDwgForReadWrite(string fileName)
        {
            Document doc =
                Application.DocumentManager.MdiActiveDocument;


            if (!System.IO.File.Exists(fileName))
            {
                throw new FileNotFoundException(fileName);
            }

            // Create a database and try to load the file
            ACADDB.Database db = new ACADDB.Database(false, true);
            using (db)
            {
                try
                {
                    db.ReadDwgFile(
                        fileName,
                        System.IO.FileShare.ReadWrite,
                        false,
                        ""
                        );

                    var wdb = ACADDB.HostApplicationServices.WorkingDatabase;
                    ACADDB.HostApplicationServices.WorkingDatabase = db;

                    // Purge unused DGN linestyles from the drawing
                    // (returns false if nothing is erased)
                    ACADDB.ObjectIdCollection collection = Process.GetIdsByTypeTypeValue(
                        "POLYLINE", "LWPOLYLINE", "POLYLINE2D");

                    Process.CopyPolylinesBetweenDatabases(db, collection);


                    // Still need to reset the working database

                    ACADDB.HostApplicationServices.WorkingDatabase = wdb;
                }
                catch (System.Exception)
                {
                    COMS.MessengerManager.AddLog(String.Format(
                                                     "Unable to read drawing file.",
                                                     db.FingerprintGuid.ToString())
                                                 );
                    return;
                }
            }

            Application.DocumentManager.MdiActiveDocument = doc;
        }
Exemple #20
0
        DBObjects(AcDb.ObjectIdCollection objIds, TransactionHelper tr)
        {
            m_trans = tr;

            // Required for Windows Form Designer support
            InitializeComponent();

            m_tvObjs.BeginUpdate();

            AddObjectIdCollectionToTree(objIds);
            m_tvObjs.ExpandAll();

            m_tvObjs.EndUpdate();
        }
Exemple #21
0
        References(AcDb.ObjectIdCollection hardPointerIds, AcDb.ObjectIdCollection softPointerIds,
                   AcDb.ObjectIdCollection hardOwnerIds, AcDb.ObjectIdCollection softOwnerIds, TransactionHelper tr)
            :   base(tr)
        {
            m_tvObjs.BeginUpdate();

            AddRefsToTree("Hard Pointers", hardPointerIds);
            AddRefsToTree("Soft Pointers", softPointerIds);
            AddRefsToTree("Hard Ownership", hardOwnerIds);
            AddRefsToTree("Soft Ownership", softOwnerIds);

            m_tvObjs.ExpandAll();
            m_tvObjs.EndUpdate();
        }
Exemple #22
0
        public static IOrderedEnumerable <Acaddb.Polyline> OrderPolylines(Acaddb.ObjectIdCollection polyoId)
        {
            var ordered = new List <Acaddb.Polyline>();

            foreach (Acaddb.ObjectId i in polyoId)
            {
                using (var tr = Active.StartTransaction())
                {
                    ordered.Add(tr.GetObject(i, Acaddb.OpenMode.ForWrite) as Acaddb.Polyline);
                }
            }

            return(ordered.OrderBy(p => p.Area));
        }
        private void StreamCurvesSample()
        {
            Editor   editor = GetEditor();
            Database db     = GetDatabase();

            editor.WriteMessage("* StreamCurves *\n");
            editor.WriteMessage("StreamCurves collects curves and lines from the objects passed in.\n");
            editor.WriteMessage("Pick some objects in the current drawing. The collected graphics will be highlighted while the numbers of collected lines and curves will be printed in the output window.\n");

            ObjectIdCollection ids = PickObjectSet();

            if (ids.Count == 0)
            {
                editor.WriteMessage("No object is picked\n");
                return;
            }

            StreamCurves stream = new StreamCurves(db);

            // collect arcs instead of breaking arcs into line segments
            stream.CollectArcs = true;
            TransactionManager tm = db.TransactionManager;

            using (Transaction trans = tm.StartTransaction())
            {
                stream.PushDisplayParameters(DictionaryDisplayConfiguration.GetStandardDisplayConfiguration(db), trans);

                foreach (ObjectId id in ids)
                {
                    Entity ent = trans.GetObject(id, OpenMode.ForRead) as Entity;
                    stream.Stream(ent);
                }

                stream.PopDisplayParameters();
                trans.Commit();
            }

            LineSegment3d[] lines = stream.Lines;
            CircularArc3d[] arcs  = stream.Arcs;
            editor.WriteMessage("Collected " + lines.Length + " lines and " + arcs.Length + " arcs.\n");
            foreach (LineSegment3d line in lines)
            {
                editor.DrawVector(line.StartPoint, line.EndPoint, 1, true);
            }
            foreach (CircularArc3d arc in arcs)
            {
                HighlightArc(arc);
            }
        }
Exemple #24
0
        AddRefsToTree(string categoryStr, AcDb.ObjectIdCollection objIds)
        {
            TreeNode categoryNode = new TreeNode(categoryStr);

            categoryNode.Tag = null;
            m_tvObjs.Nodes.Add(categoryNode);

            // initialize the tree control with the ObjectId of each item
            for (int i = 0; i < objIds.Count; i++)
            {
                TreeNode tmpNode = new TreeNode(MgdDbg.Utils.AcadUi.ObjToTypeAndHandleStr(objIds[i]));
                tmpNode.Tag = objIds[i];
                categoryNode.Nodes.Add(tmpNode);
            }
        }
        //[CommandMethod("PGA-ExportTo3DSMax")]
        //public static void Export3DSMax()
        //{
        //    PasteSurfaces surfaceManager = new PasteSurfaces();
        //    Database db = Application.DocumentManager.MdiActiveDocument.Database;
        //    Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

        //    try
        //    {
        //        ObjectIdCollection surfaces = surfaceManager.GetAllSurfaces();

        //        foreach (ObjectId surfaceId in surfaces)
        //        {
        //            using (Transaction trans = db.TransactionManager.StartTransaction())
        //            {
        //                TinSurface surface = trans.GetObject(surfaceId, OpenMode.ForWrite) as TinSurface;

        //                surface.GetTriangles(true);


        //                trans.Commit();
        //            }

        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        ACADLogging.LogMyExceptions(e.Message);
        //    }

        //}
        public static Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection CloseSelectedPolylines()
        {
            Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection oids;
            oids = new Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection();

            SelectionSet selection;

            selection = BBC.Common.AutoCAD.SelectionManager.GetSelectionSet("");

            foreach (ObjectId obj in selection.GetObjectIds())
            {
                oids.Add(obj);
            }
            return(oids);
        }
        private acaddb.ObjectId findObjectInDocument(Document document)
        {
            ObjectNodeProvider provider = document.NodeProvider;

            acaddb.ObjectIdCollection objectNode = provider.GetNode(typeof(T));
            foreach (acaddb.ObjectId id in objectNode)
            {
                c3ddb.Entity entity = id.GetObject(acaddb.OpenMode.ForRead)
                                      as c3ddb.Entity;
                if (entity.Name == ObjectName)
                {
                    return(id);
                }
            }
            return(acaddb.ObjectId.Null);
        }
Exemple #27
0
        public static Parcel ByIndex(Autodesk.AutoCAD.DynamoNodes.Document document, Site siteObject, int index)
        {
            Parcel retParcel = null;

            //get the current document and database
            AcadApp.Document doc = document.AcDocument;
            Database         db  = doc.Database;

            Autodesk.Civil.DatabaseServices.Site site = (Autodesk.Civil.DatabaseServices.Site)siteObject._curCivilObject;
            Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection parcelIds = site.GetParcelIds();
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                retParcel = new Parcel((Autodesk.Civil.DatabaseServices.Entity)trans.GetObject(parcelIds[index], OpenMode.ForRead), true);
            }
            return(retParcel);
        }
Exemple #28
0
        public void AddFeatureLinesToAllSurface(ObjectIdCollection featureIds, ObjectId surfaceId)
        {
            Debug.WriteLine("Starting AddFeatureLinesToAllSurface");
            using (Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                using (Transaction tr = CivilApplicationManager.StartTransaction())
                {
                    C3DLandDb.TinSurface surface = surfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
                    surface.UpgradeOpen();
                    surface.BreaklinesDefinition.AddStandardBreaklines(featureIds, 1.0, 2.0, 2.0, 0.0);
                    surface.DowngradeOpen();

                    tr.Commit();
                    Debug.WriteLine("Ending AddFeatureLinesToAllSurface");
                }
            }
        }
        void StreamSliceSample()
        {
            Database db     = GetDatabase();
            Editor   editor = GetEditor();

            editor.WriteMessage("* StreamSlice *\n");
            editor.WriteMessage("StreamSlice slices bodies with a plane.\n");
            editor.WriteMessage("Pick some objects in the current drawing to be sliced and then pick three points to define the plane. The result profile will be highlighted.\n");
            ObjectIdCollection ids = PickObjectSet("Please pick the bodies need to be sliced");

            if (ids.Count == 0)
            {
                editor.WriteMessage("No object is picked\n");
                return;
            }

            editor.WriteMessage("Now you need to pick 3 points from the screen to define the slicing plane.\n");
            Plane plane = PromptPlane();

            if (plane == null)
            {
                return;
            }

            StreamSlice stream = new StreamSlice(db, plane);

            TransactionManager tm = db.TransactionManager;

            using (Transaction trans = tm.StartTransaction())
            {
                stream.PushDisplayParameters(DictionaryDisplayConfiguration.GetStandardDisplayConfiguration(db), trans);

                foreach (ObjectId id in ids)
                {
                    Entity ent = trans.GetObject(id, OpenMode.ForRead) as Entity;
                    stream.Stream(ent);
                }

                stream.PopDisplayParameters();
                trans.Commit();
            }

            HighlightProfile(stream.GetProfile(), plane);
        }
Exemple #30
0
        public void SelectAlignment()
        {
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    PromptEntityOptions prEntOpts = new PromptEntityOptions("\nPlease select exsisting alignment: ");
                    prEntOpts.AllowNone = true;
                    prEntOpts.SetRejectMessage("\n Selected object must be an alignment type");
                    prEntOpts.AddAllowedClass(typeof(Alignment), true);

                    PromptEntityResult prEntRes = ed.GetEntity(prEntOpts);
                    if (prEntRes.Status != PromptStatus.OK)
                    {
                        MessageBox.Show("Please repeat selection", "Info", MessageBoxButtons.OK);
                    }

                    else
                    {
                        Alignment alig = tr.GetObject(prEntRes.ObjectId, OpenMode.ForRead) as Alignment;
                        ed.WriteMessage("\n You selected alignment: " + alig.Name);

                        selectedALig = alig;
                        ObjectIdCollection profIds = selectedALig.GetProfileIds();
                        foreach (ObjectId id in profIds)
                        {
                            Autodesk.Civil.DatabaseServices.Profile prof = tr.GetObject(id, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Profile;
                            profiles.Add(prof);
                        }

                        tr.Commit();
                    }
                }

                catch (System.Exception ex)
                {
                    ed.WriteMessage("Error encountered" + ex.Message);
                    tr.Abort();
                    selectedALig = null;
                }
            }
        }