.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynamic block properties from block definition

1 REPLY 1
Reply
Message 1 of 2
Anonymous
244 Views, 1 Reply

Dynamic block properties from block definition

Can we get Dynamic block properties from the block definition. I have some lookup lists and I want to get all available/allowable values from the block definition before inserting an instance of the block.
This would be great to populate my variables and arrays from original blocks instead of hard-coding them in my code.
1 REPLY 1
Message 2 of 2
mabe2k11
in reply to: Anonymous

Try this:

It gets the information of a single block selected by user (code is not complete!).

.
.
.

PromptSelectionOptions prSelectionOptions = new PromptSelectionOptions();
prSelectionOptions.SingleOnly = true;
prSelectionOptions.SelectEverythingInAperture = true;
PromptSelectionResult prSelectionResult = ed.GetSelection(prSelectionOptions);

.
.
.

if (trans.GetObject(prSelectionResult.Value[0].ObjectId, OpenMode.ForRead).GetType() == typeof(BlockReference))
{
BlockReference br = (BlockReference)trans.GetObject(prSelectionResult.Value[0].ObjectId, OpenMode.ForRead);
if (br.IsDynamicBlock)
{
DynamicBlockReferencePropertyCollection dynBrProColl = br.DynamicBlockReferencePropertyCollection;
foreach (DynamicBlockReferenceProperty dynBrPro in dynBrProColl)
{
ed.WriteMessage(dynBrPro.PropertyName + " ");
ed.WriteMessage(dynBrPro.Value.ToString());
ed.WriteMessage("\n");
}
}
else
{
ed.WriteMessage("The block is not dynamic");
}
}

.
.
.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost