How do I use py scripts to control the attachment of one component to another?



Untitled.vcmx (3.5 MB)
I have a question for you. Using robot programming, an object is placed on the assembly line and the object seems to be adsorbed on the conveyor belt after the claw is released. What is the adsorption distance, or can this distance be adjusted?

When you use the grab-and-release feature that comes with the robot program, then the distance it is placed is related to the Gravity direction, and the value of the Gravity direction attribute means that when you release, the robot looks for the last component that is in the extended gravity direction from the TOOL coordinates (which is actually along the Z-direction of TOOL) and attaches the released component to that component, and this is something that can be debugged in the robot properties.


It should be added that the direction is along the Z-axis of the TOOL frame, but the distance is counted from the release of the component.

If the gravity direction of the claw is 25 mm, then the distance currently measured is 26 mm, why is the adsorption still moving together on the assembly line?

Make sure to check the component Bounding box when measuring. The bounding box may be slightly larger.

1 Like

Thank you. I’ve got it. But what do you have to do to release this component and attach it to another component if you want to write a PY script?

1 Like

Thank you. That’s true. I have one more question, this action of attaching to another component, if you want to program it using PY script, what do you need to do?

Either use vcNode.attach(), or if your component has a container, you can use vcContainer.grab().

1 Like


Hello, the use of the vcNode.attach() method changes the location of the component in the world, which is troublesome if you need to keep the location the same. The vcContainer.grab() method requires creating a container in the component in advance, which is also cumbersome. Is there an easier way? Because we can directly click on the menu interface when we manually operate

Many Python API documentation pages have code examples if you scroll to the bottom of the page. The vcNode page has an example of how to attach an object without changing the location.