InternalValidationError of Occurrence deleteMe

InternalValidationError of Occurrence deleteMe

Anonymous
Not applicable
473 Views
1 Reply
Message 1 of 2

InternalValidationError of Occurrence deleteMe

Anonymous
Not applicable

Hello,

 

What my script does so far:

- Insert a Component from File (has a jointOrigin)

- Duplicates the inserted Component with 

 

occurence = rootComp.occurrences.addExistingComponent(sourceComponent, adsk.core.Matrix3D.create())

- gets a Occurence and takes the jointOrigin of the imported component 

- uses createForAssemblyContext(occurence) to get the jointOrigin of the Copy

 

jointInput = joints.createInput(occurence.component.allJointOrigins[jointOriginIndex].createForAssemblyContext(occurence), secondJoinOrigin)

- create a joint

- add the occurence to my global array of occurences 

 

what I try to do:

- iterate through my global variable occurences

- delete all occurence of the created copies who were joined:

    for occurence in occurences:
        if occurence.isValid and occurence.component.name == sourceComponent.name:
            occurences.remove(occurence)
            occurence.deleteMe()

- create new occurences and joints for each selected jointOrigin

 

the first times it works as expected and after selecting the 4th jointOrigin I get this error:

fuserror.PNG

InternalValidationError findObjectPath(this, objPath)

 

How can i delete the occurences on a save way and prevent the Error?

 

 

0 Likes
Accepted solutions (1)
474 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Solution:

 

- Iterate over a copy of the occurences

 

    for occurence in list(occurences):
        if occurence.isValid and occurence.component.name == sourceComponent.name:
            occurences.remove(occurence)
            #occurence.isLightBulbOn = False
            occurence.deleteMe()
0 Likes