Hello,
I have a tray with 20 + positions that needs to have containers for each position.
I created some of the root frames (4 root frames, for 4 diffenrent parts that need to pleaced in the frames) by hand and moved them to the right position.
I created the other 20 + frames by script, but now I want to move them to their respective traget positions. I know the offsets from the root frames. So what I want to to is
- get the position of the respective root frame
- move the newly created frame to the root frame position
- move the newly created frame by the known offset to their target position
How can I achieve this in the script?
The script (creation of frames+moving) is only run once upon initialization.
This is what I have so far:
from vcScript import *
from collections import namedtuple
import sys
from vcHelpers.Output import *
_schlitten = "S1"
_containers = ["ContainerSechskant1","ContainerSechskant2","ContainerSechskant3","ContainerSechskantLöt"]
_frames = ["FrameS1AufnahmeSechskant1","FrameS1AufnahmeSechskant2","FrameS1AufnahmeSechskant3","FrameS1Lötrohraufnahme"]
def OnSignal( signal ):
pass
def OnRun():
pass
def OnStart():
targetNode = _comp.findNode("201_Y-Achse")
for container in _containers:
for number in range(1,5):
getOrCreateBehaviour(_comp, targetNode, VC_COMPONENTCONTAINER, _schlitten + container + str(number))
print("creating frames")
targetFeature = _comp.findFeature("Aufnahmeschlitten-1")
if targetFeature is not None:
for frame in _frames:
for number in range(1,5):
getOrCreateFeature(_comp, targetFeature, VC_FRAME, frame + str(number))
rootFrameName = "Root" + frame
rootFrame = _comp.findFeature(rootFrameName)
# get root frame position
# move frame to target position
def getOrCreateProperty(comp, type, name, quantityName = None, defaultValue = None):
prop = comp.getProperty(name)
if not prop:
prop = comp.createProperty(type, name)
if quantityName:
prop.Quantity = _app.findQuantity(quantityName)
if defaultValue:
prop.Value = defaultValue
return prop
def getOrCreateBehaviour(rootNode, partentNode, type, name, automaticReset = True):
beh = rootNode.findBehaviour(name)
if not beh:
beh = partentNode.createBehaviour(type, name)
if type in [VC_BOOLEANSIGNAL, VC_REALSIGNAL, VC_INTEGERSIGNAL, VC_STRINGSIGNAL]:
beh.AutomaticReset = automaticReset
return beh
def getOrCreateFeature(rootFeature, parentFeature, type, name):
print("in create feature " + name)
feat = rootFeature.findFeature(name)
if not feat:
feat = parentFeature.createFeature(type, name)
print("created feature")
else:
print("found featrue")
return feat
### GLOBAL VARIABLES ###############################################
_comp = getComponent()
_app = getApplication()
#_buildButton = getOrCreateProperty(_comp, VC_BUTTON, "Build Comp")
#_buildButton.OnChanged = onBuildButtonAction
Thanks for your help in advance
Thomas