I want to be able to use Python to read a .STP file, exported by solidworks as STEP 242 using MBD.
In the read file, I want to be able to find the edges that I mark in the SW as weldments. By looking at the ASCII of the .STP file I can see this line:
To get some samples how to iterate model tree, extract and down cast each entity.
Best regards, Commenter-1.
02Author
Thanks for the reply.
I'm not very familiar with C++, but I'll give it a try.
But as far as I understand, the post you mention is similar to what I want. I want to get the entities in #69=TESSELLATED_SHELL('Weld Bead1',(#57,#58,#59,#60,#61,#62,#63,#64,#65,#66,#67,#68),$);
Is there something similar in python?
03Commenter-1
pythonOCC is the almost identical with c++. It is a wrapper.
So, yes. Is is possible by c++ and in the same way it should be possible by pythonOCC
04Author
If you find some post similar using python, please let me know.
Thanks a lot for your time.
05Author
Hi @Commenter-1
from OCC.Core.STEPControl import STEPControl_Reader
from OCC.Core.IFSelect import IFSelect_Functions
from OCC.Core.TopExp import TopExp_Explorer
from OCC.Core.TopAbs import TopAbs_FACE
from OCC.Core.StepRepr import StepRepr_RepresentationItem
from OCC.Extend.TopologyUtils import TopologyExplorer
if __name__ == "__main__":
filename = r'Step_242.STP'
reader = STEPControl_Reader()
reader.ReadFile(filename)
reader.TransferRoots()
tr = reader.WS().TransferReader()
model = reader.StepModel()
shape = reader.OneShape()
t = TopologyExplorer(shape)
ws = reader.WS()
entity_id = '#30'
entity = IFSelect_Functions.GiveEntity(ws, entity_id)
I think this gives more or less what you mention. But now I have