Ejemplo n.º 1
0
Archivo: Ldr.cs Proyecto: 15831944/EM
 setLdrVertex(ObjectId idLdr, int indx, Point3d pnt3d)
 {
     using (var tr = BaseObjs.startTransactionDb())
     {
         Leader ldr = (Leader)tr.GetObject(idLdr, OpenMode.ForRead);
         ldr.SetVertexAt(indx, pnt3d);
         tr.Commit();
     }
 }
Ejemplo n.º 2
0
        AVG(ObjectId idPoly, Point3d pnt3dCEN, double dblSlope, double dblPadElev, bool boolSetPointAtCenter, Point3d pnt3dTAR)
        {
            ObjectIdCollection idsPoly3d = new ObjectIdCollection();

            double   dblDist = 0.0;
            uint     pntNum;
            ObjectId idPoly3d = ObjectId.Null;

            switch (boolSetPointAtCenter)
            {
            case true:
                pnt3dCEN.setPoint(out pntNum, "CPNT-ON");
                break;

            case false:

                pnt3dCEN = new Point3d(pnt3dCEN.X, pnt3dCEN.Y, dblPadElev);

                if (pnt3dTAR != Pub.pnt3dO)
                {
                    dblDist = pnt3dCEN.getDistance(pnt3dTAR);
                }

                using (BaseObjs._acadDoc.LockDocument())
                {
                    pnt3dCEN.setPoint(out pntNum, "CPNT-ON");

                    if (pnt3dTAR != Pub.pnt3dO)
                    {
                        pnt3dTAR = new Point3d(pnt3dTAR.X, pnt3dTAR.Y, pnt3dCEN.Z + dblDist * dblSlope);
                        pnt3dTAR.setPoint(out pntNum, "CPNT-ON");
                    }

                    idsPoly3d = DrawFloorSlab.build3dPolyFloorSlab(idPoly, pnt3dCEN, pnt3dTAR, dblSlope, "CPNT-ON", "CPNT-BRKLINE", "AVG");

                    int numBldg = updateDictGRADEDOCK(idsPoly3d[0].getHandle(), dblSlope, pnt3dCEN, pnt3dTAR);

                    modSurface("CPNT-ON", "Finish Surface", idsPoly3d, true);

                    TypedValue[] tvs = new TypedValue[3];
                    tvs.SetValue(new TypedValue(1001, "AVG"), 0);
                    tvs.SetValue(new TypedValue(1000, "BLDG"), 1);
                    tvs.SetValue(new TypedValue(1070, numBldg), 2);           //Number assigned; to building

                    foreach (ObjectId id in idsPoly3d)
                    {
                        id.setXData(tvs, "AVG");
                    }
                }
                break;
            }

            using (BaseObjs._acadDoc.LockDocument())
            {
                BaseObjs.regen();
            }
        }
