I’ve just starting to explore the Python API and I want to be able to update the Origin of an imported component using the Python API. This is a common question/issue in the Component form and I know how to move the origin using the GUI but would like to automate the process using Python.
I thought I could use the MovementOrigin property of the component but assigning a matrix to it doesn’t cause the property to change.
Code Below:
from vcScript import *
import vcMatrix as mat
def printMatrix(mat):
“”“Usefull utility function for printing matrix value”“”
for Vec in [mat.N,mat.O,mat.A,mat.P]:
print (“%3.3g\t%3.3g\t%3.3g\t%3.3g\n”%(Vec.X,Vec.Y,Vec.Z,Vec.W))
workpiece.MovementOrigin = move
workpiece.rebuild() # I’m not sure if I need this one
app.render()
sim.update()
This results in no change to the workpiece origin and the MovementOrigin matrix after the move matrix assignment is still all default values. Could someone offer some insight? I can update the position of the object via the PositionMatrix without issues.
MovementOrigin is not for reset origin, do it opposite way, not to change the component origin, but to change the feature origin, offset the feature, you could collapse feature, make the feature origin consistent with the component origin.
I realized updating the Root feature’s PositionMatrix only made it look like I had shifted the origins of the feature but it wasn’t real. It technically moved them but the features were also tied to the component so when I explode or extract a feature into a component. That new feature/component was free to shift to maintain the original origin offset
Thank you for your response. It’s good to know that the MovementOrigin was the wrong property to use for this.
I do see now that the origin of the components and the origin of the features within the components are different and independent. I am able to move the origin of the feature and it’s nice that moving the Root PositionMatrix will cause all dependent features to move as well.
When you suggest “collapse feature” are you implying that I merge all of the features into one super feature that is the same as the component? I would like to keep all of the features independent as I’ll be exploding them later to make an assembly. I think even if I did merge all my features together, moving the feature and the component origins would still result in different behavior. My current list of features do have the same origin as the component by default.