GD&T Workbench for FreeCAD

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
juanvanyo
Posts: 16
Joined: Sat Dec 10, 2016 12:14 am
Location: Spain

Re: GD&T Workbenk for FreeCAD

Post by juanvanyo »

ickby wrote:
NormandC wrote:It's a pity though that this info will surely be lost at STEP export as I doubt FreeCAD's STEP exporter supports this.
Actually occ step importer does super it, and i suppose exporter too. So with some work it should be possible to include it in step. But don't know if it is somehow possible to make this available for modules if there is no gd&t data type in the part workbench, where the exporter lives.

https://www.opencascade.com/comment/19633

Great work by the way!
It is True. One of the future works should be to export the step format. If anyone could help, I would be grateful.
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: GD&T Workbench for FreeCAD

Post by Jee-Bee »

It would be nice if this workbench/ functions are accessible everywhere. since it are basic functions in a CAD package.
And of course automatically added by Techdraw :D

More for phase 2 i think
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: GD&T Workbenk for FreeCAD

Post by easyw-fc »

juanvanyo wrote: It is True. One of the future works should be to export the step format. If anyone could help, I would be grateful.
you can have a look at the STEP improvements here:
https://forum.freecadweb.org/viewtopic. ... 24#p166173
just follow the author work... he is doing a lot for STEP improvements and the next step will be the exporter for hierarchy

Maurice
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: GD&T Workbench for FreeCAD

Post by triplus »

Looking good.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: GD&T Workbench for FreeCAD

Post by wandererfan »

Downloaded from here: https://github.com/juanvanyo/FreeCAD-GDT approx 17:45UTC today.
1) Select face on Part::Cube
2) Press "Add Annotation Plane"

Code: Select all

Running the Python command 'dd_annotationPlane' failed:
Traceback (most recent call last):
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/annotationPlane.py", line 39, in Activated
    gdt.activate(idGDT = self.idGDT, dialogTitle=self.toolTip, dialogIconPath=self.iconPath, endFunction=self.Activated, dictionary=self.dictionary)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1392, in activate
    self.taskDialog = GDTDialog( self.dialogTitle, self.dialogIconPath, self.idGDT, extraWidgets + self.dialogWidgets, self.ContainerOfData)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1398, in __init__
    self.createForm()
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1402, in createForm
    self.form = GDTGuiClass( title, idGDT, dialogWidgets, ContainerOfData)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1422, in __init__
    self.initUI( self.title , self.idGDT, self.ContainerOfData)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1430, in initUI
    w = widg.generateWidget(self.idGDT,self.ContainerOfData)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1536, in generateWidget
    FreeCADGui.Snapper.grid.set()

'NoneType' object has no attribute 'set'
Same result with padded sketch.

wf

OS: Ubuntu 12.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10950 (Git)
Build type: debug
Branch: master
Hash: 6368b2f822cf838ee6c50ebf62480ff86c214317
Python version: 2.7.3
Qt version: 4.8.1
Coin version: 3.1.3
OCC version: 7.1.0
juanvanyo
Posts: 16
Joined: Sat Dec 10, 2016 12:14 am
Location: Spain

Re: GD&T Workbench for FreeCAD

Post by juanvanyo »

wandererfan wrote:Downloaded from here: https://github.com/juanvanyo/FreeCAD-GDT approx 17:45UTC today.
1) Select face on Part::Cube
2) Press "Add Annotation Plane"

Code: Select all

Running the Python command 'dd_annotationPlane' failed:
Traceback (most recent call last):
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/annotationPlane.py", line 39, in Activated
    gdt.activate(idGDT = self.idGDT, dialogTitle=self.toolTip, dialogIconPath=self.iconPath, endFunction=self.Activated, dictionary=self.dictionary)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1392, in activate
    self.taskDialog = GDTDialog( self.dialogTitle, self.dialogIconPath, self.idGDT, extraWidgets + self.dialogWidgets, self.ContainerOfData)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1398, in __init__
    self.createForm()
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1402, in createForm
    self.form = GDTGuiClass( title, idGDT, dialogWidgets, ContainerOfData)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1422, in __init__
    self.initUI( self.title , self.idGDT, self.ContainerOfData)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1430, in initUI
    w = widg.generateWidget(self.idGDT,self.ContainerOfData)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1536, in generateWidget
    FreeCADGui.Snapper.grid.set()

'NoneType' object has no attribute 'set'
Same result with padded sketch.

wf

OS: Ubuntu 12.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10950 (Git)
Build type: debug
Branch: master
Hash: 6368b2f822cf838ee6c50ebf62480ff86c214317
Python version: 2.7.3
Qt version: 4.8.1
Coin version: 3.1.3
OCC version: 7.1.0
Does the Draft module work properly?

FreeCADGui.Snapper.grid.set() is used to show the grid from Draft module

OS: Mac OS X
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6706 (Git)
Build type: Release
Branch: tag: 0.16.6706
Hash: f86a4e411ff7848dea98d7242f43b7774bee8fa0
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.8.0.oce-0.17
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: GD&T Workbench for FreeCAD

Post by yorik »

