How to read entity names in STEP files?

Hi!

I want to get the name of the model information in Figure 1.

Now, The information I obtained from other files can be consistent with CAD Assistant, but I cannot obtain such complex information content in this file;

This is my code:

for (TopExp_Explorer exp(aShape, TopAbs_SOLID); exp.More(); exp.Next())
	{
		TopoDS_Solid solid = TopoDS::Solid(exp.Current());
		Handle(Standard_Transient) entity = treader->EntityFromShapeResult(solid, 1);
		if (entity.IsNull()) // as just mapped
		{
			entity = treader->EntityFromShapeResult(solid, -1);
		}else if (entity.IsNull()) // as anything
		{
			entity = treader->EntityFromShapeResult(solid, 4);
		}else if (entity.IsNull())
		{
			cout << "Warning: cannot get entity from shape" << endl;
		}

		auto aReprItem = Handle(StepRepr_RepresentationItem)::DownCast(entity); 
		auto bReprItem = Handle(StepBasic_ProductDefinitionRelationship)::DownCast(entity);
		auto nReprItem = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(entity);
		auto dsReprItem = Handle(StepRepr_ProductDefinitionShape)::DownCast(entity);

		if (!aReprItem.IsNull()) {
			cout << "aReprItem, " << aReprItem->Name()->ToCString() << endl;
		}else if (!bReprItem.IsNull()) {
			cout << "bReprItem, " << bReprItem->Name()->ToCString() << endl;
		}
		else if (!nReprItem.IsNull()) {
			cout << "nReprItem, " << nReprItem->Name()->ToCString() << endl;
		}
		else if (!dsReprItem.IsNull()) {
			cout << "dsReprItem, " << dsReprItem->Name()->ToCString() << endl;
		}
		else if (dsReprItem.IsNull() && nReprItem.IsNull() && bReprItem.IsNull() && 
                 aReprItem.IsNull()) {
			cout << "Warning: unknown entity type " << entity->DynamicType() << endl;
		}
	}

Figure 2 is the entity information obtained by traversing the model.

I have a few questions now:

  1. What is the meaning of the list on the left in CAD Assistant (the information in Figure 1)? My personal understanding is the Solid of the model.
  2. How should I deal with a STEP file like this (Like twin.zip, this is a STEP file)?

Thanks for everyone's reply!

gkv311 n's picture

If you're using STEPCAFControl_Reader for reading STEP file, consider taking a look at XCAFPrs_DocumentExplorer.

sunlin0oo's picture

Thanks your reply!
I have solved the problem of finding the bottom type through the inheritance relationship, and then I can read the corresponding information;