Message 1 of 1
Dynamic block doesnt correctly update after property value change

Not applicable
03-17-2020
08:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm writing a script that needs to update a dynamic block reference size. When I modify the block reference through the DynamicBlockReferencePropertyCollection, it doesn't get visually updated in the same way as it would if I would move the grip.
Code:
private void UpdateBlockReferenceParameter(Database db, BlockReference blockRef, int referenceIndex, double value)
{
var objectID = blockRef.Id;
using (Transaction transaction = db.TransactionManager.StartTransaction())
{
DBObject obj = transaction.GetObject(objectID, OpenMode.ForWrite);
BlockReference br = ((BlockReference)obj);
br.DynamicBlockReferencePropertyCollection[referenceIndex].Value = value;
transaction.Commit();
}
}
...
for (int i=0; i<br.DynamicBlockReferencePropertyCollection.Count; i++)
{
if (br.DynamicBlockReferencePropertyCollection[i].UnitsType == DynamicBlockReferencePropertyUnitsType.Distance)
{
UpdateBlockReferenceParameter(database, br, i, (double)(200 + i));
}
}
And this is the result:
On the top: the original
In the middle: the dynamic block after running this snippet
On the bottom: the same dynamic block after moving the grip.
The middle version (which is the problem) fixes itself if I move the grip by a small amount after running the script.
What is wrong with what I am doing? How can it be solved?