Dynamic Block with Parametric constraints update geometry within command

Dynamic Block with Parametric constraints update geometry within command

MGO-Norsyn
Advocate Advocate
494 Views
5 Replies
Message 1 of 6

Dynamic Block with Parametric constraints update geometry within command

MGO-Norsyn
Advocate
Advocate

I am placing a dynamic block with parametric constraints and setting some values by code which in turn should modify the block dimensions. I am using these geometric dimensions in later code to modify some other geometry.

The problem is that the block does not update until I exit the command. I have searched everywhere and apparently one should call AnonymousBlockTableRecord abtr.UpdateAnonymousBlocks and set the current document doc.TransactionManager.QueueForGraphicsFlush();

 

But this doesn't work. Please help me force Autocad to update this dynamic block, so I can read it's new geometry and act upon it without exiting the command.

0 Likes
495 Views
5 Replies
Replies (5)
Message 2 of 6

_gile
Consultant
Consultant

Hi,

What if you commit and close the transaction after having edited the block and start a new one to re-open the block for read ?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 6

MGO-Norsyn
Advocate
Advocate

Thank you for your suggestion, it is what I am doing currently.

I started first with an encompassing transaction, but after I encountered this problem, I changed my code to passing ObjectIds around and creating transaction in each method.

So I place the block in one transaction, commit it, then in the next method, which should operate on the updated geometry, open a new transaction, but the block (also visually) remains as in blockeditor until I exit the command.

😞

0 Likes
Message 4 of 6

_gile
Consultant
Consultant

In another topic, you said: "I have a dynamic block with parametric constraint which calculates arc length based on radius and angle".

You do not need a paramtric constraint to calculate the arc length based on radius and angle, simply multiply the angle (in radians) by the radius.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 6

MGO-Norsyn
Advocate
Advocate
Thank you for this little detail. I was wrong in my description though, I am not finding the length of the arc, but rather the length of two tangents at both ends of the arc for pipe elbow cut length calculation. Anyway, I solved my problem from before by working around by calculating the needed geometry intersection points inside the code.
So the problem with geometric constraints not updating until command exit still persists.
0 Likes
Message 6 of 6

MGO-Norsyn
Advocate
Advocate

I found a workaround for this problem. I have detailed it in this post: https://forums.autodesk.com/t5/net/update-dynamic-block-with-constraint-parameter-while-command-is/m...

In short, call a command like this:

editor.Command("-PAN", new Point3d(), new Point3d());

This will force Autocad to update parametric geometry.

0 Likes