当前位置: 首页>>代码示例>>C#>>正文


C# ObjectId.GetObject方法代码示例

本文整理汇总了C#中ObjectId.GetObject方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectId.GetObject方法的具体用法?C# ObjectId.GetObject怎么用?C# ObjectId.GetObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectId的用法示例。


在下文中一共展示了ObjectId.GetObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddAttrToBlockRef

        protected AttributeReference AddAttrToBlockRef(BlockReference blRef, ObjectId idAttrDef, string textString)
        {
            using (var attrDef = idAttrDef.GetObject(OpenMode.ForRead, false, true) as AttributeDefinition)
             {
            var attrRef = new AttributeReference();
            attrRef.SetAttributeFromBlock(attrDef, blRef.BlockTransform);
            attrRef.TextString = textString;

            blRef.AttributeCollection.AppendAttribute(attrRef);
            t.AddNewlyCreatedDBObject(attrRef, true);
            return attrRef;
             }
        }
开发者ID:vildar82,项目名称:PanelColorAlbum,代码行数:13,代码来源:DimensionAbstract.cs

示例2: convertText

        private Extents3d convertText(ObjectId idDbText, int angle, Point3d pos, bool isMarkOrPaint)
        {
            Extents3d resVal = new Extents3d();
            if (idDbText.IsNull)
            {
                return resVal;
            }
            using (var text = idDbText.GetObject(OpenMode.ForWrite, false, true) as DBText)
            {
                text.TextStyleId = idDbText.Database.GetTextStylePIK();

                double lenMax = panelBtr.HeightByTile;

                // Аннотативность???

                if (panelBtr.HeightByTile >= 2000)
                {
                    text.Position = pos;
                    double angleRadian = Math.PI * angle / 180.0;
                    text.Rotation = angleRadian;
                }
                else
                {
                    lenMax = panelBtr.ExtentsNoEnd.MaxPoint.X - panelBtr.ExtentsNoEnd.MinPoint.X;
                    // Небольшая корректировка положения текста
                    if (isMarkOrPaint)
                    {
                        text.Position = new Point3d(10, 315,0);
                    }
                    else
                    {
                        text.Position = new Point3d(10, 65, 0);
                    }
                }

                // Проверка длины текста - если не вписывается в размер панели то сжатие
                ControlTextLength(text, lenMax);

                resVal = text.GeometricExtents;
            }
            return resVal;
        }
开发者ID:vildar82,项目名称:PanelColorAlbum,代码行数:42,代码来源:ConvertCaption.cs

示例3: AddData

 /// <summary>
 /// Agrega información a un Xrecord
 /// </summary>
 /// <param name="recId">El id del Xrecord.</param>
 /// <param name="data">La información a guardar</param>
 public void AddData(ObjectId recId, params String[] data)
 {
     Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
     using (Transaction tr = db.TransactionManager.StartTransaction())
     {
         try
         {
             Xrecord oldX = (Xrecord)recId.GetObject(OpenMode.ForWrite);
             List<TypedValue> typedValueData = new List<TypedValue>();
             for (int i = 0; i < data.Length; i++)
                 typedValueData.Add(new TypedValue((int)DxfCode.Text, data[i]));
             oldX.Data = new ResultBuffer(typedValueData.ToArray());
             tr.Commit();
         }
         catch (System.Exception exc)
         {
             ed.WriteMessage(exc.Message);
             tr.Abort();
         }
     }
 }
开发者ID:JOndarza,项目名称:CAD,代码行数:26,代码来源:DManager.cs

示例4: exploreDictionary

 private static void exploreDictionary(ObjectId idDict, ref StringBuilder sbInfo, string tab = "    ")
 {
     var entry = idDict.GetObject(OpenMode.ForRead);
     if (entry is DBDictionary)
     {
         var dict = entry as DBDictionary;
         foreach (var item in dict)
         {
             sbInfo.AppendLine($"{tab}{item.Key}");
             exploreDictionary(item.Value, ref sbInfo, tab+"    ");
         }
     }
     else if (entry is Xrecord)
     {
         var xrec = entry as Xrecord;
         foreach (var item in xrec)
         {
             sbInfo.AppendLine($"{tab}    {getTypeCodeName(item.TypeCode)} = {item.Value}");
         }
     }
 }
开发者ID:vildar82,项目名称:AcadLib,代码行数:21,代码来源:XDataView.cs

示例5: Extract

 /// <summary>
 /// Obtiene información de un Xrecord
 /// </summary>
 /// <param name="xId">El id de un Xrecord</param>
 /// <returns>La información del registro</returns>
 public string[] Extract(ObjectId xId)
 {
     Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
     List<string> values = new List<string>();
     using (Transaction tr = db.TransactionManager.StartTransaction())
     {
         try
         {
             Xrecord xRec = (Xrecord)xId.GetObject(OpenMode.ForWrite);
             TypedValue[] tps = xRec.Data.AsArray();
             foreach (TypedValue tp in tps)
                 values.Add((string)tp.Value);
         }
         catch (System.Exception exc)
         {
             ed.WriteMessage(exc.Message);
             tr.Abort();
         }
     }
     return values.ToArray();
 }
