Hi guys,
I’m trying to model a stack creator but I’m not being able to modify the position of each component to create the stack.
My first idea was to move the components keeping them into the component container, attaching them to the first component of the stack but I haven’t been able to do this as they don’t move from the node of the component container.
Even if I have attached the components to the sim.world node they keep attached the component container and they don’t move.
I think I have not understood the basics of simulation hierarchy and I’m not on the right track.
Thanks in advance!
StackCreatorTest.vcmx (12.6 KB)
from vcScript import *
import vcMatrix
sim = getSimulation()
app = getApplication()
comp = getComponent()
products = {'Block':'vcid:b3932aed-c4b9-4895-a94e-5340a2d994e0'}
def OnRun():
global products
creator = comp.findBehaviour('StackCreator')
container = comp.findBehaviour('StackContainer')
n_block = comp.getProperty('N_Comp').Value
n_b = 0
while n_b < n_block:
n_b+=1
#Create part
creator.Part = products['Block']
part = creator.create()
if part:
print "Part %i created" %n_b
first_part = True
for part in container.Components:
if first_part:
pm = part.WorldPositionMatrix
release_node = part
# release_node = sim.World
first_part = False
release_node.attach(part)
pm.translateRel(0,0,1000)
part.PositionMatrix = pm
sim.update()