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

DynamicBlockReferenceProperty Value not changing

3 REPLIES 3
Reply
Message 1 of 4
OlliLuukas
1228 Views, 3 Replies

DynamicBlockReferenceProperty Value not changing

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?

3 REPLIES 3
Message 2 of 4
hgasty1001
in reply to: OlliLuukas

Hi,

 

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

 

 


Message 3 of 4
OlliLuukas
in reply to: hgasty1001

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.

Message 4 of 4

Can you send me that example ????

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