Attribute Changes Don't Apply To Nested Blocks

@dale,

I’ve encountered a bug in the way that the way that the SampleCsUserData project and SampleCsSetUserText command are implemented.

Steps to Reproduce:

  • Create a Box
  • Make a Block out of the Box
  • Duplicate the Block Instance
  • Make a Block out of the Two Instances of the Box Block
  • Double Click on the Top Level Block to Modify It
  • Use the Block Editing Dialog to Select one of the instances of the Box Block:
    NestBlockUserData1
  • Use the SampleCsAddUserData Command from the SampleCsUserData Project to add Notes to box in the box block
  • Use the Block Dialog to Switch to the other instance of the Box Block
  • Run the SampleCsQueryUserData Command on the Box in this Block instance
  • The command returns “User data not found.”

The problem appears to be that the RhinoDoc.ModifyObjectAttributes Event doesn’t get called unless you call ‘ModifyAttributes’ on the Document’s Object Table with something like:
rhinoObject.Document.Objects.ModifyAttributes(rhinoObject, newAtt, true);. A similar behavior occurs with the SampleCsSetUserText command when used in conjunction with nested blocks.

-Cullen

Hi @cullen.sarles,

The sample command is adding user data to the instance reference, not the instance definition.

Or did I confuse your instructions?

– Dale

@dale Thanks for taking a look.

Yes, you’ve miss understood my instructions. My original example had two different objects inside the nested box. Hopefully this helps to clarify my instructions:

The goal is to add user data to just the red box inside of the nested block:


The command works, and adds the data, but when you then switch to the other instance of the nested block via the block edit dialog and query the other red box, there’s no user data on it.

Here’s an old post where you point out the solution to the problem, https://discourse.mcneel.com/t/modifyobjectattributes-not-triggering/39263/4. Without the call to ModifyObjectAttributes, the block editor misses that user data on an object inside of a nested block has been modified and doesn’t propagate the change to the nested block’s definition.

Thanks,
Cullen

Hi @cullen.sarles,

I’ve fixed the sample in question. You might pull new source and see if this work any better.

SampleCsSetUserText.cs

– Dale

That looks good for the usertext command. It also needs changed in the SampleCsUserData project.

I can make the changes on my fork and make a pull request if that would be helpful.

Best,
Cullen

Hey @cullen.sarles,

I don’t mind updating - some of the code is looking old.

– Dale