Using pythonOCC to get Weld Bead

Forums: 

Hello everyone.

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:

#69=TESSELLATED_SHELL('Weld Bead1',(#57,#58,#59,#60,#61,#62,#63,#64,#65,#66,#67,#68),$);

But I'm not sure how to start, and how to interpret this.
If anyone is able to help me I appreciate it.

Thanks.

Dmitrii Pasukhin's picture

Hello,

Unfortunatelly, I don't know pythonOCC functionality.

But you can make a look into this topic how to get the id of entity in STEP file? - Forum Open Cascade Technology

To get some samples how to iterate model tree, extract and down cast each entity.

Best regards, Dmitrii.

Jorge Fernandes's picture

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?

Dmitrii Pasukhin's picture

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

Jorge Fernandes's picture

If you find some post similar using python, please let me know.

Thanks a lot for your time.

Jorge Fernandes's picture

Hi @Dmitrii Pasukhin

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

entity
<class 'Standard_Transient'>

but I'm not sure what to do with it...

From the step file, id #30 is:

#30=TESSELLATED_SHELL('Weld Bead1',(#27,#28,#29),$);

How to extract the information?

Go ahead and use c++ terms, I'll be able to adapt.

Thanks in advance.

haibo xu's picture

Hi @Jorge Fernandes
Did you solve the problem? I have the same question , could you tell me how to solve it .