McBlockRef
class is used to represent the insertion of a block in a drawing. All you need to do is create an insert object and assign a block name as the BlockName
field: McBlockRef refBlk = new McBlockRef(); refBlk.BlockName = "block_01"; refBlk.DbEntity.AddToCurrentDocument();
DbEntity.ObjectProperties
: refBlk.DbEntity.ObjectProperties["NAME"] = “”; refBlk.DbEntity.ObjectProperties["LABEL"] = “1127()”;
McDocument
class contains a method for displaying a dialog with a list of all the blocks present in the document, with which you can select the necessary block for insertion: [CommandMethod("smpl_insertBlock", CommandFlags.NoCheck | CommandFlags.Redraw)] static public void smpl_insertBlock() { // McDocument doc = McDocumentsManager.GetActiveDoc(); if (doc == null) return; String selBlock = String.Empty; McObjectId currId; // if (doc.ShowSelectBlockForm(ref selBlock, out currId, McContext.MainWindow().Handle)) { McBlockRef refBlk = new McBlockRef(); refBlk.BlockName = selBlock; refBlk.DbEntity.AddToCurrentDocument(); // InputJig jig = new InputJig(); refBlk.DbEntity.ObjectProperties["NAME"] = jig.GetText(" :"); refBlk.DbEntity.ObjectProperties["LABEL"] = jig.GetText(" :"); } else { MessageBox.Show(" "); } }
Source: https://habr.com/ru/post/269203/
All Articles