.NET

.NET

Reply
Active Member
h_najmi
Posts: 8
Registered: ‎07-02-2001
Message 1 of 2 (114 Views)

Dynamic block properties from block definition

114 Views, 1 Replies
02-27-2006 10:40 AM
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.
Contributor
mabe2k11
Posts: 24
Registered: ‎03-14-2006
Message 2 of 2 (114 Views)

Re: Dynamic block properties from block definition

04-27-2006 07:20 AM in reply to: h_najmi
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");
}
}

.
.
.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.