开发者ID:JOndarza,项目名称:CAD,代码行数:26,代码来源:DManager.cs

示例6: AddXRecord

 /// <summary>
 /// Agrega un xrecord en un diccionario
 /// </summary>
 /// <param name="xName">El nombre del registro</param>
 /// <param name="dicId">El id del diccionario.</param>
 /// <returns>El object id del nuevo registro</returns>
 public ObjectId AddXRecord(ObjectId dicId, String xName)
 {
     Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
     ObjectId id = new ObjectId();
     using (Transaction tr = db.TransactionManager.StartTransaction())
     {
         try
         {
             DBDictionary dic = (DBDictionary)dicId.GetObject(OpenMode.ForWrite);
             Xrecord x = new Xrecord();
             dic.SetAt(xName, x);
             tr.AddNewlyCreatedDBObject(x, true);
             id = x.ObjectId;
             tr.Commit();
         }
         catch (System.Exception exc)
         {
             ed.WriteMessage(exc.Message);
             tr.Abort();
         }
     }
     return id;
 }
开发者ID:JOndarza,项目名称:CAD,代码行数:29,代码来源:DManager.cs

示例7: ChangeBasePointInRedefineBase

        public void ChangeBasePointInRedefineBase(Database dbExt, ObjectId idBtr)
        {
            var btr = idBtr.GetObject( OpenMode.ForRead) as BlockTableRecord;
            var idsBlRefs =btr.GetBlockReferenceIds(true, false);
            foreach (ObjectId idBlRef in idsBlRefs)
            {
                var blRef = idBlRef.GetObject( OpenMode.ForWrite) as BlockReference;
                if (blRef == null) continue;

                blRef.TransformBy(MatChangeBasePoint);
            }
            if (btr.IsDynamicBlock && !btr.IsAnonymous)
            {
                var idsBtrAnonym =btr.GetAnonymousBlockIds();
                foreach (ObjectId idBtrAnonym in idsBtrAnonym)
                {
                    ChangeBasePointInRedefineBase(dbExt, idBtrAnonym);
                }
            }
        }
开发者ID:vildar82,项目名称:RedefineBlockInFolder,代码行数:20,代码来源:RedefineBlock.cs

示例8: replaceText

 private ObjectId replaceText(ObjectId idBdText, BlockTableRecord btr)
 {
     using (var text = idBdText.GetObject(OpenMode.ForWrite, false, true) as DBText)
     {
         using (var copyText = text.Clone() as DBText)
         {
             text.Erase();
             return btr.AppendEntity(copyText);
         }
     }
 }
开发者ID:vildar82,项目名称:PanelColorAlbum,代码行数:11,代码来源:ConvertCaption.cs

示例9: GetInsertionPoint

        public Point3d GetInsertionPoint(ObjectId BRid, string attributeName)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            Point3d insertionPoint = new Point3d();

            using (Transaction tr = doc.TransactionManager.StartTransaction())
            {
                    BlockReference br = BRid.GetObject(OpenMode.ForRead) as BlockReference;

                    if (br != null)
                    {
                        AttributeCollection arColl = br.AttributeCollection;

                        foreach (ObjectId arID in arColl)
                        {
                            AttributeReference ar = tr.GetObject(arID, OpenMode.ForRead) as AttributeReference;

                            if (ar != null)
                            {
                                if (ar.Tag == attributeName)
                                {
                                    insertionPoint = ar.Position;
                                }

                            }
                        }
                    }
                }
            return insertionPoint;
        }
开发者ID:BKSpurgeon,项目名称:BensAcadGenUtils,代码行数:32,代码来源:BlockUtility.cs

示例10: Transform

        public static void Transform(Matrix3d matrix, ObjectId entId)
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Database dwg = Application.DocumentManager.MdiActiveDocument.Database;
            using (Transaction tr = dwg.TransactionManager.StartTransaction())
            {
                try
                {
                    Entity ent = entId.GetObject(OpenMode.ForWrite) as Entity;

                    ent.TransformBy(matrix);
                    tr.Commit();
                }
                catch (Exception exc)
                {
                    ed.WriteMessage(exc.Message);
                    tr.Abort();
                }
            }
        }
开发者ID:JOndarza,项目名称:CAD,代码行数:20,代码来源:DBMan.cs

示例11: OpenEnity

 public static Entity OpenEnity(ObjectId id)
 {
     Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
     Database dwg = Application.DocumentManager.MdiActiveDocument.Database;
     //La variable de tipo entidad
     Entity ent = null;
     using (Transaction tr = dwg.TransactionManager.StartTransaction())
     {
         try
         {
             //Abrir entidad
             ent = id.GetObject(OpenMode.ForRead) as Entity;
             tr.Commit();
         }
         catch (Exception exc)
         {
             ed.WriteMessage(exc.Message);
             tr.Abort();
         }
     }
     //el valor de retorno
     return ent;
 }