@juanvanyo you must verify that the grid exists before calling its set() method:

Code: Select all

if hasattr(Gui,"Snapper"):
    if Gui.Snapper.grid:
        Gui.Snapper.grid.set()
juanvanyo
Posts: 16
Joined: Sat Dec 10, 2016 12:14 am
Location: Spain

Re: GD&T Workbench for FreeCAD

Post by juanvanyo »

yorik wrote:@juanvanyo you must verify that the grid exists before calling its set() method:

Code: Select all

if hasattr(Gui,"Snapper"):
    if Gui.Snapper.grid:
        Gui.Snapper.grid.set()
I do it in my showGrid() method.

Code: Select all

def showGrid():
    if hasattr(FreeCADGui,"Snapper"):
        if FreeCADGui.Snapper.grid:
            if FreeCADGui.Snapper.grid.Visible == False:
                FreeCADGui.Snapper.grid.reset()
                FreeCADGui.Snapper.grid.on()
                FreeCADGui.Snapper.forceGridOff=False
        else:
            FreeCADGui.Snapper.show()
Those method is called when I activate Add Annotation Plane command, but now also I've added it before calling the set() method

Code: Select all

if hasattr(FreeCADGui,"Snapper"):
	if FreeCADGui.Snapper.grid:
		FreeCAD.DraftWorkingPlane.alignToPointAndAxis(self.ContainerOfData.PointWithOffset, self.ContainerOfData.Direction, 0.0)
		FreeCADGui.Snapper.grid.set()
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: GD&T Workbench for FreeCAD

Post by wandererfan »

juanvanyo wrote:Does the Draft module work properly?
Yes, Draft seems to work fine.

Got farther with new version. Do you want issues created on your github?

1) Select face on Part::Cube
2) add annotation plane
3) press "Add Datum Feature" in toolbar
4) press "Add Datum Feature" in TaskView

Code: Select all

Traceback (most recent call last):
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1171, in updateData
    fp.circumferenceBool = True if (True in [l.Closed for l in fp.faces[0][0].Shape.getElement(fp.faces[0][1]).Edges] and len(fp.faces[0][0].Shape.getElement(fp.faces[0][1]).Vertexes) == 2) else False
<type 'exceptions.TypeError'>: must be string, not tuple
Traceback (most recent call last):
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1451, in createObject
    obj = makeDatumFeature(self.textName, self.ContainerOfData)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 834, in makeDatumFeature
    makeAnnotation(ContainerOfData.faces, ContainerOfData.annotationPlane, DF=obj, GT=[])
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1243, in makeAnnotation
    obj.p1 = (obj.faces[0][0].Shape.getElement(obj.faces[0][1]).CenterOfMass).projectToPlane(obj.AP.PointWithOffset, obj.AP.Direction)
TypeError: must be string, not tuple
juanvanyo
Posts: 16
Joined: Sat Dec 10, 2016 12:14 am
Location: Spain

Re: GD&T Workbench for FreeCAD

Post by juanvanyo »

wandererfan wrote:
juanvanyo wrote:Does the Draft module work properly?
Yes, Draft seems to work fine.

Got farther with new version. Do you want issues created on your github?

1) Select face on Part::Cube
2) add annotation plane
3) press "Add Datum Feature" in toolbar
4) press "Add Datum Feature" in TaskView

Code: Select all

Traceback (most recent call last):
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1171, in updateData
    fp.circumferenceBool = True if (True in [l.Closed for l in fp.faces[0][0].Shape.getElement(fp.faces[0][1]).Edges] and len(fp.faces[0][0].Shape.getElement(fp.faces[0][1]).Vertexes) == 2) else False
<type 'exceptions.TypeError'>: must be string, not tuple
Traceback (most recent call last):
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1451, in createObject
    obj = makeDatumFeature(self.textName, self.ContainerOfData)
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 834, in makeDatumFeature
    makeAnnotation(ContainerOfData.faces, ContainerOfData.annotationPlane, DF=obj, GT=[])
  File "/home/user/.FreeCAD/Mod/FreeCAD-GDT/GDT.py", line 1243, in makeAnnotation
    obj.p1 = (obj.faces[0][0].Shape.getElement(obj.faces[0][1]).CenterOfMass).projectToPlane(obj.AP.PointWithOffset, obj.AP.Direction)
TypeError: must be string, not tuple
Hi wandererfan, I can not reproduce your problem. Can you enter the following lines in the Python console?

Code: Select all

import GDT
GDT.getAllAnnotationObjects()[0].faces
Example result: [(<Part::PartFeature>, 'Face3')]

This indicate that I selected the Face3 of Part piece when I tried to create the new Datum Feature.

And if you select the Face3 and Face6 the result is: [(<Part::PartFeature>, 'Face3'), (<Part::PartFeature>, 'Face6')]

I use that for the annotation to begin in the center of mass of the first selected face, so that if that face is modified, the starting point will be modified to the new mass center.

If you insert the lines that I mentioned to you and you get a result similar to mine, you should not have problems when running those lines since the value of "fp.faces [0] [1]" is a String.

And, of course you can create these issues on my github.
Post Reply