api-issue-tracker
api-issue-tracker copied to clipboard
comp#make_unique does not guarantee the definition is made unique (or we need a definition#duplicate)
The typical use case is to construct a new definition from an existing one (usually modify the definition while keeping the original one).
The workaround that works is to:
- create a new definition (
model.definitions.add) - insert an instance of the definition to be copied
- explode the instance
The method whereby you do a make_unique on a component does not guarantee that the definition of the component is different from the original one.
And there is no method definition#duplicate (or definition#copy). This would probably the simplest.
The method whereby you do a make_unique on a component does not guarantee that the definition of the component is different from the original one.
When does it not create a new definition?
When does it not create a new definition?
if the component / group is the ONLY instance in the model.
And, if you have several instances, there is nothing documented about which instance gets a new definition.
Say you have C1 and C2 the instances of the same deifnition cdef.
If you do C1.make_unique, there is no guarantee that C1 gets the new definition. It could well be C2.
The use case is:
- given a definition
cdef - you want to create a duplicate of the definition
cdef2to modifying it, - while keeping the original definition
cdef
if the component / group is the ONLY instance in the model.
Ah. I'd say that's expected (as designed) since it's "make unique" and a single instance is already unique. And we would probably break existing behaviour if we changed that. So a new duplicate method makes sense to me.
If you do C1.make_unique, there is no guarantee that C1 gets the new definition. It could well be C2. That is unfortunate, yes. Would have to look into that. Something we'd have to be careful about touching in case it breaks anything. It'd depend on what is actually dictating the current behaviour. (Maybe its order dependent of some data in a container.)
Marking it as a bug and an enhancement request.
Many thanks.
I think that a method definition#duplicate would be a good enhancement (I am even surprised it did not exist).
For the make_unique, it might be that the instance which get the new definition is the last one created.
Logged as: SKEXT-4120