I’m investigating the possibility of printing the sensor placement on all conveyor belts. Therefor, I’m trying to find out where the sensor is placed relative to the origin of the part. This is what I have now:
from vcScript import *
import vcMatrix
app = getApplication()
for comp in app.Components:
name = comp.Name
frame = comp.findFeature("Mid")
if frame:
pos = frame.PositionMatrix
print name
print frame
print pos.P.X, pos.P.Y, pos.P.Z
This gives the following in the output panel:
It returns x, y, z positions as 0.0, but the x value should return 750.0. Does anyone know why this happens and how to fix this?
“PositionMatrix” gives you the position of a feature realtive to it’s parent feature.
So I assume your “Mid” feature is inside another feature.
Use “NodePositionMatrix” instead to get the position relative to the node.
Instead of using the frame.PositionMatrix, use either the frame.FramePositionMatrix or frame.NodePositionMatrix
vcFeature.PositionMatrix will give you the position of the feature relative to its parent feature. However the transformation of the feature is 0,0,0, as the transformation takes place in the transform above the feature in the tree.
vcFeature.NodePositionMatrix will give you the position inside this Node, which is the value you are looking for. Also the vcFrameFeature.FramePositionMatrix will give you this value.