mayo icon indicating copy to clipboard operation
mayo copied to clipboard

Marking of Geometric tolerance

Open akjay opened this issue 1 year ago • 17 comments

Hi,is there a plan to develop a feature of marking geometric tolerance,like the CAD Assistant does.Or the OCCT supply a read to use function to do this? image

akjay avatar Aug 12 '22 01:08 akjay

CAD Assistant is using OpenCascade's "PMI Visualization Technology" commercial component. That said OpenCascade has some free tools to support GD&T data when reading/writing STEP files. Main class XCAFDoc_DimTolTool even provides basic representations of GD&T data as BRep shapes. Just displaying thoses shapes would be better than nothing.

HuguesDelorme avatar Aug 12 '22 08:08 HuguesDelorme

CAD Assistant is using OpenCascade's "PMI Visualization Technology" commercial component. That said OpenCascade has some free tools to support GD&T data when reading/writing STEP files. Main class XCAFDoc_DimTolTool even provides basic representations of GD&T data as BRep shapes. Just displaying thoses shapes would be better than nothing.

While,use OCAF tool,I can read GD&T data from STEP file, but how to display it?For dimensions, the library supply classes under PrsDim folder to add an AIS_InteractiveObject created from selected shapes to show length,angular or other dimension types.

akjay avatar Aug 12 '22 09:08 akjay

  1. Call XCAFDoc_DimTolTool::GetDimensionLabels() to get the list of dimension labels
  2. For each dimension label retrieve the attached XCAFDoc_Dimension attribute
  3. Call XCAFDoc_Dimension::GetObject() to retrieve XCAFDimTolObjects_DimensionObject instance
  4. Retrieve the graphical presentation as a BRep shape by calling XCAFDimTolObjects_DimensionObject::GetPresentation()
  5. The shape can be displayed with AIS_Shape directly

HuguesDelorme avatar Aug 12 '22 10:08 HuguesDelorme

Thank you, I just called the GetGDTPresentations function to get all TopoDS_Shape for the GD&T,the Display it out, it workd well,but can not move when drag,seems have much work to do for this.

akjay avatar Aug 12 '22 10:08 akjay

If you want to move the dimensions 3D objects with the mouse then yes it requires some work.

HuguesDelorme avatar Aug 12 '22 10:08 HuguesDelorme

There is a question, if I add some geometric tolerance information,how to compute the presentation manually?Dose occ support some function to do this,did not seen any information about this in the user_guide?Do you have some advise?

akjay avatar Aug 16 '22 12:08 akjay

Is the presentation should be draw by myself,the occ did not provide a tool to draw this except pmi visualization commercial module?

akjay avatar Aug 19 '22 03:08 akjay

Actually after adding some GD&T information to a document, you would like to draw the representation shape but it's not available(because it's new) ?

HuguesDelorme avatar Aug 19 '22 09:08 HuguesDelorme

Yes,for the STEP file imported in before,I can show presentations for these GD&Ts because they are part of ap242 file and maybe already drawn by other software,so the function can get TopoDS_Shape and show it.But if add a new definition,the presentation need to draw by self because occ did not provide a function to do this(maybe I didn't find it),if I save this file,only GD&T information can be stored in ap242 schema,no presentation since it has not been drawn. And I even try define a GD&T through SolidWorks2021 and published use ap242,then imported in occ and try to read it's presentation,still failed with only part of the presentation shown like only an arrow but missing other parts.But if I use SolidWorks itself to read this file,it can be shown correctly,maybe each software has a different implement for the ap242 protocol? But it seems that if I draw some presentation for the GD&T defined in occ and save it with ap242_dis schema,the open it with SolidWorks2021,it can be shown correctly.

akjay avatar Aug 19 '22 09:08 akjay

I guess SolidWorks doesn't use the GD&Ts shape representations available in the STEP file but rather create its own representation/graphics. This is surely what is also providing OpenCascade "PMI Visualization Technology" commercial component.

HuguesDelorme avatar Aug 19 '22 09:08 HuguesDelorme

Eh,I found a tool named SFA in opencascade website told that can process STEP files. And I tried with my model drawn by Solidworkd 2021,pictures below show the GD&T representation in different software. 1.Solidworks 2021 open a AP242 file with PMI enabled solidworks

2.CAD Assistant with PMI commercial component [missing some infomation] CAD-Assiatant-with-pmi-commercial-component

3.CAD Assistant without PMI commercial component [can not show ] CAD-Assiatant-without-pmi-commercial-component

4.SFA sfa

While the SFA show the GD&T infos same with Solidworks,so I guess they are should be read from AP242 files not draw by Solidworks itself, and this indicate that when Solidworks publish a AP242 file, the GD&T representation is well saved with standard ap242 protocol and can be readout by other software like OpenCASCADE(because SFA is based on OpenCASCADE),I try to read the SFA source code to find how it draw the GD&T representation but it write with tcl language which is not my domain,and can not understant.

Do you have any idea?Or the SFA use other technology to achieve this?

Need your help.

Attach is my test STP file. part4.zip

akjay avatar Aug 23 '22 11:08 akjay

Where is the SFA source code ?

HuguesDelorme avatar Aug 23 '22 15:08 HuguesDelorme

Here is the source code

akjay avatar Aug 24 '22 02:08 akjay

@akjay Can you share your code? Using the OpenCascade for reading the GD&T and displaying it out, Thank you!

cz-source avatar Oct 19 '22 06:10 cz-source

@akjay Can you share your code? Using the OpenCascade for reading the GD&T and displaying it out, Thank you!

Use this. 1.Call XCAFDoc_DimTolTool::GetDimensionLabels() to get the list of dimension labels 2.For each dimension label retrieve the attached XCAFDoc_Dimension attribute 3.Call XCAFDoc_Dimension::GetObject() to retrieve XCAFDimTolObjects_DimensionObject instance 4.Retrieve the graphical presentation as a BRep shape by calling XCAFDimTolObjects_DimensionObject::GetPresentation() 5.The shape can be displayed with AIS_Shape directly

akjay avatar Oct 19 '22 10:10 akjay

@akjay Use this. 1.Call XCAFDoc_DimTolTool::GetDimensionLabels() to get the list of dimension labels 2.For each dimension label retrieve the attached XCAFDoc_Dimension attribute 3.Call XCAFDoc_Dimension::GetObject() to retrieve XCAFDimTolObjects_DimensionObject instance 4.Retrieve the graphical presentation as a BRep shape by calling XCAFDimTolObjects_DimensionObject::GetPresentation() 5.The shape can be displayed with AIS_Shape directly

Thank you. When I used PythonOCC for step 2, there was a problem. Maybe it's the version.

cz-source avatar Oct 20 '22 06:10 cz-source

I'm using C++, not know how to do this with PythonOCC.

akjay avatar Oct 20 '22 09:10 akjay