Hi,
I am using version 4.4. I have a robot tool (2F-85) and I want to mount this tool on a UR10e robot. I can easily connect them with drag and drop. It also works when I use the “Interfaces Button” at the top of the screen. But I need to do this with python programming. I tried many different methods., watched many videos and read many topics in forum. But I couldn’t find the solution. I can connect other components and create a hierarchy with the “attach” method, but it doesn’t work for mounting tools. I also tried to connect the interfaces of the robot and the robot tool, but this also didn’t work. You can see my code below. Could you please help me?
from vcScript import *
from vcHelpers.Robot import *
from vcHelpers.Robot2 import *
from vcHelpers.Selection import getAllComponents
import vcMatrix
import vcVector
import sys
import os
import difflib
import xml.etree.ElementTree as xml
from vcSimInterface import *
from vcSimInterfaceField import *
app = getApplication()
sim = getSimulation()
Load the robot tool 2F-85
app.load(“file:///C:/Users/Public/Documents/Visual Components/4.4/Models/Components/Robotiq/Robot Tools/2F-85.vcmx”)
Find the robot
robot = app.findComponent(“UR10e”)
Define the position of the robot
mtx1 = vcMatrix.new()
mtx1.translateRel(5.00000000, 5.00000000, 0.00000000)
robot.PositionMatrix = mtx1
robot.update()
Find the robot tool
tool1 = app.findComponent(“2F-85”)
Find the “mountplate” node of the robot and get its position
mountNode = robot.findNode(“mountplate”)
mountNode_node_mtx = mountNode.PositionMatrix
mountNode_world_mtx = mountNode.WorldPositionMatrix * mountNode_node_mtx
mountNode_wpr = mountNode_world_mtx.getWPR()
Define the position of the robot tool
mtx = vcMatrix.new()
mtx.translateRel(mountNode_world_mtx.P.X, mountNode_world_mtx.P.Y, mountNode_world_mtx.P.Z)
mtx.rotateRelX(mountNode_wpr.X)
mtx.rotateRelY(mountNode_wpr.Y)
mtx.rotateRelZ(mountNode_wpr.Z)
tool1.PositionMatrix = mtx
tool1.update()
#robot.update()
Attach robot tool to “mountnode”
mountNode.attach(tool1, True)
Find interfaces to connect them
inIface = robot.findBehaviour(‘Tool’)
print(inIface, inIface.Name)
outIface = tool1.findBehaviour(‘EOAT_MountInterface’)
print(outIface, outIface.Name)
Connect interfaces
if outIface.canConnect(inIface):
print(“It works!”)
outIface.connect(inIface) #OPTION 1: this will not move the connected component
#app.connectComponents(robot, tool1) # OPTION 2: this will move them
outIface.connect(inIface)
outIface.update()
tool1.update()
getApplication().render()
mount_tool.vcmx (21.2 KB)