pythonocc-core icon indicating copy to clipboard operation
pythonocc-core copied to clipboard

Getting part name and part origin location from assembly step file

Open iantferguson opened this issue 4 years ago • 2 comments

I have an assembly step file and I'm trying to return the part names and part origin locations with respect to the top-level assembly origin. I've tried something like this for getting origin location but all three parts come back as (0.0, 0.0, 0.0):

step_reader = STEPControl_Reader()
step_reader.ReadFile('./test_assy.stp')
step_reader.TransferRoots()
myshape = step_reader.Shape()

it = TopoDS_Iterator(myshape)
while it.More():
   shp = it.Value()
   trsf = myshape.Location().Transformation()
   print (trsf.TranslationPart().Coord())
   it.Next()

I'm also not sure if it's more appropriate to use XCAF and something like ShapeTool which I've seen in some assembly examples.

iantferguson avatar May 12 '21 22:05 iantferguson

Found my answer by looking at DataExchange.py: https://github.com/tpaviot/pythonocc-core/blob/master/src/Extend/DataExchange.py

iantferguson avatar May 13 '21 19:05 iantferguson

I reopen the issue, I have additional material related to this topic

tpaviot avatar May 14 '21 13:05 tpaviot