PMI annotations reading (TDF_Label.FindAttribute from OCP not working properly)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- computer-graphics
Research direction
Start by running the attached TestOCCT.cpp project with the supplied STEP file and compare its C++ attribute lookup with the Python TDF_Label.FindAttribute call. Inspect the XCAFDoc_Dimension and FindAttribute entry points; done means identifying the binding mismatch or a reliable workaround and documenting the corrected PMI-reading behavior.
Written by the indexing model from the issue text.
Description
Hello,
I'm trying to implement the reading of PMI annotations (Geometrical Dimensions and tolerances) from a step file using OCP.
I have a C++ code that is working fine and that I have already tested:
In my C++ code, I have something like this:
m_gdtTool = XCAFDoc_DocumentTool::DimTolTool(doc->Main());
TDF_LabelSequence labels_datums, label_geoms, label_dims, label_dimTols;
m_gdtTool->GetDatumLabels(labels_datums);
m_gdtTool->GetDimensionLabels(label_dims);
m_gdtTool->GetGeomToleranceLabels(label_geoms);
int datumSize = labels_datums.Length();
int dimSize = label_dims.Length();
int geomSize = label_geoms.Length();
// Dimensional Tolerances
for (int i = 1; i <= dimSize; ++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();
}
}
So, I have translated into python:
labels_datums = TDF_LabelSequence()
labels_dims = TDF_LabelSequence()
labels_geoms = TDF_LabelSequence()
self.gdt_tool.GetDatumLabels(labels_datums)
self.gdt_tool.GetDimensionLabels(labels_dims)
self.gdt_tool.GetGeomToleranceLabels(labels_geoms)
datum_size = labels_datums.Length()
dim_size = labels_dims.Length()
geom_size = labels_geoms.Length()
for i in range(1, dim_size + 1):
label_dim = labels_dims.Value(i)
aDimAttr = XCAFDoc_Dimension()
found = label_dim.FindAttribute(XCAFDoc_Dimension.GetID_s(), aDimAttr)
if found:
aDimObject = aDimAttr.GetObject()
When the execution gets in the line aDimObject = aDimAttr.GetObject() I get this error:
I have verified and compared the label_dim variable in both python and c++ :
python
c++
Do you have any ideas why I'm getting this error?
I suspect that the problem is coming from TDF_Label.FindAttribute method:
I think that for my case it's falling in the third case, and maybe the pybind11 wrapping of this method is not working properly because the generic type?
I'm attaching the c++ project and the step file used to test the reading. The main file is called TestOCCT.cpp
Thank you very much for the attention. Any insight on how to solve this issue or workaround will be highly appreciated!
TestOCCPMI.zip
- Dominant language
- C++
- Stars
- 200
- Forks
- 48
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CadQuery/OCP
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
-
Python 3.14t build Open
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
OCCT8
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Similar issues
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 88/100
QuantStack/git2cpp#187 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
mlcommons/mobile_app_open#1182 ·
-
Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/winget-cli#6547 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·