Ejemplo n.º 3
0
        public static void doMXR()
        {
            string title  = "Multiple XRef - MXR";
            string dir    = Path.GetDirectoryName(BaseObjs.docFullName);
            string filter = "All Drawings (*.dwg)|*.dwg|Current Design Files1 (*.dwg)|????BNDY.dwg;????CGP.dwg;????CUP.dwg;????CNTL.dwg;????CONT.dwg;????DEMO.dwg;????GCAL.dwg;????SD.dwg;????TOPO.dwg;????T-SITE.dwg;????UTIL.dwg|Current Design Files2(*.dwg)|*BNDY.dwg;*CGP.dwg;*CUP.dwg;*CNTL.dwg;*CONT.dwg;*DEMO.dwg;*GCAL.dwg;*SD.dwg;*TOPO.dwg;*T-SITE.dwg;*UTIL.dwg|_JDH Files (*_JDH.dwg)|*_JDH.dwg";
            string defExt = ".dwg";

            string[] files = FileManager.getFiles(defExt, title, filter, dir);


            if (files == null || files.Length == 0)
            {
                return;
            }

            string jn = BaseObjs.jobNumber();

            object tMode = Application.GetSystemVariable("TILEMODE");

            if (tMode.ToString() != "1")
            {
                BaseObjs._editor.Command("_tilemode", "1", "");
            }

            BaseObjs._editor.Command("_ucs", "w", "");

            for (int i = 0; i < files.Length; i++)
            {
                string nameLayer = string.Format("_{0}", Path.GetFileNameWithoutExtension(files[i]));
                Layer.manageLayers(nameLayer);

                string nameXRef = nameLayer.Replace("_", "x");

                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    ObjectId id = BaseObjs._db.AttachXref(files[i], nameXRef);

                    if (!id.IsNull)
                    {
                        using (BlockReference br = new BlockReference(Point3d.Origin, id))
                        {
                            BlockTable       bt = (BlockTable)BaseObjs._db.BlockTableId.GetObject(OpenMode.ForRead);
                            BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                            ms.AppendEntity(br);
                            tr.AddNewlyCreatedDBObject(br, true);
                            br.Layer = nameLayer;
                        }
                    }
                    tr.Commit();
                }
            }
            Editor ed = BaseObjs._editor;

            ed.Command("_.LAYER", "C", "9", "*TOPO*", "");
        }
Ejemplo n.º 4
0
        addVertexToPoly3d(this ObjectId idPoly3dOrg, Point3d pnt3d, int pos, Handle hCgPNt)
        {
            List <Point3d> pnts3d      = idPoly3dOrg.getCoordinates3dList();
            ObjectId       idPoly3dNew = ObjectId.Null;
            Polyline3d     poly3dNew   = new Polyline3d();

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                BlockTableRecord ms = Blocks.getBlockTableRecordMS();
                idPoly3dNew = ms.AppendEntity(poly3dNew);

                poly3dNew.SetDatabaseDefaults();
                poly3dNew.Layer = idPoly3dOrg.getLayer();
                pnts3d.Insert(pos + 1, pnt3d);
                foreach (Point3d pnt3dX in pnts3d)
                {
                    PolylineVertex3d v3d = new PolylineVertex3d(pnt3dX);
                    poly3dNew.AppendVertex(v3d);
                    tr.AddNewlyCreatedDBObject(v3d, true);
                }
                tr.AddNewlyCreatedDBObject(poly3dNew, true);
                tr.Commit();
            }

            using (Transaction tr1 = BaseObjs.startTransactionDb())
            {
                DBObject dbObjOrg = tr1.GetObject(idPoly3dOrg, OpenMode.ForRead);
                DBObject dbObjNew = tr1.GetObject(idPoly3dNew, OpenMode.ForRead);

                dbObjNew.UpgradeOpen();
                dbObjNew.SwapIdWith(dbObjOrg.ObjectId, true, true);

                idPoly3dNew.delete();
                tr1.Commit();
            }

            ResultBuffer rb = idPoly3dOrg.getXData(apps.lnkBrks);

            TypedValue[] tvs = rb.AsArray();

            TypedValue[] tvsNew = new TypedValue[tvs.Length + 1];
            for (int i = 0; i < pos + 2; i++)
            {
                tvsNew[i] = tvs[i];
            }
            tvsNew.SetValue(new TypedValue(1005, hCgPNt), pos + 2);

            for (int i = pos + 2; i < tvs.Length; i++)
            {
                tvsNew[i + 1] = tvs[i];
            }

            idPoly3dOrg.clearXData(apps.lnkBrks);
            idPoly3dOrg.setXData(tvsNew, apps.lnkBrks);
        }
Ejemplo n.º 5
0
        getBlockRefName(ObjectId idBR)
        {
            string nameBlkRef;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                BlockReference br = (BlockReference)tr.GetObject(idBR, OpenMode.ForRead);
                nameBlkRef = br.Name;
            }
            return(nameBlkRef);
        }
