Tue, 12/13/2022 - 12:09
hi:
while I imported a STEP file by OCC,compare to the text content in STEP file,there are many id of entity just like "#11=","#5="ect,the id show the topology relationship with the other entity.
my question is,if can get these id information by Opencascade?is there any way to got it and as same as it show in STEP file?
thanks
jason
Tue, 12/13/2022 - 14:05
Hello, Yes it is possible.
Code sample to find entity's ID:
Way to find entity by id is not the best. You can upgrade StepData_StepModel to find using key-values from "theidnums" field.
DRAW:
C++ (in this case you iterate for all entities to find needed, not perfomance way):
After that, you can navigate on the entity's graph:
Thank you for your interest in OCCT.
Best regards, Dmitrii.
Wed, 12/14/2022 - 18:32
hi,Dmitrii:
Thans for your reply.
In sample 1,the new questions are:1,because the instance of STEPCAFControl_Reader is null, how can I get the StepData_StepModel?is it generated while loading a step file? 2,what is anEntity?just like an Edge,a Face,a Wire,or a Vertex?if it is,how to translate these different entity?3,how to only determine a entity?then,the only identlable can be given.
In sample 2,the instance of Reader also is null,how to assignment?and the param seems wrong,can not be compiled in VS2017.
Finally,could could you give me a complete sample code?
BestRegards
Jason
Tue, 12/20/2022 - 14:34
Hello,
Entity - is STEP object, for example #13 = EDGE_LOOP.
Full code sample:
Best regards, Dmitrii.
Tue, 12/20/2022 - 16:30
Dmitrii:
Thanks,in this sample,the Reader transfer to TDocStd_Document is not necessary,is right?the const Handle(Standard_Transient)& anEntity how to transfer to TopoDS_Shape,Face,Wire,Edge ect?if it can be transfered,the the entity of STEP FILE and OPENCASCADE object is related.
finally,if want to get the name of entity if STEP file,just like this:tandard_CString shapetypename = aModel->TypeName(anEntity);is it right?
thanks agin.
Jason.
Tue, 12/20/2022 - 17:01
TopoDS_Shape genereted only after Transfer operation (you need to create document). Or you can use STEPControl_Reader
To get TopoDS object from Enitity you can use the next code:
Whan name do you means? If it is description - you need to make downcast and get field value. If it is type name of entity "EDGE_LOOP", that write after #12345 = ... It is possible, but not for all cases. You can get only type name of simple entity. For complex entity it is not possible.
Best regards, Dmitrii.
Thu, 12/22/2022 - 09:12
Dmitrii:
Thanks,I tested by your way and code,it is ok.
Thanks
Jason.
Fri, 01/20/2023 - 12:36
Dmitrii:
An other relative question is:if I hava gotten an entity such as a Shape,face,wire,edge,vertex etc,How can I find it in step/stp file?refer the code you gave,I traverse whole stp file by compare every entities,but not fond the right one.such as if want to find a face in step file,the code just like below:
Handle(Transfer_Binder) binder;
binder = aTP->Find(anEntity);
if (binder.IsNull()) {
continue;
}
TopoDS_Shape shape = TransferBRep::ShapeResult(binder);
if (shape.ShapeType() != TopAbs_FACE)
{
continue;
}
TopoDS_Face face = TopoDS::Face(shape);
if(face.IsSame(searchshape))//searchshape is the one I got in OCC and want to find it in step file.
//if (shape.IsSame(searchshape))
{
AfxMessageBox(_T("found"));
iffond = true;
}
else {
AfxMessageBox(_T("not same"));
}
Above code show that it can not find the right one I want.
Then,what is the problem?could you give a suggestion?
Thanks
Jason.
Tue, 04/23/2024 - 13:31
Hi @Dmitrii Pasukhin
How do we get the Entity value from the Entity Object in pythonocc? such as
#2830 = CARTESIAN_POINT('',(-5.303300858899,3.,5.303300858899)); I need get the value ('',(-5.303300858899,3.,5.303300858899))
Under is my code
step_reader = STEPControl_Reader()
status = step_reader.ReadFile(filename)
model = step_reader.StepModel();
nbNum = model.NbEntities()
for index in range(nbNum):
entity = model.Entity(index + 1);
print(index + 1, model.StringLabel(entity).ToCString(),"=",model.TypeName(entity))
StepBasic_ProductDefinition.DownCast(entity);