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


C# Transaction.GetObject方法代码示例

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


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

示例1: Create

        public static DBObject Create(this Grevit.Types.DrawingPoint a, Transaction tr)
        {
            try
            {
                LayerTable lt = (LayerTable)tr.GetObject(Command.Database.LayerTableId, OpenMode.ForRead);
                Point3d pp = a.point.ToPoint3d();
                DBPoint ppp = new DBPoint(pp);
                ppp.SetDatabaseDefaults(Command.Database);

                if (a.TypeOrLayer != "") { if (lt.Has(a.TypeOrLayer)) ppp.LayerId = lt[a.TypeOrLayer]; }
                BlockTable bt = (BlockTable)tr.GetObject(Command.Database.BlockTableId, OpenMode.ForRead);
                BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                ms.AppendEntity(ppp);
                tr.AddNewlyCreatedDBObject(ppp, true);
                return ppp;
            }

            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
            }


            return null;

        }
开发者ID:samuto,项目名称:Grevit,代码行数:25,代码来源:CreateExtension.cs

示例2: InsertBlock

        public Handle InsertBlock(Transaction trans, string blockName, Point3d origin, double scale, double rotationDegrees, string layerName)
        {
            BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
            LayerTable lt = trans.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
            if (!bt.Has(blockName))
            {
                BlockDefinitionCreator bdc = new BlockDefinitionCreator();
                bdc.CreateBlock(blockName);
            }
            if (!lt.Has(layerName))
            {
                throw new ArgumentException("Layer doesn't exists.");
            }

            ObjectId btObjectId = bt[blockName];
            if (btObjectId != ObjectId.Null)
            {
                BlockReference blockRef = new BlockReference(origin, btObjectId);
                blockRef.Rotation = rotationDegrees * Math.PI / 180;
                blockRef.TransformBy(Matrix3d.Scaling(scale, origin));
                blockRef.Layer = layerName;

                BlockTableRecord currentSpaceId = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                currentSpaceId.AppendEntity(blockRef);
                trans.AddNewlyCreatedDBObject(blockRef, true);

                BlockTableRecord btr = trans.GetObject(btObjectId, OpenMode.ForRead) as BlockTableRecord;
                if (btr.HasAttributeDefinitions)
                {
                    foreach (ObjectId atId in btr)
                    {
                        Entity ent = trans.GetObject(atId, OpenMode.ForRead) as Entity;
                        if (ent is AttributeDefinition)
                        {
                            AttributeDefinition atd = ent as AttributeDefinition;
                            AttributeReference atr = new AttributeReference();
                            atr.SetAttributeFromBlock(atd, blockRef.BlockTransform);
                            blockRef.AttributeCollection.AppendAttribute(atr);
                            trans.AddNewlyCreatedDBObject(atr, true);
                        }
                    }
                }
                return blockRef.ObjectId.Handle;
            }
            else
            {
                return new Handle();
            }
        }
开发者ID:anielii,项目名称:Acommands,代码行数:49,代码来源:BlockManager.cs

示例3: GetAttributeReferences

 /// <summary>
 /// Gets the attribute references.
 /// </summary>
 /// <param name="bref">The bref.</param>
 /// <param name="trx">The TRX.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="includingErased">if set to <c>true</c> [including erased].</param>
 /// <param name="openObjectsOnLockedLayers">if set to <c>true</c> [open objects on locked layers].</param>
 /// <returns></returns>
 /// <exception cref="Autodesk.AutoCAD.Runtime.Exception"></exception>
 public static IEnumerable<AttributeReference> GetAttributeReferences(this BlockReference bref, Transaction trx,
     OpenMode mode = OpenMode.ForRead, bool includingErased = false, bool openObjectsOnLockedLayers = false)
 {
     if (trx == null)
     {
         throw new Exception(ErrorStatus.NoActiveTransactions);
     }
     if (includingErased)
     {
         foreach (ObjectId id in bref.AttributeCollection)
         {
             yield return (AttributeReference) trx.GetObject(id, mode, true, openObjectsOnLockedLayers);
         }
     }
     else
     {
         foreach (ObjectId id in bref.AttributeCollection)
         {
             if (!id.IsErased)
             {
                 yield return (AttributeReference) trx.GetObject(id, mode, false, openObjectsOnLockedLayers);
             }
         }
     }
 }
开发者ID:sybold,项目名称:AcExtensionLibrary,代码行数:35,代码来源:BlockReferenceExtensions.cs

示例4: DimStyleTable

 /// <summary>
 /// Dims the style table.
 /// </summary>
 /// <param name="database">The database.</param>
 /// <param name="transaction">The transaction.</param>
 /// <param name="openMode">The openMode.</param>
 /// <returns>DimStyleTable</returns>
 /// <exception cref="Exception"></exception>
 /// <example>
 /// <code source=".\Content\Samples\Samplescsharp\AcDbMgdExtensions\DatabaseServices\DatabaseExtensionsCommands.cs" language="cs" region="DimStyleTableTrx" />
 /// <code source=".\Content\Samples\Samplesvb\AcDbMgdExtensions\DatabaseServices\DatabaseExtensionsCommands.vb" language="VB" region="DimStyleTableTrx" />
 /// </example>
 public static DimStyleTable DimStyleTable(this Database database, Transaction transaction, OpenMode openMode = OpenMode.ForRead)
 {
     if (transaction == null)
     {
         throw new Exception(ErrorStatus.NoActiveTransactions);
     }
     return (DimStyleTable)transaction.GetObject(database.DimStyleTableId, openMode, false, false);
 }
