Delete/Remove entities from step model.

Hello,

I am trying to delete/remove some of the entities in my STEP model before proceeding to write STEP file. I want to delete the StepGeom_Axis2Placement3d entities whose name is empty. Here is my code:

Handle(StepData_StepModel) aWriteModel = Handle(StepData_StepModel)::DownCast(writer.Writer().WS()->Model());
for (int i = 1; i <= aWriteModel->NbEntities(); i++)
{
const Handle(Standard_Transient)& anEnt = aReadModel->Value(i);
if (!anEnt->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
{
continue;
}
Handle(StepGeom_Axis2Placement3d) stpEnt = Handle(StepGeom_Axis2Placement3d)::DownCast(anEnt);
auto name = stpEnt->Name();
if (name->IsEmpty()) {
//delete this stpEnt object.
}
}
//write step

Is there any way to do it?

Best Regards,
Prajwal.

Dmitrii Pasukhin's picture

Hello,

Remove something alone is not possible.

You need to remove all reference from it and after that recreate a model.

I can send a code example to remove something. But it takes some times. I apologize for the possible delay.

Best regards, Dmitrii.

kai zhang's picture

Hello, Dmitri,
I have been looking for the knowledge to delete a single component from step, but I have not found it and have no more ideas. You said that you need to delete all references from step and recreate the model. Can you also send me a copy of your example code for me to learn?
This is my email: zk1079511174@163.com

Thank you.
Zhang Kai

Prajwal Shelar's picture

Hello Dmitrii,
Thanks for the reply.
Sample code of removing references and recreating the model will be really helpful.
Thanks,
Prajwal.

Prajwal Shelar's picture

Hello Dmitrii,

Is there any update on this issue?

Best regards,
Prajwal

Dmitrii Pasukhin's picture

Hello,

Thanks for waiting.

I have been attached some code sample to remove entities. It is a sample, in some cases you need to upgrade it.

To do some improve, it is necessary to analyze step graph and removed entity.

Best regards, Dmitrii.

Prajwal Shelar's picture

Thanks Dmitrii, I'll check it out.
Best regards,
Prajwal