To update this topic, I’ve done the looping part so far, and I’ve found that if I remove the Cable behavior before deleting the entire component, then deleting the entire component doesn’t result in an error (I’ve only tested the case where the deletion code is placed in OnReset). I have put the code below for possible needs.
from vcScript import *
import vcMatrix
def OnReset():
global a,temp,por
#a.delete()
a.Visible = False
print por
por.delete()
a.delete()
temp.append(a)
def OnRun():
#app.findComponent('demo').delete()
global a,m,n,b,c,temp,por
#a = part.clone()
#a = app.cloneComponent(part)
m = vcMatrix.new()
n = vcMatrix.new()
m.rotateAbsX(180)
m.translateAbs(0,0,200.999+17.5)
a = app.createComponent()
a.Name = 'demo'
por = a.createBehaviour('rPhysicsRope','PhysicsCable')
a.PositionMatrix = partframe
por.Thickness = 1
n1 = a.findNode('Pin_1')
n2 = a.findNode('Pin_2')
print 'n=[',n.P.X,n.P.Y,n.P.Z,n.WPR.X,n.WPR.Y,n.WPR.Z,']'
print 'm=[',m.P.X,m.P.Y,m.P.Z,m.WPR.X,m.WPR.Y,m.WPR.Z,']'
a.rebuild()
n1.PositionMatrix = n
n2.PositionMatrix = m
a.rebuild()
app = getApplication()
part = app.findComponent('201mm')
partframe = part.PositionMatrix
a = None
temp = []
comp = getComponent()