.NET

Reply
New Member
OlliLuukas
Posts: 2
Registered: ‎07-12-2013
Message 1 of 3 (139 Views)

DynamicBlockReferenceProperty Value not changing

139 Views, 2 Replies
10-03-2013 04:15 AM

I'm having problems with DynamicBlockReferenceProperty Value -property. The value is not changing when I'm trying to set it. So far I've recognized that trying to set a value of wrong type causes an exception to be thrown, but in this example case there is no exception thrown nor does the value of the property change.

 

foreach (DynamicBlockReferenceProperty prop in blockReference.DynamicBlockReferencePropertyCollection)
{
  if (prop.PropertyName != "Property1")
    continue;

  if (prop.ReadOnly)
    continue;

  Console.WriteLine(string.Format("Current value: {0}", prop.Value));
// Outputs correctly: "Current value: 0" foreach (object obj in prop.GetAllowedValues()) // contains 2 values, 0 and 1 if (!prop.Value.Equals(obj)) // skips the first value { prop.Value = obj; Console.WriteLine(string.Format("New value: {0}", prop.Value));
// Outputs "New value: 0"
// Should output "New value: 1" } }

I have also tried stuff like this:

 

Console.WriteLine(prop.Value); // Outputs "0"
prop.Value = (short)1;
Console.WriteLine(prop.Value); // Outputs "0", should output "1"

 

Am I missing something, such as not setting some specific flag in the 'blockReference' which would allow setting of the property values?

Distinguished Mentor
gasty1001
Posts: 535
Registered: ‎04-11-2010
Message 2 of 3 (117 Views)

Re: DynamicBlockReferenceProperty Value not changing

10-03-2013 07:59 AM in reply to: OlliLuukas

Hi,

 

I think you have to update the block table record first, using: MyBlkTblRec.UpdateAnonymousBlocks()

 

 


New Member
OlliLuukas
Posts: 2
Registered: ‎07-12-2013
Message 3 of 3 (97 Views)

Re: DynamicBlockReferenceProperty Value not changing

10-04-2013 03:21 AM in reply to: gasty1001

Ok, I found the solution to the problem. Actually it wasn't all that complicated, but thanks to gasty I realized what was wrong.

 

I was attempting to modify the dynamic property directly on the BlockReference, but I had not added it to the current drawing's modelspace. After appending the BlockReference to the model space, it started working.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.