"House" is already the name of an existing definition in the model’s
ComponentDefinition name must be unique as it is used as a key.
You can easily test this before your code:
# method will return
nil if the definition name has not yet been used.
The absolute necessity for uniqueness of member names applies for all of the SketchUp API’s collection classes that allow access by name via their
So generally, for any collection member object, if you attempt to set the member’s
name property to a name that is already in use, then the API will “difference” the name by adding
" where n is an integer that forces the name to be unique.*
* This also applies to manual user actions through the GUI when bringing resources into the model such as definitions, materials, etc.
If you wanted to reuse the name
"House", you would first need to delete the old definition using that name.
dlist = active_mod.definitions
if old_house = dlist['House']
dlist.remove(old_house) if old_house.instances.empty
If you do not care if
old_house had instances, then calling
dlist.remove(old_house) will delete those instances from the model or the entities of any other definition (whether used or not.)
ADD: the other option is to rename the