开发者ID:sybold,项目名称:AcExtensionLibrary,代码行数:20,代码来源:DatabaseExtensions.cs

示例5: GetLayer

 private LayerTableRecord GetLayer(string layerName, LayerType fx, bool isPlottable, Transaction trans)
 {
     LayerTableRecord ltr = new LayerTableRecord();
     ltr.Name = layerName;
     Color color = GetLayerColor(fx);
     ltr.Color = color;
     LinetypeTable ltt = trans.GetObject(db.LinetypeTableId, OpenMode.ForRead) as LinetypeTable;
     ltr.LinetypeObjectId = ltt["Continuous"];
     ltr.IsPlottable = isPlottable;
     return ltr;
 }
开发者ID:anielii,项目名称:Acommands,代码行数:11,代码来源:LayerManager.cs

示例6: CreateIfDoesntExists

 private void CreateIfDoesntExists(Transaction trans, string layerName, LayerType fx, bool isPlottable)
 {
     LayerTable lt = trans.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
     if (!lt.Has(layerName))
     {
         LayerTableRecord ltr = GetLayer(layerName, fx, isPlottable, trans);
         lt.UpgradeOpen();
         lt.Add(ltr);
         trans.AddNewlyCreatedDBObject(ltr, true);
     }
 }
开发者ID:anielii,项目名称:Acommands,代码行数:11,代码来源:LayerManager.cs

示例7: ScaleCircles

 private void ScaleCircles(ObjectId[] circlesIds, double scaleRatio, Transaction trans)
 {
     Circle circle;
     foreach (var circleId in circlesIds)
     {
         var circleObject = trans.GetObject(circleId, OpenMode.ForWrite);
         if (circleObject is Circle)
         {
             circle = circleObject as Circle;
             circle.Radius *= scaleRatio;
         }
     }
 }
开发者ID:anielii,项目名称:Acommands,代码行数:13,代码来源:AScaleCircles.cs

示例8: ChangeBlocksText

        private void ChangeBlocksText(IEnumerable<BlockReference> blockCollection, int startNumber, string blockTag, bool blockOneType, Transaction trans)
        {
            foreach (BlockReference item in blockCollection)
            {
                AttributeCollection atc = item.AttributeCollection;

                foreach (ObjectId attribute in atc)
                {
                    AttributeReference atr = trans.GetObject(attribute, OpenMode.ForRead) as AttributeReference;

                    if(atr.Tag == blockTag)
                    {
                        atr.UpgradeOpen();
                        atr.TextString = GetTagText(startNumber, blockOneType);
                        startNumber++;
                    }
                }
            }
        }
开发者ID:anielii,项目名称:Acommands,代码行数:19,代码来源:AColumnText.cs

示例9: AddAttributes

 /// <summary>
 /// Добавление атрибутов к вставке блока
 /// </summary>        
 public static void AddAttributes(BlockReference blRef, BlockTableRecord btrBl, Transaction t)
 {
     foreach (ObjectId idEnt in btrBl)
     {
         if (idEnt.ObjectClass.Name == "AcDbAttributeDefinition")
         {
             var atrDef = t.GetObject(idEnt, OpenMode.ForRead) as AttributeDefinition;
             if (!atrDef.Constant)
             {
                 using (var atrRef = new AttributeReference())
                 {
                     atrRef.SetAttributeFromBlock(atrDef, blRef.BlockTransform);
                     //atrRef.TextString = atrDef.TextString;
                     blRef.AttributeCollection.AppendAttribute(atrRef);
                     t.AddNewlyCreatedDBObject(atrRef, true);
                 }
             }
         }
     }
 }
开发者ID:vildar82,项目名称:AcadLib,代码行数:23,代码来源:BlockInsert.cs

示例10: Create

        public static void Create(Database db, Grevit.Types.Door door, Wall wall, Transaction tr, BlockTableRecord ms)
        {
            Door d = new Door();
            DictionaryDoorStyle dds = new DictionaryDoorStyle(db);
            bool newEnt = false;
            if (Command.existing_objects.ContainsKey(door.GID))
            {
                d = (Door)tr.GetObject(Command.existing_objects[door.GID], OpenMode.ForWrite);
            }
            else
            {
                d.SetDatabaseDefaults(db);
                d.SetToStandard(db);
                AnchorOpeningBaseToWall w = new AnchorOpeningBaseToWall();
                w.SetToStandard(db);
                w.SubSetDatabaseDefaults(db);
                d.SetAnchor(w);
                newEnt = true;
                w.SetSingleReference(wall.Id, Autodesk.Aec.DatabaseServices.RelationType.OwnedBy);
            }

            Point3d pkt = new Point3d(door.locationPoint.x, door.locationPoint.y + (wall.Width / 2), door.locationPoint.z);
            d.Location = pkt;

            LayerTable lt = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForRead);
            if (door.TypeOrLayer != "") { if (lt.Has(door.TypeOrLayer)) d.LayerId = lt[door.TypeOrLayer]; }
            if (dds.Has(door.FamilyOrStyle, tr)) d.StyleId = dds.GetAt(door.FamilyOrStyle);

            if (newEnt)
            {
                AddXData(door, d);
                ms.AppendEntity(d);
                tr.AddNewlyCreatedDBObject(d, true);
            }

            writeProperties(d, door.parameters, tr);
            storeID(door, d.Id);
        }
