.NET

Reply
Distinguished Contributor
tommam
Posts: 139
Registered: ‎05-07-2008
Message 1 of 4 (282 Views)
Accepted Solution

Creating blocks, but not inserting correctly

282 Views, 3 Replies
03-22-2013 03:34 PM

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?

 

Thanks!!

 

            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;

 

                if (blkTbl.Has("TEST"))

                {

                    // ...Warn the user

                }

                else

                {

                    BlockTableRecord btr = new BlockTableRecord();

                    btr.Name = "TEST";

 

                    blkTbl.UpgradeOpen();

                    ObjectId btrId = blkTbl.Add(btr);

                    Tx.AddNewlyCreatedDBObject(btr, true);

 

                    // Add entities

                    Line l1 = new Line(p1, p2);

                    l1.ColorIndex = 5;

                    btr.AppendEntity(l1);

                    Tx.AddNewlyCreatedDBObject(l1, true);

                    Line l2 = new Line(p2, p3);

                    l2.ColorIndex = 5;

                    btr.AppendEntity(l2);

                    Tx.AddNewlyCreatedDBObject(l2, true);

 

                    Tx.Commit();

                }

            }

*Expert Elite*
Alfred.NESWADBA
Posts: 8,866
Registered: ‎06-29-2007
Message 2 of 4 (266 Views)

Re: Creating blocks, but not inserting correctly

03-22-2013 04:23 PM in reply to: tommam

Hi,

 

>> 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 -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 3 of 4 (255 Views)

Re: Creating blocks, but not inserting correctly

03-22-2013 07:50 PM in reply to: tommam

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.

 

 

Distinguished Contributor
tommam
Posts: 139
Registered: ‎05-07-2008
Message 4 of 4 (234 Views)

Re: Creating blocks, but not inserting correctly

03-23-2013 07:51 AM in reply to: DiningPhilosopher

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!

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community