I imported a set of points from an external file into VC and use “routine.addStatement” to translate these points into a routine for robots,as the Fig1 shows. I found that the routine will move along with robots. The exact result i prefered is like fig2 and i hope the generated routine can be attached to a workpiece rather a robot. Is there any functions i can use to achieve the purpose.
FIG1:
Hello!
Are you talking about attaching a base to a workpiece yes, it’s certainly possible, you can use set the Node of any base frame under the robot’s base group to a workpiece and then loop through modifying the robot program to change the base of the part you need from Null to the base frame that’s already been set.
Note that after setting it up, because the parent of the base frame has changed, you’ll also need to do some Matrix manipulation to make the frame normal overall.
The help file is a bit inadequate for reading changes to the robot program strip, it goes roughly as follows (I didn’t write in the changes to the location).
from vcScript import *
from vcHelpers.Robot2 import *
from vcRslStatement import *
def OnSignal( signal ):
pass
def OnRun():
pass
comp = getComponent()
app = getApplication()
part = app.findComponent('Block Geo')
robot = comp.findBehaviour('DFC4')
base = robot.Bases[0]
base.Node = part
print base
robotexe = comp.findBehaviour('Executor')
#print robotexe.Program
main = robotexe.Program.MainRoutine
routines= main.Statements
#print routines
for i in routines:
if i.Scopes != []:
#print "yes"," ",i.Scopes
for j in i.Scopes:
print j.Statements
for z in j.Statements:
z.Base = base