SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
38 stars 10 forks source link

[Component Definition] Name assignment messed up with Undo #933

Open Fredosixx opened 1 year ago

Fredosixx commented 1 year ago

1) Start a new model in SU2023 2) Take a component definition (cdef), for instance the Heather component, with name Heather 3) Change its name via cdef.name = 'Fredo'. This works fine. The component shows the name Fredo 4) Perform an UNDO. The component gets its original name back (Heather). 5) Redo the change of name cdef.name = 'Fredo'. The component receives the name Fredo#1.

See video attached for illustration

https://github.com/SketchUp/api-issue-tracker/assets/57754157/ab0ccf52-cc65-4cd0-b662-7f6e09efe247

The issue is that there is NO way to correct the definition name via the API from now on.... The name Fredo is supposed to be used for as long as the model is opened.

Strangely, you can correct the name manually in the Component panel, as shown at the end of the video.

It seems that the table for Unique definition names is not restored to its previous state when you do an UNDO. So, the name 'Fredo' is still in the table and you therefore get a name with a suffix when you try to assign it. This also happens if you re-assign the same name to a component definition: on Heather component, cdef.name = cdef.name will result in the component being named Heather#1...!

More generally, the method cdef#name = <new_name> has a strange behavior, trying to make the new name unique, even if the new_name is not used in the model. The correct behavior would be to check if there is already a definition with the specified in the model. If not, then should be accepted.

thomthom commented 10 months ago

I can reproduce this back to SU2022. SU2021 works as expected.

sketchup[bot] commented 10 months ago

Logged as: SKEXT-3987