コード例 #1
0
        public static bool InPoly(_AcGe.Point3d vertexPoint, _AcDb.Entity pElFG)
        {
            int nrTrue  = 0;
            int nrFalse = 0;

            if (InPoly(vertexPoint, 1.0, 1.0, pElFG))
            {
                nrTrue++;
            }
            else
            {
                nrFalse++;
            }

            if (InPoly(vertexPoint, -1.0, 1.0, pElFG))
            {
                nrTrue++;
            }
            else
            {
                nrFalse++;
            }

            if (InPoly(vertexPoint, -1.0, -1.0, pElFG))
            {
                nrTrue++;
            }
            else
            {
                nrFalse++;
            }

            return(nrTrue > nrFalse);
        }
コード例 #2
0
        private _Db.DBObjectCollection getGeometry()
        {
            _Db.DBObjectCollection geometry = new _Db.DBObjectCollection();

            _Ed.PromptSelectionOptions opts = new _Ed.PromptSelectionOptions();
            opts.MessageForAdding = "\nSelect Geometry: ";
            _Ed.PromptSelectionResult userSelection = _c.doc.Editor.GetSelection(opts);
            if (userSelection.Status != _Ed.PromptStatus.OK)
            {
                throw new DMTException("[ERROR] Geometry - cancelled");
            }

            _Ed.SelectionSet selectionSet = userSelection.Value;

            foreach (_Ed.SelectedObject currentObject in selectionSet)
            {
                if (currentObject == null)
                {
                    continue;
                }

                _Db.Entity currentEntity = _c.trans.GetObject(currentObject.ObjectId, _Db.OpenMode.ForRead) as _Db.Entity;
                if (currentEntity == null)
                {
                    continue;
                }

                if (currentEntity is _Db.Curve)
                {
                    geometry.Add(currentEntity);
                }
            }

            return(geometry);
        }
コード例 #3
0
        private List <_Db.RotatedDimension> getAllDims()
        {
            List <_Db.RotatedDimension> dims = new List <_Db.RotatedDimension>();

            foreach (_Db.ObjectId btrId in _c.blockTable)
            {
                _Db.BlockTableRecord btr = _c.trans.GetObject(btrId, _Db.OpenMode.ForWrite) as _Db.BlockTableRecord;
                if (!(btr.IsFromExternalReference))
                {
                    foreach (_Db.ObjectId bid in btr)
                    {
                        _Db.Entity currentEntity = _c.trans.GetObject(bid, _Db.OpenMode.ForWrite, false) as _Db.Entity;

                        if (currentEntity == null)
                        {
                            continue;
                        }

                        if (currentEntity is _Db.RotatedDimension)
                        {
                            _Db.RotatedDimension dim = currentEntity as _Db.RotatedDimension;
                            dims.Add(dim);
                        }
                    }
                }
            }

            return(dims);
        }
コード例 #4
0
        public void renameBlockInside(string find, string replace)
        {
            foreach (_Db.ObjectId btrId in _c.blockTable)
            {
                _Db.BlockTableRecord btr = _c.trans.GetObject(btrId, _Db.OpenMode.ForWrite) as _Db.BlockTableRecord;

                foreach (_Db.ObjectId bid in btr)
                {
                    _Db.Entity currentEntity = _c.trans.GetObject(bid, _Db.OpenMode.ForWrite) as _Db.Entity;

                    if (currentEntity == null)
                    {
                        continue;
                    }
                    if (currentEntity is _Db.MText)
                    {
                        _Db.MText txt = currentEntity as _Db.MText;
                        txt.Contents = txt.Contents.Replace(find, replace);
                        txt.DowngradeOpen();
                    }
                    if (currentEntity is _Db.DBText)
                    {
                        _Db.DBText txt = currentEntity as _Db.DBText;
                        txt.TextString = txt.TextString.Replace(find, replace);
                    }
                }
            }
        }
