pythonocc-core icon indicating copy to clipboard operation
pythonocc-core copied to clipboard

I have get trouble in the use "XCAFDoc_Dimension",I think there is something wrong . & ?

Open ealwen opened this issue 3 years ago • 1 comments

My pythonocc's version is 7.6.2 when I try to get the PMI message(GB&T) stored in my step file,I get the wrong like this:

TypeError: Wrong number or type of arguments for overloaded function 'TDF_Label_FindAttribute'. Possible C/C++ prototypes are: TDF_Label::FindAttribute(Standard_GUID const &,opencascade::handle< TDF_Attribute > &) TDF_Label::FindAttribute(Standard_GUID const &,Standard_Integer const,opencascade::handle< TDF_Attribute > &)

I find their is someting wrong in the class XCAFDoc_Dimension ,it inherite the class object wrongly,I think it should nherite the class OCC.Core.TDF.TDF_Attribute and there is something wrong about class XCAFDoc_GeomTolerance,it show :@classnotwrapped the test-code like this ( my code) :


#!/usr/bin/env python3

from OCC.Core.STEPCAFControl import STEPCAFControl_Reader
from OCC.Core.TCollection import TCollection_ExtendedString
from OCC.Core.TDF import TDF_LabelSequence
from OCC.Core.TDocStd import TDocStd_Document
from OCC.Core.IFSelect import IFSelect_RetDone
from OCC.Core.XCAFDoc import XCAFDoc_DocumentTool_DimTolTool, XCAFDoc_Dimension,XCAFDoc_Datum,XCAFDoc_Dimension_GetID,XCAFDoc_DocumentTool,XCAFDoc_DimTol,XCAFDoc_GeomTolerance
doc = TDocStd_Document(TCollection_ExtendedString("pythonocc-doc"))

filename=r"...\nist_ctc_05.stp"  #my step file 
step_reader = STEPCAFControl_Reader()
step_reader.SetColorMode(True)
step_reader.SetLayerMode(True)
step_reader.SetNameMode(True)
step_reader.SetMatMode(True)
step_reader.SetGDTMode(True)

status = step_reader.ReadFile(filename)

doc = TDocStd_Document(TCollection_ExtendedString("pythonocc-doc"))
step_reader.Transfer(doc)

if status == IFSelect_RetDone:
    step_reader.Transfer(doc)

#PMI,GB&T工具
m_dimTolTool=XCAFDoc_DocumentTool.DimTolTool(doc.Main())
m_dimTolTool=XCAFDoc_DocumentTool_DimTolTool(doc.Main())

#尺寸
DimsionLabels=TDF_LabelSequence()

m_dimTolTool.GetDimensionLabels(DimsionLabels)
print(DimsionLabels.Length())

for i in range(DimsionLabels.Length()):
    aLabel=DimsionLabels.Value(i+1)
    print(aLabel.DumpToString())

    aDimAttr=XCAFDoc_Dimension()
    # aDimAttr.Set(aLabel)
    # aDimAttr.GetObject()
    # aDimTolObj = aDimAttr.GetObject()
    if not aLabel.FindAttribute(XCAFDoc_Dimension.GetID(),aDimAttr):  #the wrong line
        continue
    aDimTolObj=aDimAttr.GetObject()

ealwen avatar Nov 25 '22 13:11 ealwen

I have encountered the same problem, may I ask if you have solved it?

aruig666 avatar May 05 '24 12:05 aruig666