I use the following code to create blocks in AutoCAD 2013. When the user goes to insert this block, the insert command does not show a preview of the block when moving the mouse to locate it, and it comes in exploded. This was working at one point, but something changed. Is there some setting in AutoCAD or through the API that would cause this behavior? Any other ideas?
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Point3d p1 = new Point3d(0, 0, 0);
Point3d p2 = new Point3d(10, 0, 0);
Point3d p3 = new Point3d(10, 10, 0);
using (Transaction Tx = db.TransactionManager.StartTransaction())
BlockTable blkTbl = Tx.GetObject(db.BlockTableId, OpenMode.ForRead, false, true) as BlockTable;
// ...Warn the user
BlockTableRecord btr = new BlockTableRecord();
btr.Name = "TEST";
ObjectId btrId = blkTbl.Add(btr);
// Add entities
Line l1 = new Line(p1, p2);
l1.ColorIndex = 5;
Line l2 = new Line(p2, p3);
l2.ColorIndex = 5;
Solved! Go to Solution.
>> to insert this block, the insert command does not show a preview
>> [...] and it comes in exploded
this code shows how you create a blockdefinition, it does not show how the user is inserting anything with preview or exploded.
- alfred -
Blocks created by your plugin/extension do not get a preview icon automatically. You would need to use the BLOCKICON command or some other means of generating the preview icon.
As far as being inserted exploded, that's most-likely because the checkbox on the insert dialog is checked.
Yes, somehow the "Explode" checkbox got checked. That took care of the preview also. Now, when the user inserts, they see the preview and the block does not explode. Don't I feel foolish!
Start with some of our most frequented solutions to get help installing your software.