Message 1 of 3
Manipulating a component's origin
Not applicable
02-25-2016
12:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
is there a way to translate and rotate an orgin of a component using the python API.
I have code to reorient the coordinate system of an occurance but it doesn't seem to do anything to the actual component:
def translateToNewOrigin(root, newOrigin, newZaxis):
zAxis = newZaxis
(x,y,z)= axes(zAxis)
xAxis = adsk.core.Vector3D.create(x[0],x[1],x[2])
yAxis = adsk.core.Vector3D.create(y[0],y[1],y[2])
zAxis = adsk.core.Vector3D.create(z[0],z[1],z[2])
# reportMessageBox("Axes: \nx:{}\ny:{}\nz:{}",(x,y,z))
for occurrence in design.rootComponent.allOccurrencesByComponent(root):
# reportMessageBox("occurance: {}", (occurrence.component.name))
# Get the current transform of the occurrence
transform = occurrence.transform
# reportMessageBox("transform: {}", (transform.asArray()))
coordinateSystem = transform.getAsCoordinateSystem()
# reportMessageBox("system: {}, {}, {},{};", coordinateSystem)
transform.setToAlignCoordinateSystems(coordinateSystem[0],coordinateSystem[1],coordinateSystem[2],coordinateSystem[3],newOrigin,xAxis,yAxis,zAxis)
# reportMessageBox("new Transform: {}", (transform.asArray()))
# Set the tranform data back to the occurrence
occurrence.transform = transform
# reportMessageBox("result: {}", (self.design.rootComponent.allOccurrencesByComponent(self.RWOH).item(0).transform.asArray()))