开发者ID:JOndarza,项目名称:CAD,代码行数:23,代码来源:DBMan.cs

示例12: eraseEntInBlock

 private void eraseEntInBlock(ObjectId idBtr)
 {
     using (var btr = idBtr.GetObject(OpenMode.ForWrite) as BlockTableRecord)
     {
         foreach (ObjectId idEnt in btr)
         {
             using (var ent = idEnt.GetObject(OpenMode.ForWrite, false, true) as Entity)
             {
                 ent.Erase();
             }
         }
     }
 }
开发者ID:vildar82,项目名称:PanelColorAlbum,代码行数:13,代码来源:ConvertEndsFacade.cs

示例13: GetLine

        public static Line GetLine(ObjectId lineID)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            Line ln;

            // check the current value of the br and see if it is null - it should not be

            using (Transaction tr = doc.TransactionManager.StartTransaction())
            {
                ln = lineID.GetObject(OpenMode.ForRead) as Line;

                if (ln != null)
                {
                    return ln;
                }
                // throws an exception if the point does not have any value
                else
                {
                    throw new Autodesk.AutoCAD.Runtime.Exception(ErrorStatus.NullObjectId, "The block reference returned is null - probably because the objectID you passed into the GetBlockReference method was not a blockReference.");
                }

            }

            return ln;
        }
开发者ID:BKSpurgeon,项目名称:BensAcadGenUtils,代码行数:28,代码来源:BlockUtility.cs

示例14: GetInsertionPointOfBlockReference

        ///////////the below has proven obsolete
        //////public static BlockReference GetBlockReference(ObjectId BRid)
        //////{
        //////    Document doc = Application.DocumentManager.MdiActiveDocument;
        //////    Editor ed = doc.Editor;
        //////    Database db = doc.Database;
        //////    BlockReference br;
        //////    // check the current value of the br and see if it is null - it should not be
        //////    using (Transaction tr = doc.TransactionManager.StartTransaction())
        //////    {
        //////        br = BRid.GetObject(OpenMode.ForRead) as BlockReference;
        //////        if (br != null)
        //////        {
        //////            return br;
        //////        }
        //////        // throws an exception if the point does not have any value
        //////        else
        //////        {
        //////            throw new Autodesk.AutoCAD.Runtime.Exception(ErrorStatus.NullObjectId, "The block reference returned is null - probably because the objectID you passed into the GetBlockReference method was not a blockReference.");
        //////        }
        //////    }
        //////    return br;
        //////}
        public static Point3d GetInsertionPointOfBlockReference(ObjectId BRid)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            Point3d insertionPoint = new Point3d();

            using (Transaction tr = doc.TransactionManager.StartTransaction())
            {
                BlockReference br = BRid.GetObject(OpenMode.ForRead) as BlockReference;

                if (br != null)
                {
                    insertionPoint = br.Position;
                }
            }

            // throws an exception if the point does not have any value
            if (insertionPoint.IsEqualTo(new Point3d()))
            {
                throw new Autodesk.AutoCAD.Runtime.Exception(ErrorStatus.InvalidDxf3dPoint, "The block reference does not have an insertion point. Probably the objectID you passed into the GetInsertionPointOfBlockReference method is not in fact a blockReference id.");
            }

            return insertionPoint;
        }
开发者ID:BKSpurgeon,项目名称:BensAcadGenUtils,代码行数:48,代码来源:BlockUtility.cs

示例15: Get

 /// <summary>
 /// Obtiene un diccionario o un registro, contenido en otro diccionario.
 /// Si el id es de una entidad, el diccionario abrir será el de extensión
 /// </summary>
 /// <param name="dName">El nombre del diccionario</param>
 /// <param name="objId">El id del objeto</param>
 /// <returns>El object id del diccionario seleccionado</returns>
 public ObjectId Get(ObjectId objId, String dName)
 {
     Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
     ObjectId id = new ObjectId();
     using (Transaction tr = db.TransactionManager.StartTransaction())
     {
         try
         {
             DBObject obj = objId.GetObject(OpenMode.ForRead);
             DBDictionary dic = null;
             if (obj is Entity && (obj as Entity).ExtensionDictionary.IsValid)
                 dic = (DBDictionary)(obj as Entity).ExtensionDictionary.GetObject(OpenMode.ForWrite);
             else if (obj is DBDictionary)
                 dic = (DBDictionary)objId.GetObject(OpenMode.ForRead);
             if (dic != null)
                 id = dic.GetAt(dName);
             tr.Commit();
         }
         catch (System.Exception exc)
         {
             ed.WriteMessage(exc.Message);
             tr.Abort();
         }
     }
     return id;
 }
开发者ID:JOndarza,项目名称:CAD,代码行数:33,代码来源:DManager.cs


注:本文中的ObjectId.GetObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。