Ejemplo n.º 6
0
Archivo: xData.cs Proyecto: 15831944/EM
        removeCmdXDataFromCogoPoint(ObjectId id, string nameApp, string nameCmd)
        {
            TypedValue[] tvsNew = null;
            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    if (id.getType() != "CogoPoint")
                    {
                        return;
                    }
                    ResultBuffer rb = id.getXData(nameApp);
                    if (rb == null)
                    {
                        return;
                    }

                    TypedValue[] tvs = rb.AsArray();
                    int          x   = 0;
                    for (int i = 1; i < tvs.Length; i++)
                    {
                        if (nameCmd == tvs[i].Value.ToString())
                        {
                            x = i;
                            break;
                        }
                    }
                    if (tvs.Length > 4)
                    {
                        int n = -1;
                        tvsNew = new TypedValue[tvs.Length - 3];
                        for (int j = 0; j < tvs.Length; j++)
                        {
                            if (j < x || j >= x + 3)
                            {
                                tvsNew[++n] = tvs[j];
                            }
                        }

                        removeAppXData(id, nameApp);
                        id.setXData(tvsNew, nameApp);
                    }
                    else
                    {
                        removeAppXData(id, nameApp);
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " xData.cs: line: 505");
            }
        }
Ejemplo n.º 7
0
Archivo: Misc.cs Proyecto: 15831944/EM
        showHandle()
        {
            bool   escape = true;
            Entity ent    = Select.selectEntity("Select ent:", out escape);

            if (escape)
            {
                return;
            }
            BaseObjs.write(string.Format("\nHandle: {0}", ent.Handle.ToString()));
        }
Ejemplo n.º 8
0
 public static void StreamMessage(string str)
 {
     try
     {
         //InfoMessageBox(str);
         StreamToRichTextControl(str);
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(ex.Message + " Helper.cs: line: 26");
     }
 }
Ejemplo n.º 9
0
        fixXrefs()
        {
            DBObject DbObj;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    SelectionSet SS = Base_Tools45.Select.buildSSet(typeof(BlockReference), true);
                    if (SS == null)
                    {
                        return;
                    }

                    foreach (SelectedObject ssObj in SS)
                    {
                        DbObj = ssObj.ObjectId.GetObject(OpenMode.ForRead);

                        if (DbObj is BlockReference)
                        {
                            BlockReference   BR  = (BlockReference)DbObj;
                            ObjectId         id  = BR.BlockTableRecord;
                            BlockTableRecord Btr = (BlockTableRecord)id.GetObject(OpenMode.ForRead);
                            string           nameLayer;
                            if (Btr.XrefStatus == XrefStatus.Resolved)
                            {
                                if (Btr.Name.Substring(1, 1) != "x")
                                {
                                    nameLayer = string.Format("_{0}", Btr.Name);
                                    Btr.UpgradeOpen();
                                    Btr.Name = string.Format("x{0}", Btr.Name);
                                }
                                else
                                {
                                    nameLayer = String.Format("_{0}", Btr.Name.Substring(2));
                                }
                                if (BR.Layer != nameLayer)
                                {
                                    BR.UpgradeOpen();
                                    Layer.manageLayers(nameLayer);
                                    BR.Layer = nameLayer;
                                }
                            }
                        }
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " xRef.cs: line: 307");
            }
        }
Ejemplo n.º 10
0
Archivo: Ldr.cs Proyecto: 15831944/EM
        getLdrVerticeCount(ObjectId idLdr)
        {
            int numV = 0;

            using (var tr = BaseObjs.startTransactionDb())
            {
                Leader ldr = (Leader)tr.GetObject(idLdr, OpenMode.ForRead);
                numV = ldr.NumVertices;
                tr.Commit();
            }
            return(numV);
        }
Ejemplo n.º 11
0
Archivo: Ldr.cs Proyecto: 15831944/EM
        getLdrAnnotationObject(ObjectId idLdr)
        {
            ObjectId idMTxt = ObjectId.Null;

            using (var tr = BaseObjs.startTransactionDb())
            {
                Leader ldr = (Leader)tr.GetObject(idLdr, OpenMode.ForRead);
                idMTxt = ldr.Annotation;
                tr.Commit();
            }
            return(idMTxt);
        }
