Hi Team, I have created a dimension in creoand exported a step file using AP 242 protocol.
I am trying to get dimension information such as value, Arrowpoints, linePoints, location, name and type of that dimensions.
Below is my function that I worked to get the information
But the only info I am able to get is name and vertex points in mm
After investigation i found getValues function of class XCAFDimTolObjects_DimensionObject which is returing 0.
I have attached cpp file having code as well as image of the dimensions and the properties i am using to export my file from creo.
int getDimensionsData(Handle(TDocStd_Document) document) {
Handle(XCAFDoc_DimTolTool) m_gdtTool = XCAFDoc_DocumentTool::DimTolTool(document->Main());
Handle(XCAFDoc_ShapeTool) m_shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
TDF_LabelSequence labels_datums, label_geoms, label_dims, label_dimTols, label_ding;
m_gdtTool->GetDatumLabels(labels_datums);
m_gdtTool->GetDimensionLabels(label_dims);
m_gdtTool->GetGeomToleranceLabels(label_geoms);
int datumSize = labels_datums.Length(); //getting 0
int dimSize = label_dims.Length(); //getting 1 since only step file have only one dimension
int geomSize = label_geoms.Length(); //getting 0
// Geometric Tolerances
for (int i = 1; i
{
const TDF_Label& label_dim = label_dims.Value(i);
Handle(XCAFDoc_Dimension) aDimAttr;
label_dim.FindAttribute(XCAFDoc_Dimension::GetID(), aDimAttr);
if (!aDimAttr.IsNull())
{
Handle(XCAFDimTolObjects_DimensionObject) aDimObject = aDimAttr->GetObject();
Handle(TCollection_HAsciiString) name = aDimObject->GetPresentationName();
if (!name)
name = aDimObject->GetSemanticName();
double val = aDimObject->GetValue(); // getting 0.0000000000000000
double lowerTolVal = aDimObject->GetLowerTolValue(); // getting 0.0000000000000000
double lowerBoundVal = aDimObject->GetLowerBound(); // getting 0.0000000000000000
double upperTolVal = aDimObject->GetUpperTolValue(); // getting 0.0000000000000000
double upperBound = aDimObject->GetUpperBound(); // getting 0.0000000000000000
gp_Pnt lowerBoun = aDimObject->GetPoint(); // getting x,y,z as 0.0000000000000000
gp_Pnt lowerBou = aDimObject->GetPoint2(); // getting x,y,z as 0.0000000000000000
gp_Pnt lowerBo = aDimObject->GetPointTextAttach(); // getting x,y,z as 0.0000000000000000
gp_Dir Dir;
double a = aDimObject->GetDirection(Dir);
XCAFDimTolObjects_DimensionType dimType = aDimObject->GetType(); //DimensionType_DimensionPresentation
XCAFDimTolObjects_DimensionQualifier dimQualifier = aDimObject->GetQualifier(); //XCAFDimTolObjects_DimensionQualifier_None
Handle(TColStd_HArray1OfReal) vals = aDimObject->GetValues();
if (vals)
{
int length = vals->Length();
if (length)
{
double dval = vals->Value(length - 1);
}
}
if (name)
{
TCollection_AsciiString ascNameStr = name->String(); //getting name "dd1" as given in creo
std::wstring nameStr = StrTool::str2wstr(ascNameStr.ToCString());
// Get shape
TDF_LabelSequence fir, sec;
m_gdtTool->GetRefShapeLabel(label_dim, fir, sec);
GDT_Item* gdt = nullptr;
//getting points in mm
//p1 = x:0.0 y:26632.637026440600 z:16798.487548626999
//p2 = x:7492.7460000000001 y:26632.637026440600 z:16798.487548626999
gp_Pnt p1, p2;
for (int j = 1; j
{
const TDF_Label& label_shape = fir.Value(1);
const TopoDS_Shape& shape = m_shapeTool->GetShape(label_shape);
TopAbs_ShapeEnum shapetype = shape.ShapeType();
TopExp_Explorer expFace;
int n = 1;
for (expFace.Init(shape, TopAbs_VERTEX); expFace.More(); expFace.Next()) {
TopoDS_Vertex aVertex = TopoDS::Vertex(expFace.Current());
if (n == 1) {
p1 = BRep_Tool::Pnt(aVertex);
}
else {
p2 = BRep_Tool::Pnt(aVertex);
}
++n;
}
const gp_Trsf& trsf = m_shapeTool->GetLocation(label_shape).Transformation();
NCollection_IndexedDataMap dimmap;
m_gdtTool->GetGDTPresentations(dimmap);
bool val = dimmap.IsEmpty();
int val2 = dimmap.Size();
}
for (int j = 1; j
{
const TDF_Label& label_shape = sec.Value(1);
const TopoDS_Shape& shape = m_shapeTool->GetShape(label_shape);
//gdt->AddShape(shape);
}
}
return 0;
}
}
}