コード例 #5
0
        private static bool Correction(_AcDb.Entity ent, string suffix, bool isContinuous)
        {
            if (ent.Layer.EndsWith(suffix, StringComparison.OrdinalIgnoreCase))
            {
                return(false);                                                                // already handled
            }
            var ltr = (_AcDb.LayerTableRecord)_Tr.GetObject(ent.LayerId, _AcDb.OpenMode.ForRead);
            var li  = new LayerInfo(ltr, _Tr);

            if (isContinuous)
            {
                li.NewLineType = "Continuous";
            }
            li.NewLayer = ent.Layer + suffix;
            li.CreateNewLayer();
            li.UnlockOldLayer();
            ent.UpgradeOpen();
            ent.Layer = li.NewLayer;



            //const string prefix = "Autodesk.AutoCAD.DatabaseServices.";
            //string typeString = ent.GetType().ToString();
            //if (typeString.Contains(prefix)) typeString = typeString.Substring(prefix.Length);
            //log.Info("\nEntity " + ent.ObjectId.ToString() + " of type " + typeString + " found on layer " +
            //                    ent.Layer + " with colour " + ent.Color.ToString());



            return(true);
        }
コード例 #6
0
        private void getAllDims()
        {
            foreach (_Db.ObjectId btrId in _c.blockTable)
            {
                _Db.BlockTableRecord btr = _c.trans.GetObject(btrId, _Db.OpenMode.ForWrite) as _Db.BlockTableRecord;

                if (!(btr.IsFromExternalReference))
                {
                    foreach (_Db.ObjectId bid in btr)
                    {
                        _Db.Entity currentEntity = _c.trans.GetObject(bid, _Db.OpenMode.ForWrite, false) as _Db.Entity;

                        if (currentEntity == null)
                        {
                            continue;
                        }

                        if (currentEntity is _Db.Dimension)
                        {
                            _Db.Dimension dim = currentEntity as _Db.Dimension;
                            dims[dim] = btr;
                        }
                    }
                }
            }
        }