Ejemplo n.º 12
0
        public static void GetCmdMethodInfo()
        {
            Assembly assem = Assembly.GetExecutingAssembly();

            List <string> cmdsGlobal = new List <string>();
            List <string> cmdsLocal  = new List <string>();
            List <string> cmdsGroup  = new List <string>();

            Module[] mods = assem.GetModules(true);
            foreach (Module mod in mods)
            {
                Type[] types = mod.GetTypes();
                foreach (Type type in types)
                {
                    ResourceManager rm = new ResourceManager(type.FullName, assem);
                    rm.IgnoreCase = true;

                    MethodInfo[] meths = type.GetMethods();
                    foreach (MethodInfo meth in meths)
                    {
                        object[] atts = meth.GetCustomAttributes(typeof(CommandMethodAttribute), true);
                        foreach (object att in atts)
                        {
                            CommandMethodAttribute cmdAtt = (CommandMethodAttribute)att;
                            if (cmdAtt != null)
                            {
                                string nameGlobal    = cmdAtt.GlobalName;
                                string nameLocal     = nameGlobal;
                                string nameLocalized = cmdAtt.LocalizedNameId;
                                if (nameLocalized != null)
                                {
                                    try
                                    {
                                        nameLocal = rm.GetString(nameLocalized);
                                    }
                                    catch (System.Exception ex)
                                    {
                                        BaseObjs.writeDebug(ex.Message + " ExtractMethods.cs: line: 48");
                                    }
                                }
                                cmdsGlobal.Add(nameGlobal);
                                cmdsLocal.Add(nameLocal);
                                if (cmdAtt.GroupName != null && !cmdsGroup.Contains(cmdAtt.GroupName))
                                {
                                    cmdsGlobal.Add(cmdAtt.GroupName);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 13
0
        getPoint(string strPrompt, Point3d pnt3d, out bool escape, out PromptStatus promptStatus, int osMode)
        {
            object mode = SnapMode.getOSnap();

            SnapMode.setOSnap(osMode);

            promptStatus = PromptStatus.Error;
            escape       = false;
            Point3d           pnt3dX = Pub.pnt3dO;
            Editor            ED     = BaseObjs._editor;
            PromptPointResult PPR    = null;

            PromptPointOptions PPO = new PromptPointOptions(strPrompt);

            PPO.AllowNone = true;
            if (pnt3d != pnt3dX)
            {
                PPO.AllowNone     = true;
                PPO.UseBasePoint  = true;
                PPO.BasePoint     = pnt3d;
                PPO.UseDashedLine = true;
            }

            try
            {
                PPR = ED.GetPoint(PPO);
                switch (PPR.Status)
                {
                case PromptStatus.Cancel:
                    escape = true;
                    break;

                case PromptStatus.Other:
                    pnt3dX = Pub.pnt3dO;
                    break;

                case PromptStatus.OK:
                    pnt3dX = PPR.Value;
                    break;
                }
                promptStatus = PPR.Status;
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " UserInput.cs: line: 138");
            }
            finally
            {
                SnapMode.setOSnap((int)mode);
            }
            return(pnt3dX);
        }
Ejemplo n.º 14
0
        getXRefBlockTableRecordMS(string nameDwg)
        {
            BlockTableRecord ms;
            BlockReference   br = getXRefBlockReference(nameDwg);

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                BlockTable       bt  = (BlockTable)br.Database.BlockTableId.GetObject(OpenMode.ForRead);
                BlockTableRecord btr = (BlockTableRecord)bt[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForRead);
                ms = btr;
            }
            return(ms);
        }
Ejemplo n.º 15
0
        highlightNestedEntity()
        {
            Document doc =
                Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;

            PromptNestedEntityResult rs =
                ed.GetNestedEntity("\nSelect nested entity: ");

            if (rs.Status == PromptStatus.OK)
            {
                ObjectId[] objIds = rs.GetContainers();
                ObjectId   ensel  = rs.ObjectId;
                int        len    = objIds.Length;

                // Reverse the "containers" list
                ObjectId[] revIds = new ObjectId[len + 1];
                for (int i = 0; i < len; i++)
                {
                    ObjectId id =
                        (ObjectId)objIds.GetValue(len - i - 1);
                    revIds.SetValue(id, i);
                }
                // Now add the selected entity to the end
                revIds.SetValue(ensel, len);

                // Retrieve the sub-entity path for this entity
                SubentityId subEnt =
                    new SubentityId(SubentityType.Null, (IntPtr)0);
                FullSubentityPath path =
                    new FullSubentityPath(revIds, subEnt);

                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        // Open the outermost container...
                        ObjectId id  = (ObjectId)revIds.GetValue(0);
                        Entity   ent =
                            (Entity)tr.GetObject(id, OpenMode.ForRead);
                        // ... and highlight the nested entity
                        ent.Highlight(path, false);
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " View.cs: line: 162");
                }
            }
        }
Ejemplo n.º 16
0
        deepClone(ObjectIdCollection ids, Point3d pnt3dBase)
        {
            Entity             dbObj  = null;
            Database           db     = BaseObjs._db;
            ObjectIdCollection idsNew = new ObjectIdCollection();

            try
            {
                using (BaseObjs._acadDoc.LockDocument())
                {
                    try
                    {
                        using (Transaction tr = BaseObjs.startTransactionDb())
                        {
                            IdMapping idMap = new IdMapping();
                            db.DeepCloneObjects(ids, db.CurrentSpaceId, idMap, false);
                            foreach (IdPair idP in idMap)
                            {
                                ObjectId id = idP.Value;
                                dbObj = (Entity)id.GetObject(OpenMode.ForWrite);
                                idsNew.Add(id);
                            }

                            JigDraw jDraw = new JigDraw(pnt3dBase);
                            jDraw.AddEntity(idsNew);

                            PromptResult jRes = BaseObjs._editor.Drag(jDraw);
                            if (jRes.Status == PromptStatus.OK)
                            {
                                jDraw.TransformEntities();
                            }
                            else
                            {
                                return;
                            }

                            db.Dispose();
                            tr.Commit();
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " Blocks.cs: line: 634");
                    }
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Blocks.cs: line: 640");
            }
        }
Ejemplo n.º 17
0
        selectCogoPntAtPoint3d(Point3d pnt3d)
        {
            Autodesk.AutoCAD.DatabaseServices.Entity ENT = null;
            Point3d   pnt3d0  = new Point3d(pnt3d.X, pnt3d.Y, 0);
            CogoPoint cogoPnt = null;
            ObjectId  idCgPnt = ObjectId.Null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    TypedValue[] TVs = new TypedValue[1];
                    TVs.SetValue(new TypedValue((int)DxfCode.Start, "AECC_COGO_POINT"), 0);
                    SelectionFilter FILTER = new SelectionFilter(TVs);

                    PromptSelectionResult PSR = BaseObjs._editor.SelectCrossingWindow(pnt3d0, pnt3d0, FILTER);

                    if (PSR.Status == PromptStatus.OK)
                    {
                        SelectionSet SS = PSR.Value;

                        if (SS.Count > 1)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format("{0} Points Found at Selected Location - Exiting....", SS.Count.ToString()));
                            tr.Commit();
                            return(idCgPnt);
                        }
                        SelectedObject OBJ = SS[0];
                        if (OBJ != null)
                        {
                            ENT = tr.GetObject(OBJ.ObjectId, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
                        }
                        if (ENT != null)
                        {
                            if (ENT is CogoPoint)
                            {
                                cogoPnt = (CogoPoint)ENT;
                                idCgPnt = cogoPnt.ObjectId;
                                tr.Commit();
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Select.cs: line: 454");
            }
            return(idCgPnt);
        }
Ejemplo n.º 18
0
Archivo: Db.cs Proyecto: 15831944/EM
        handleToObjectId(Database db, Handle h)
        {
            ObjectId id = ObjectId.Null;

            try
            {
                id = db.GetObjectId(false, h, 0);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Db.cs: line: 234");
            }
            return(id);
        }
Ejemplo n.º 19
0
 reverse(this ObjectId idLine)
 {
     if (idLine.getType() == "Line")
     {
         using (Transaction tr = BaseObjs.startTransactionDb())
         {
             Line    line  = (Line)tr.GetObject(idLine, OpenMode.ForWrite);
             Point3d pnt3d = line.StartPoint;
             line.StartPoint = line.EndPoint;
             line.EndPoint   = pnt3d;
             tr.Commit();
         }
     }
 }
Ejemplo n.º 20
0
        getOwnerOfVertex2d3d(this ObjectId idV3d)
        {
            ObjectId idPoly2d3d = ObjectId.Null;

            using (var tr = BaseObjs.startTransactionDb())
            {
                DBObject obj = idV3d.GetObject(OpenMode.ForRead);
                if (obj is PolylineVertex3d || obj is Vertex2d)
                {
                    idPoly2d3d = obj.OwnerId;
                }
            }
            return(idPoly2d3d);
        }
Ejemplo n.º 21
0
Archivo: UCsys.cs Proyecto: 15831944/EM
        setUCS2Object(Point3d pnt3dBase0, Point3d pnt3dBaseX, Point3d pnt3dBaseY)
        {
            Vector3d vec3dXaxis = new Vector3d(pnt3dBaseX.X - pnt3dBase0.X, pnt3dBaseX.Y - pnt3dBase0.Y, pnt3dBaseX.Z - pnt3dBase0.Z);
            Vector3d vec3dYaxis = new Vector3d(pnt3dBaseY.X - pnt3dBase0.X, pnt3dBaseY.Y - pnt3dBase0.Y, pnt3dBaseY.Z - pnt3dBase0.Z);

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    // Open the UCS table for read
                    UcsTable       acUCSTbl = getUcsTable();
                    UcsTableRecord acUCSTblRec;

                    // Check to see if the "New_UCS" UCS table record exists
                    if (acUCSTbl.Has("Temp") == false)
                    {
                        acUCSTblRec      = new UcsTableRecord();
                        acUCSTblRec.Name = "Temp";

                        // Open the UCSTable for write
                        acUCSTbl.UpgradeOpen();

                        // Add the new UCS table record
                        acUCSTbl.Add(acUCSTblRec);
                        tr.AddNewlyCreatedDBObject(acUCSTblRec, true);
                    }
                    else
                    {
                        acUCSTblRec = tr.GetObject(acUCSTbl["Temp"], OpenMode.ForWrite) as UcsTableRecord;
                    }

                    acUCSTblRec.Origin = pnt3dBase0;
                    acUCSTblRec.XAxis  = vec3dXaxis;
                    acUCSTblRec.YAxis  = vec3dYaxis;

                    // Open the active viewport
                    ViewportTableRecord acVportTblRec;
                    acVportTblRec = tr.GetObject(BaseObjs._editor.ActiveViewportId, OpenMode.ForWrite) as ViewportTableRecord;
                    // Set the UCS current
                    acVportTblRec.SetUcs(acUCSTblRec.ObjectId);
                    BaseObjs._editor.UpdateTiledViewportsFromDatabase();

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " UCsys.cs: line: 328");
            }
        }
Ejemplo n.º 22
0
        // When the OFFSET command starts, let's add our selection manipulating event-handler
        /// <summary>
        ///
        /// </summary>
        public void Initialize()
        {
            DocumentCollection dm = Application.DocumentManager;

            // Remove any temporary objects at the end of the command

            dm.DocumentLockModeWillChange += delegate(object sender, DocumentLockModeWillChangeEventArgs e)
            {
                if (_ids.Count > 0)
                {
                    try
                    {
                        using (Transaction tr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
                        {
                            foreach (ObjectId id in _ids)
                            {
                                DBObject obj = id.GetObject(OpenMode.ForWrite, true);
                                obj.Erase();
                            }
                            tr.Commit();
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " xRefOffsetApp.cs: line: 64");
                    }
                    _ids.Clear();
                }
            };

            // When a document is created, make sure we handle the important events it fires

            dm.DocumentCreated += delegate(object sender, DocumentCollectionEventArgs e)
            {
                e.Document.CommandWillStart += new CommandEventHandler(OnCommandWillStart);
                e.Document.CommandEnded     += new CommandEventHandler(OnCommandFinished);
                e.Document.CommandCancelled += new CommandEventHandler(OnCommandFinished);
                e.Document.CommandFailed    += new CommandEventHandler(OnCommandFinished);
            };

            // Do the same for any documents existing on application initialization

            foreach (Document doc in dm)
            {
                doc.CommandWillStart += new CommandEventHandler(OnCommandWillStart);
                doc.CommandEnded     += new CommandEventHandler(OnCommandFinished);
                doc.CommandCancelled += new CommandEventHandler(OnCommandFinished);
                doc.CommandFailed    += new CommandEventHandler(OnCommandFinished);
            }
        }
Ejemplo n.º 23
0
Archivo: Db.cs Proyecto: 15831944/EM
 transformToWcs(this ObjectId id, Database db)
 {
     if (id == ObjectId.Null)
     {
         return;
     }
     using (Transaction tr = BaseObjs.startTransactionDb())
     {
         Entity   ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);
         Matrix3d m   = getUcsMatrix(db);
         ent.TransformBy(m);
         tr.Commit();
     }
 }
Ejemplo n.º 24
0
        addBlockRefPolyLdr(List <Vertex2d> vtxs2d, string nameLayer = "0", short color = 256)
        {
            ObjectId id = ObjectId.Null;
            Database db = BaseObjs._db;

            Layer.manageLayers(nameLayer);
            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    Polyline poly = new Polyline();
                    int      i    = -1;
                    poly.SetDatabaseDefaults();
                    foreach (Vertex2d vtx2d in vtxs2d)
                    {
                        i = ++i;
                        Point2d pnt2d = new Point2d(vtx2d.Position.X, vtx2d.Position.Y);
                        poly.AddVertexAt(i, pnt2d, vtx2d.Bulge, vtx2d.StartWidth, vtx2d.EndWidth);
                    }
                    poly.Layer = nameLayer;
                    poly.Color = Color.FromColorIndex(ColorMethod.ByBlock, color);

                    BlockTable       bt  = (BlockTable)db.BlockTableId.GetObject(OpenMode.ForWrite);
                    BlockTableRecord btr = new BlockTableRecord();
                    btr.Name       = "*U";
                    btr.Explodable = false;
                    btr.Origin     = poly.StartPoint;
                    btr.AppendEntity(poly);
                    btr.Annotative = AnnotativeStates.True;
                    ObjectId idbtr = bt.Add(btr);
                    tr.AddNewlyCreatedDBObject(btr, true);

                    BlockTableRecord ms = (BlockTableRecord)bt[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForWrite);
                    BlockReference   br = new BlockReference(poly.StartPoint, idbtr);
                    //BlockTableRecord btrPoly = (BlockTableRecord)tr.GetObject(br.ObjectId, OpenMode.ForWrite);
                    //btrPoly.Name = "*U";
                    //btrPoly.Annotative = AnnotativeStates.True;

                    id = ms.AppendEntity(br);
                    tr.AddNewlyCreatedDBObject(br, true);
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Blocks.cs: line: 467");
            }
            return(id);
        }
Ejemplo n.º 25
0
Archivo: xRef2.cs Proyecto: 15831944/EM
        getNestedEntityCoordinates(Handle h, string nameFile)
        {
            Entity ent = null;

            Database xdb = new Database(false, true);

            xdb.ReadDwgFile(nameFile, FileOpenMode.OpenForReadAndReadShare, true, null);
            List <Point3d> pnts3d = new List <Point3d>();

            //BlockReference br = getXRefBlock(nameFile);
            //ObjectId idbtr = br.BlockTableRecord;

            try
            {
                using (Transaction tr = xdb.TransactionManager.StartOpenCloseTransaction())
                {
                    //BlockTableRecord btr = (BlockTableRecord)tr.GetObject(idbtr, OpenMode.ForRead);
                    //Database dbXRef = btr.Database;
                    ObjectId id = Db.handleToObjectId(xdb, h);
                    if (!id.IsValid)
                    {
                        return(pnts3d);
                    }

                    ent = (Entity)tr.GetObject(id, OpenMode.ForRead);
                    if (ent is Line)
                    {
                        Line line = (Line)ent;
                        pnts3d.Add(line.StartPoint);
                        pnts3d.Add(line.EndPoint);
                    }
                    else if (ent is Polyline || ent is Polyline3d)
                    {
                        pnts3d = Conv.polyX_listPnts3d(id);
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " xRef2.cs: line: 151");
            }
            finally
            {
                xdb.Dispose();
                xdb = null;
            }
            return(pnts3d);
        }
Ejemplo n.º 26
0
 public static void InfoMessageBox(string str)
 {
     try
     {
         System.Windows.Forms.MessageBox.Show(
             str,
             "Events Watcher",
             System.Windows.Forms.MessageBoxButtons.OK,
             System.Windows.Forms.MessageBoxIcon.Information);
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(ex.Message + " Helper.cs: line: 58");
     }
 }
Ejemplo n.º 27
0
Archivo: Db.cs Proyecto: 15831944/EM
        stringToHandle(this String strHandle)
        {
            Handle handle = new Handle();

            try
            {
                Int64 nHandle = Convert.ToInt64(strHandle, 16);
                handle = new Handle(nHandle);
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Db.cs: line: 489");
            }
            return(handle);
        }
Ejemplo n.º 28
0
 AddToCurrentSpaceAndClose(DBObjectCollection ents, Database db)
 {
     try
     {
         using (Transaction tr = BaseObjs.startTransactionDb())
         {
             AddToCurrentSpace(ents, db);
             tr.Commit();
         }
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(ex.Message + " SymTbl.cs: line: 148");
     }
 }
Ejemplo n.º 29
0
 public static void Message(System.Exception ex0)
 {
     try
     {
         System.Windows.Forms.MessageBox.Show(
             ex0.ToString(),
             "Error",
             System.Windows.Forms.MessageBoxButtons.OK,
             System.Windows.Forms.MessageBoxIcon.Error);
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(ex.Message + " Helper.cs: line: 42");
     }
 }
Ejemplo n.º 30
0
Archivo: Dict.cs Proyecto: 15831944/EM
        getNamedDictionary(string name, out bool exists)
        {
            exists = false;
            Database     db      = HostApplicationServices.WorkingDatabase;
            DBDictionary appDict = null;
            ObjectId     idDict  = ObjectId.Null;
            DBDictionary dictNOD = null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    try
                    {
                        dictNOD = (DBDictionary)db.NamedObjectsDictionaryId.GetObject(OpenMode.ForRead);
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " Dict.cs: line: 407");
                    }
                    try
                    {
                        if (dictNOD.Contains(name))
                        {
                            idDict = dictNOD.GetAt(name);
                            exists = true;
                        }
                        else
                        {
                            dictNOD.UpgradeOpen();
                            appDict = new DBDictionary();
                            idDict  = dictNOD.SetAt(name, appDict);
                            tr.AddNewlyCreatedDBObject(appDict, true);
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " Dict.cs: line: 426");
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Dict.cs: line: 433");
            }
            return(idDict);
        }