开发者ID:bbrangeo,项目名称:Grevit,代码行数:38,代码来源:CreateExtension.cs

示例11: GetReferenceMark

        private PromptEntityResult GetReferenceMark(Transaction trans)
        {
            PromptEntityResult referenceMarkPrompt;
            PromptEntityOptions selectionOptions = GetReferenceSelectionPrompt();

            while (true)
            {
                referenceMarkPrompt = editor.GetEntity(selectionOptions);
                if (referenceMarkPrompt.Status == PromptStatus.OK)
                {
                    var referenceMark = trans.GetObject(referenceMarkPrompt.ObjectId, OpenMode.ForRead);
                    if (referenceMark is BlockReference)
                    {
                        BlockReference blockReference = referenceMark as BlockReference;
                        if (blockReference.Name == blockName)
                            break;
                    }
                }
                else if (referenceMarkPrompt.Status == PromptStatus.Cancel)
                    break;
            }
            return referenceMarkPrompt;
        }
开发者ID:anielii,项目名称:Acommands,代码行数:23,代码来源:AKoty.cs

示例12: FindBlRefStampContent

 private BlockReference FindBlRefStampContent(BlockTableRecord btrLayoutContent, Transaction t)
 {
     foreach (ObjectId idEnt in btrLayoutContent)
      {
     if (idEnt.ObjectClass.Name == "AcDbBlockReference")
     {
        var blRefStampContent = t.GetObject(idEnt, OpenMode.ForRead, false, true) as BlockReference;
        if (blRefStampContent.GetEffectiveName().Equals(Settings.Default.BlockFrameName, StringComparison.OrdinalIgnoreCase))
        {
           return blRefStampContent;
        }
     }
      }
      throw new System.Exception("Не найден блок штампа в шаблоне содержания.");
 }
开发者ID:vildar82,项目名称:PanelColorAlbum,代码行数:15,代码来源:SheetsContent.cs

示例13: IsDatabaseHas

 public bool IsDatabaseHas(Transaction trans, string blockName)
 {
     bool databaseHasBlock;
     BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
     if (bt.Has(blockName))
     {
         databaseHasBlock = true;
     }
     else
     {
         databaseHasBlock = false;
     }
     return databaseHasBlock;
 }
开发者ID:anielii,项目名称:Acommands,代码行数:14,代码来源:BlockManager.cs

示例14: LayoutDictionary

 /// <summary>
 /// Layouts the dictionary.
 /// </summary>
 /// <param name="database">The database.</param>
 /// <param name="transaction">The transaction.</param>
 /// <param name="openMode">The openMode.</param>
 /// <param name="includingErased">if set to <c>true</c> [including erased].</param>
 /// <returns></returns>
 /// <exception cref="Exception"></exception>
 public static LayoutDictionary LayoutDictionary(this Database database, Transaction transaction,
     OpenMode openMode = OpenMode.ForRead, bool includingErased = false)
 {
     if (transaction == null)
     {
         throw new Exception(ErrorStatus.NoActiveTransactions);
     }
     DBDictionary dic = (DBDictionary)transaction.GetObject(database.LayoutDictionaryId, openMode, false, false);
     return includingErased
         ? new LayoutDictionary(transaction, dic, includingErased)
         : new LayoutDictionary(transaction, dic.IncludingErased, includingErased);
 }
开发者ID:sybold,项目名称:AcExtensionLibrary,代码行数:21,代码来源:DatabaseExtensions.cs

示例15: UpdateDescriptionBlockTags

        public void UpdateDescriptionBlockTags(Transaction trans, Handle handle, Dictionary<string, string> tagsValues)
        {
            ObjectId blockObjId;
            if (db.TryGetObjectId(handle, out blockObjId))
            {
                BlockReference br = trans.GetObject(blockObjId, OpenMode.ForRead) as BlockReference;

                AttributeCollection atc = br.AttributeCollection;
                foreach (ObjectId objId in atc)
                {
                    AttributeReference atr = trans.GetObject(objId, OpenMode.ForWrite) as AttributeReference;
                    if (tagsValues.ContainsKey(atr.Tag))
                    {
                        atr.TextString = tagsValues[atr.Tag];
                    }
                }
            }
        }
开发者ID:anielii,项目名称:Acommands,代码行数:18,代码来源:BlockManager.cs


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