コード例 #7
0
 private static void GetAllFgsAbzsAndRbs(string rbName, string fgLayer, string afLayer, _AcDb.Database db, _AcDb.Transaction tr, List <_AcDb.Entity> fgs, List <_AcDb.Entity> azf, List <_AcDb.Entity> rbs)
 {
     _AcDb.BlockTable       bt  = (_AcDb.BlockTable)tr.GetObject(db.BlockTableId, _AcDb.OpenMode.ForRead);
     _AcDb.BlockTableRecord btr = (_AcDb.BlockTableRecord)tr.GetObject(bt[_AcDb.BlockTableRecord.ModelSpace], _AcDb.OpenMode.ForRead);
     foreach (_AcDb.ObjectId objId in btr)
     {
         _AcDb.Entity ent  = (_AcDb.Entity)tr.GetObject(objId, _AcDb.OpenMode.ForRead);
         var          poly = ent as _AcDb.Polyline;
         if (poly != null)
         {
             if (string.Compare(poly.Layer, fgLayer, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 fgs.Add(ent);
             }
             else if (string.Compare(poly.Layer, afLayer, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 azf.Add(ent);
             }
         }
         else
         {
             var block = ent as _AcDb.BlockReference;
             if (block != null)
             {
                 if (string.Compare(block.Name, rbName, StringComparison.OrdinalIgnoreCase) == 0)
                 {
                     rbs.Add(ent);
                 }
             }
         }
     }
 }
コード例 #8
0
        private void SetColor(Teigha.DatabaseServices.Entity entity, Color color)
        {
            var tempColor = entity.Color;

            tempColor.Dispose();
            entity.Color = Teigha.Colors.Color.FromColor(color);
        }
コード例 #9
0
        //private static bool RecAddRbToFg(_AcDb.Entity rb, _AcDb.Entity fg, Dictionary<_AcDb.Entity, FgRbStructure> fgRbStructs)
        //{
        //    var blockRef = rb as _AcDb.BlockReference;
        //    if (IsPosInFg(blockRef.Position, fg))
        //    {
        //        foreach (var inner in )
        //    }
        //}

        private static bool OverlapExtents(_AcDb.Entity ent1, _AcDb.Entity ent2)
        {
            var x1Min = ent1.GeometricExtents.MinPoint.X;
            var x1Max = ent1.GeometricExtents.MaxPoint.X;
            var y1Min = ent1.GeometricExtents.MinPoint.Y;
            var y1Max = ent1.GeometricExtents.MaxPoint.Y;

            var x2Min = ent2.GeometricExtents.MinPoint.X;
            var x2Max = ent2.GeometricExtents.MaxPoint.X;
            var y2Min = ent2.GeometricExtents.MinPoint.Y;
            var y2Max = ent2.GeometricExtents.MaxPoint.Y;

            var xOverlap = GetOverlap(x1Min, x1Max, x2Min, x2Max);

            if (xOverlap <= 0.0)
            {
                return(false);
            }
            var yOverlap = GetOverlap(y1Min, y1Max, y2Min, y2Max);

            if (yOverlap <= 0.0)
            {
                return(false);
            }

            return(true);
        }
コード例 #10
0
ファイル: ServiceCAD .cs プロジェクト: ArtemLoban/LoSa.Land
        public static void SelectObjects(AcDb.ObjectIdCollection objectIds)
        {
            using (AcDb.Transaction tr = db.TransactionManager.StartTransaction())
            {
                AcEd.PromptSelectionResult psr = ed.GetSelection();
                if (psr.Status == AcEd.PromptStatus.OK)
                {
                    AcEd.SelectionSet SSet = psr.Value;
                    foreach (AcEd.SelectedObject SObj in SSet)
                    {
                        if (SObj != null)
                        {
                            AcDb.Entity entityObject = tr.GetObject(SObj.ObjectId, AcDb.OpenMode.ForWrite) as AcDb.Entity;

                            if (entityObject != null)
                            {
                                foreach (AcDb.ObjectId idObj in objectIds)
                                {
                                    if (idObj.Equals(entityObject.ObjectId))
                                    {
                                        entityObject.Highlight();
                                    }
                                }
                            }
                        }
                    }
                    // Save the new object to the database
                    tr.Commit();
                }
            }
        }
コード例 #11
0
 private static bool IsActuallyContintuous(_AcDb.Entity ent, LayerInfo li)
 {
     if (string.Compare(ent.Linetype, "ByBlock", true) == 0)
     {
         return(true);
     }
     if (string.Compare(ent.Linetype, "ByLayer", true) == 0)
     {
         if (IsContinuous(li.LineType))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     if (IsContinuous(ent.Linetype))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #12
0
        private static bool CorrectionRest(_AcDb.Entity ent)
        {
            string suffix = "";

            var ltr = (_AcDb.LayerTableRecord)_Tr.GetObject(ent.LayerId, _AcDb.OpenMode.ForRead);
            var li  = new LayerInfo(ltr, _Tr);

            if (IsActuallyContintuous(ent, li))
            {
                suffix         = "_L";
                li.NewLineType = "Continuous";
            }
            else
            {
                suffix         = "_V";
                li.NewLineType = "Verdeckt";
            }

            if (ent.Layer.EndsWith(suffix, StringComparison.OrdinalIgnoreCase))
            {
                return(false);                                                                // already handled
            }
            li.NewLayer = ent.Layer + suffix;
            li.CreateNewLayer();

            li.UnlockOldLayer();
            ent.UpgradeOpen();
            ent.Layer      = li.NewLayer;
            ent.LinetypeId = LayerInfo.GetLinetypeFromName("ByLayer", _Tr, _Db);

            return(true);
        }
コード例 #13
0
 protected void AssignTraits(_OdDb.Entity entity)
 {
     entity.UpgradeOpen();
     entity.Layer    = _layer;
     entity.Color    = _color;
     entity.Material = _material;
     entity.DowngradeOpen();
 }
コード例 #14
0
 private static _AcDb.Extents3d GetExtents(_AcDb.TransactionManager tm, _AcDb.ObjectId oid)
 {
     using (_AcDb.DBObject dbobj = tm.GetObject(oid, _AcDb.OpenMode.ForRead, false))
     {
         _AcDb.Entity ent = dbobj as _AcDb.Entity;
         return(ent.GeometricExtents);
     }
 }
コード例 #15
0
ファイル: Engine.cs プロジェクト: presscad/Plan2ExtAcad2013
        private static void CheckSetLayer(Dictionary <string, string> substDict, _AcDb.Entity entity)
        {
            string newLayer;

            if (substDict.TryGetValue(entity.Layer.ToUpperInvariant(), out newLayer))
            {
                entity.Layer = newLayer;
            }
        }
コード例 #16
0
        private List <_Db.MText> getAllText(string layer)
        {
            List <_Db.MText> txt = new List <_Db.MText>();

            _Db.BlockTableRecord btr = _c.trans.GetObject(_c.modelSpace.Id, _Db.OpenMode.ForWrite) as _Db.BlockTableRecord;

            foreach (_Db.ObjectId id in btr)
            {
                _Db.Entity currentEntity = _c.trans.GetObject(id, _Db.OpenMode.ForWrite, false) as _Db.Entity;

                if (currentEntity != null)
                {
                    if (currentEntity is _Db.MText)
                    {
                        _Db.MText br = currentEntity as _Db.MText;
                        if (br.Layer == layer)
                        {
                            txt.Add(br);
                        }
                    }

                    if (currentEntity is _Db.DBText)
                    {
                        _Db.DBText br = currentEntity as _Db.DBText;
                        if (br.Layer == layer)
                        {
                            _Db.MText myMtext = new _Db.MText();
                            myMtext.Contents = br.TextString;
                            myMtext.Location = br.Position;
                            txt.Add(myMtext);
                        }
                    }

                    if (currentEntity is _Db.MLeader)
                    {
                        _Db.MLeader br = currentEntity as _Db.MLeader;
                        if (br.Layer == layer)
                        {
                            if (br.ContentType == _Db.ContentType.MTextContent)
                            {
                                _Db.MText leaderText = br.MText;
                                txt.Add(leaderText);
                            }
                        }
                    }
                }
            }

            return(txt);
        }
コード例 #17
0
ファイル: Commands.cs プロジェクト: presscad/Plan2ExtAcad2013
        public static bool Plan2RemoveHyperLinks(_AcDb.ResultBuffer rb)
        {
            var doc = _AcAp.Application.DocumentManager.MdiActiveDocument;

            _AcDb.Database           db      = _AcAp.Application.DocumentManager.MdiActiveDocument.Database;
            _AcDb.TransactionManager dbTrans = db.TransactionManager;
            _AcEd.Editor             ed      = doc.Editor;

            try
            {
                if (rb == null)
                {
                    ed.WriteMessage("Aufruf: (Plan2RemoveHyperLinks el)");
                    return(false);
                }

                var typedValues = rb.AsArray();
                if (typedValues == null || typedValues.Length != 1)
                {
                    ed.WriteMessage("Aufruf: (Plan2RemoveHyperLinks el)");
                    return(false);
                }

                if (typedValues[0].TypeCode != (short)_AcBrx.LispDataType.ObjectId)
                {
                    ed.WriteMessage("Aufruf: (Plan2RemoveHyperLinks el)");
                    return(false);
                }

                using (_AcDb.Transaction trans = dbTrans.StartTransaction())
                {
                    _AcDb.Entity ent = trans.GetObject((_AcDb.ObjectId)typedValues[0].Value, _AcDb.OpenMode.ForWrite) as _AcDb.Entity;
                    if (ent != null)
                    {
                        //ent.Hyperlinks.Clear(); // -> crashes
                        while (ent.Hyperlinks.Count > 0)
                        {
                            ent.Hyperlinks.RemoveAt(0);
                        }
                    }
                    trans.Commit();
                }
                return(true);
            }
            catch (Exception ex)
            {
                ed.WriteMessage("Aufruf: (Plan2RemoveHyperLinks el)");
            }
            return(false);
        }
コード例 #18
0
ファイル: ServiceCAD .cs プロジェクト: ArtemLoban/LoSa.Land
 public static AcDb.ObjectId InsertObject(AcDb.Entity entityObject)
 {
     AcDb.ObjectId objectId;
     using (AcDb.Transaction tr = db.TransactionManager.StartTransaction())
     {
         AcDb.BlockTableRecord btr = (AcDb.BlockTableRecord)tr.GetObject(db.CurrentSpaceId, AcDb.OpenMode.ForWrite);
         btr.AppendEntity(entityObject);
         tr.AddNewlyCreatedDBObject(entityObject, true);
         objectId = entityObject.ObjectId;
         btr.Dispose();
         tr.Commit();
     }
     return(objectId);
 }
コード例 #19
0
        private List <_Db.MText> getSelectedText()
        {
            List <_Db.MText> txt = new List <_Db.MText>();

            _Ed.PromptSelectionResult selection = _c.ed.GetSelection();
            if (selection.Status == _Ed.PromptStatus.OK)
            {
                _Db.ObjectId[] objIds = selection.Value.GetObjectIds();

                foreach (_Db.ObjectId objId in objIds)
                {
                    _Db.Entity currentEntity = _c.trans.GetObject(objId, _Db.OpenMode.ForRead) as _Db.Entity;

                    if (currentEntity == null)
                    {
                        continue;
                    }

                    if (currentEntity is _Db.MText)
                    {
                        _Db.MText br = currentEntity as _Db.MText;
                        txt.Add(br);
                    }
                    else if (currentEntity is _Db.DBText)
                    {
                        _Db.DBText br      = currentEntity as _Db.DBText;
                        _Db.MText  myMtext = new _Db.MText();

                        myMtext.Contents = br.TextString;
                        myMtext.Layer    = br.Layer;
                        myMtext.Location = br.Position;
                        txt.Add(myMtext);
                    }
                    else if (currentEntity is _Db.MLeader)
                    {
                        _Db.MLeader br = currentEntity as _Db.MLeader;

                        if (br.ContentType == _Db.ContentType.MTextContent)
                        {
                            _Db.MText leaderText = br.MText;
                            leaderText.Layer = br.Layer;
                            txt.Add(leaderText);
                        }
                    }
                }
            }

            return(txt);
        }
コード例 #20
0
ファイル: Tabler_Inputs.cs プロジェクト: 15831944/habile
        private List <_Db.MText> getAllText(string layer)
        {
            List <_Db.MText> txts = new List <_Db.MText>();

            foreach (_Db.ObjectId id in _c.modelSpace)
            {
                _Db.Entity currentEntity = _c.trans.GetObject(id, _Db.OpenMode.ForWrite, false) as _Db.Entity;

                if (currentEntity == null)
                {
                    continue;
                }

                if (currentEntity is _Db.MText)
                {
                    _Db.MText mtxt = currentEntity as _Db.MText;

                    if (mtxt.Layer == layer)
                    {
                        txts.Add(mtxt);
                    }
                }
                else if (currentEntity is _Db.DBText)
                {
                    _Db.DBText dbt = currentEntity as _Db.DBText;
                    if (dbt.Layer == layer)
                    {
                        _Db.MText mtxt = new _Db.MText();
                        mtxt.Contents = dbt.TextString;
                        mtxt.Location = dbt.Position;
                        txts.Add(mtxt);
                    }
                }
                else if (currentEntity is _Db.MLeader)
                {
                    _Db.MLeader ml = currentEntity as _Db.MLeader;
                    if (ml.Layer == layer)
                    {
                        if (ml.ContentType == _Db.ContentType.MTextContent)
                        {
                            _Db.MText mtxt = ml.MText;
                            txts.Add(mtxt);
                        }
                    }
                }
            }

            return(txts);
        }
コード例 #21
0
        // Entity extension
        public static _AcGe.Point3d?GetCenter(this _AcDb.Entity ent)
        {
            var cp = new _AcGe.Point3d?();

            if (ent == null)
            {
                return(cp);
            }
            if (!ent.Bounds.HasValue)
            {
                return(cp);
            }

            return(GetCenter(ent.Bounds.Value.MinPoint, ent.Bounds.Value.MaxPoint));
        }
コード例 #22
0
        private void ExplodeBlocks(_AcDb.Database db, List <_AcDb.ObjectId> allXrefsInMs, List <_AcDb.ObjectId> newlyCreatedObjects, bool deleteRef, bool deleteBtr)
        {
            log.Debug("ExplodeXRefs");
            using (_AcDb.Transaction tr = _TransMan.StartTransaction())
            {
                _AcDb.BlockTable bt = (_AcDb.BlockTable)tr.GetObject(db.BlockTableId, _AcDb.OpenMode.ForRead);

                _AcDb.BlockTableRecord btr = (_AcDb.BlockTableRecord)tr.GetObject(_AcDb.SymbolUtilityServices.GetBlockModelSpaceId(db), _AcDb.OpenMode.ForWrite);


                foreach (var oid in allXrefsInMs)
                {
                    _AcDb.DBObjectCollection objs  = new _AcDb.DBObjectCollection();
                    _AcDb.BlockReference     block = (_AcDb.BlockReference)tr.GetObject(oid, _AcDb.OpenMode.ForRead);
                    log.DebugFormat(CultureInfo.CurrentCulture, "Explode von Block '{0}'.", block.Name);
                    block.Explode(objs);
                    log.DebugFormat(CultureInfo.CurrentCulture, "Block enthält {0} Entities.", objs.Count);
                    _AcDb.ObjectId blockRefTableId = block.BlockTableRecord;


                    foreach (_AcDb.DBObject obj in objs)
                    {
                        _AcDb.Entity ent = (_AcDb.Entity)obj;
                        btr.AppendEntity(ent);
                        tr.AddNewlyCreatedDBObject(ent, true);

                        newlyCreatedObjects.Add(ent.ObjectId);
                    }

                    if (deleteRef)
                    {
                        log.DebugFormat(CultureInfo.CurrentCulture, "Lösche Block '{0}'.", block.Name);
                        block.UpgradeOpen();
                        block.Erase();
                    }

                    if (deleteBtr)
                    {
                        log.DebugFormat("DeleteBtr");
                        // funkt nicht -> xref würde gelöscht
                        var bd = (_AcDb.BlockTableRecord)tr.GetObject(blockRefTableId, _AcDb.OpenMode.ForWrite);
                        bd.Erase();
                        log.DebugFormat("Endof DeleteBtr");
                    }
                }
                tr.Commit();
            }
        }
コード例 #23
0
ファイル: Commands.cs プロジェクト: presscad/Plan2ExtAcad2013
        /// <summary>
        /// Öffnen einer Dwg ohne Editor
        /// </summary>
        //[_AcTrx.CommandMethod("Plan2TestSideDb")]
        static public void Plan2TestSideDb()
        {
            _AcAp.Document doc = _AcAp.Application.DocumentManager.MdiActiveDocument;
            _AcEd.Editor   ed  = doc.Editor;
            // Ask the user to select a file
            _AcEd.PromptResult res = ed.GetString("\nEnter the path of a DWG or DXF file: ");
            if (res.Status == _AcEd.PromptStatus.OK)
            {
                // Create a database and try to load the file
                _AcDb.Database db = new _AcDb.Database(false, true);
                using (db)
                {
                    try
                    {
                        db.ReadDwgFile(res.StringResult, System.IO.FileShare.Read, false, "");
                    }
                    catch (System.Exception)
                    {
                        ed.WriteMessage("\nUnable to read drawing file.");
                        return;
                    }

                    _AcDb.Transaction tr = db.TransactionManager.StartTransaction();
                    using (tr)
                    {
                        // Open the blocktable, get the modelspace
                        _AcDb.BlockTable       bt  = (_AcDb.BlockTable)tr.GetObject(db.BlockTableId, _AcDb.OpenMode.ForRead);
                        _AcDb.BlockTableRecord btr = (_AcDb.BlockTableRecord)tr.GetObject(bt[_AcDb.BlockTableRecord.ModelSpace], _AcDb.OpenMode.ForRead);

                        // Iterate through it, dumping objects
                        foreach (_AcDb.ObjectId objId in btr)
                        {
                            _AcDb.Entity ent = (_AcDb.Entity)tr.GetObject(objId, _AcDb.OpenMode.ForRead);

                            // Let's get rid of the standard namespace
                            const string prefix     = "Autodesk.AutoCAD.DatabaseServices.";
                            string       typeString = ent.GetType().ToString();
                            if (typeString.Contains(prefix))
                            {
                                typeString = typeString.Substring(prefix.Length);
                            }
                            ed.WriteMessage("\nEntity " + ent.ObjectId.ToString() + " of type " + typeString + " found on layer " +
                                            ent.Layer + " with colour " + ent.Color.ToString());
                        }
                    }
                }
            }
        }
コード例 #24
0
        private static bool OverlapExtents(_AcGe.Point3d point3d, _AcDb.Entity ent1)
        {
            var x1Min = ent1.GeometricExtents.MinPoint.X;
            var x1Max = ent1.GeometricExtents.MaxPoint.X;
            var y1Min = ent1.GeometricExtents.MinPoint.Y;
            var y1Max = ent1.GeometricExtents.MaxPoint.Y;

            if (point3d.X > x1Min && point3d.X < x1Max && point3d.Y > y1Min && point3d.Y < y1Max)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #25
0
        private static bool IsPosInFg(_AcGe.Point3d point3d, _AcDb.Entity entity)
        {
            if (!OverlapExtents(point3d, entity))
            {
                return(false);
            }

            if (InPoly(point3d, entity))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #26
0
        private void AddRbToRetCol(List <_AcDb.ObjectId> Ret, _AcDb.TransactionManager tm, _AcDb.ObjectId elFG)
        {
            _AcDb.Extents3d ext    = GetExtents(tm, elFG);
            _AcGe.Point3d   minExt = new _AcGe.Point3d(ext.MinPoint.X - ABSTANDTEXT, ext.MinPoint.Y - ABSTANDTEXT, ext.MinPoint.Z);
            _AcGe.Point3d   maxExt = new _AcGe.Point3d(ext.MaxPoint.X + ABSTANDTEXT, ext.MaxPoint.Y + ABSTANDTEXT, ext.MaxPoint.Z);

            _AcEd.Editor          ed     = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
            _AcEd.SelectionFilter filter = new _AcEd.SelectionFilter(new _AcDb.TypedValue[] {
                new _AcDb.TypedValue((int)_AcDb.DxfCode.Start, "INSERT"),
                new _AcDb.TypedValue((int)_AcDb.DxfCode.BlockName, _RaumblockName)
            });
            _AcEd.PromptSelectionResult res = null;
            res = ed.SelectCrossingWindow(minExt, maxExt, filter);
            if (res.Status != _AcEd.PromptStatus.OK)
            {
                // todo: logging: lot4net?
                return;
            }

#if BRX_APP
            _AcEd.SelectionSet ss = res.Value;
#else
            using (_AcEd.SelectionSet ss = res.Value)
#endif
            {
                _AcDb.ObjectId[] idArray = ss.GetObjectIds();
                for (int i = 0; i < idArray.Length; i++)
                {
                    _AcDb.ObjectId oid = idArray[i];
                    using (_AcDb.DBObject pEntity = tm.GetObject(oid, _AcDb.OpenMode.ForRead, false))
                    {
                        using (_AcDb.Entity entElFG = tm.GetObject(elFG, _AcDb.OpenMode.ForRead, false) as _AcDb.Entity)
                        {
                            if (pEntity is _AcDb.BlockReference)
                            {
                                _AcDb.BlockReference br = pEntity as _AcDb.BlockReference;
                                if (AreaEngine.InPoly(br.Position, entElFG))
                                {
                                    Ret.Add(oid);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #27
0
ファイル: CORNER_command.cs プロジェクト: 15831944/datum
        private List <_Ge.Point3d> getBlockTableRecordPoints(_Db.BlockTableRecord btr)
        {
            List <_Ge.Point3d> points = new List <_Ge.Point3d>();

            if (memory.Keys.Contains(btr))
            {
                return(memory[btr]);
            }

            foreach (_Db.ObjectId bid in btr)
            {
                _Db.Entity         currentEntity = _c.trans.GetObject(bid, _Db.OpenMode.ForWrite, false) as _Db.Entity;
                List <_Ge.Point3d> currentPoints = handle(currentEntity);
                points.AddRange(currentPoints);
            }

            memory[btr] = points;

            return(points);
        }
コード例 #28
0
        private static bool RecAddRbToFg(_AcDb.Entity rb, FgRbStructureInTrans stru, Dictionary <_AcDb.ObjectId, FgRbStructureInTrans> fgRbStructs)
        {
            var blockRef = rb as _AcDb.BlockReference;

            if (IsPosInFg(blockRef.Position, stru.FlaechenGrenze))
            {
                foreach (var inner in stru.Inseln)
                {
                    if (IsPosInFg(blockRef.Position, inner))
                    {
                        var innerStru = fgRbStructs[inner.Id];
                        if (RecAddRbToFg(rb, innerStru, fgRbStructs))
                        {
                            return(true);
                        }
                    }
                }
                stru.Raumbloecke.Add(rb);
                return(true);
            }
            return(false);
        }
コード例 #29
0
        public void renameText(string find, string replace)
        {
            foreach (_Db.ObjectId id in _c.modelSpace)
            {
                _Db.Entity currentEntity = _c.trans.GetObject(id, _Db.OpenMode.ForWrite, false) as _Db.Entity;

                if (currentEntity == null)
                {
                    continue;
                }
                if (currentEntity is _Db.MText)
                {
                    _Db.MText txt = currentEntity as _Db.MText;
                    txt.Contents = txt.Contents.Replace(find, replace);
                }
                if (currentEntity is _Db.DBText)
                {
                    _Db.DBText txt = currentEntity as _Db.DBText;
                    txt.TextString = txt.TextString.Replace(find, replace);
                }
            }
        }
コード例 #30
0
        static public GeometryBase ToRhino(this _OdDb.Entity ent)
        {
            if (ent is _OdDb.Curve curve)
            {
                var geometry = curve.ToRhino();
                if (geometry != null)
                {
                    return(geometry);
                }
            }
            var aObj = new _OdDb.DBObjectCollection()
            {
                ent
            };
            string tmpPath = Path.Combine(Path.GetTempPath(), "BricsCAD", "torhino.3dm");

            if (_OdRx.ErrorStatus.OK != Bricscad.Rhino.RhinoUtilityFunctions.ExportRhinoFile(aObj, tmpPath))
            {
                return(null);
            }
            aObj.Dispose();
            return(ExtractGeometryFromFile(tmpPath));
        }