コード例 #1
0
ファイル: InsertBlockTable.cs プロジェクト: JieGou/jszomorCAD
        private void PlaceBlock(ObjectId blockId, InsertBlockBase insertBlock, double offsetX = 0.0d, double offsetY = 0.0d)
        {
            //var defultLayers = new LayerCreator();
            using (var tr = _db.TransactionManager.StartTransaction())
            {
                var currentSpaceId = tr.GetObject(_db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;

                using (var blockDefinition = (BlockTableRecord)tr.GetObject(blockId, OpenMode.ForRead, false))
                {
                    using (var acBlkRef = new BlockReference(
                               new Point3d(insertBlock.Position.X + offsetX, insertBlock.Position.Y + offsetY, 0), blockId))
                    {
                        //InsertBlockBase insertData;
                        currentSpaceId.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);

                        SetBlockReferenceLayer(acBlkRef, insertBlock.LayerName);
                        SetRotate(acBlkRef, insertBlock.Rotation);
                        CreateBlockRefenceAttributes(acBlkRef, blockDefinition, tr);
                        SetVisibilityIndex(acBlkRef, insertBlock.StateProperty);
                        SetBlockRefenceAttributesValues(acBlkRef, insertBlock.ActionToExecuteOnAttRef);
                        SetDynamicBlockReferenceValues(acBlkRef, insertBlock.ActionToExecuteOnDynPropAfter);
                        SetHostName(acBlkRef, insertBlock.HostName);
                    }
                }
                tr.Commit();
            }
        }
コード例 #2
0
ファイル: InsertBlockTable.cs プロジェクト: JieGou/jszomorCAD
        public bool InsertBlock(InsertBlockBase insertData)
        {
            // 1. which block to insert? insertData.BlockName
            // get the block to insert
            var blockId = GetBlockTable(insertData.BlockName);

            var offsetX = 0.0d;
            var offsetY = 0.0d;

            // 2. insert block
            for (var i = 0; i < insertData.NumberOfItem; i++)
            {
                PlaceBlock(blockId, insertData, offsetX, offsetY);
                offsetX += insertData.OffsetX;
                offsetY += insertData.OffsetY;
            }
            return(true);
        }