If I have a dynamic block that contains several Point Parameters (see simplified example attached). How can I insert the block then set the values of the Point parameters in code (C# preferred not not mandatory).
I have been able to determine how to set Attributes in code, but so far I have been unable to determine how to set Parameter values programmatically.
Update: I was able to get a test program working to modify the block parameters, however, if I inspect the block after the code is run the Point Parameters will contain the modified values but the positions of the points in the drawing will not have moved. I tried executing REGEN and ATTSYNC afterwards but no change.
var doc = Application.DocumentManager.MdiActiveDocument;
var editor = doc.Editor;
using (var trans = doc.TransactionManager.StartTransaction())
{
var allObjects = editor.SelectAll().Value;
foreach (SelectedObject obj in allObjects)
{
var blockReference = trans.GetObject(obj.ObjectId, OpenMode.ForWrite) as BlockReference;
if (blockReference == null)
continue;
if (!blockReference.IsDynamicBlock)
continue;
foreach (DynamicBlockReferenceProperty property in blockReference.DynamicBlockReferencePropertyCollection)
{
if (property.PropertyName == "START_POINT X")
{
property.Value = 1.0;
}
if (property.PropertyName == "START_POINT Y")
{
property.Value = 2.0;
}
}
}
trans.Commit();
}
Can't find what you're looking for? Ask the community or share your knowledge.