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!
User avatar
Cuq
Posts: 145
Joined: Tue Jul 06, 2021 10:07 am

Re: GD&T Workbench for FreeCAD

Post by Cuq »

easyw-fc wrote: Thu Mar 16, 2023 2:00 pm Would you mind to develop on FC0.21 next stabile ?
I tested but obviously the code is not compatible with the 0.21

Code: Select all

  File "GDT.py", line 242, in showGrid
    FreeCADGui.Snapper.show()
  File "FreeCAD 0.21\Mod\Draft\draftguitools\gui_snapper.py", line 1570, in show
    toolbar = self.get_snap_toolbar()
  File "FreeCAD 0.21\Mod\Draft\draftguitools\gui_snapper.py", line 1505, in get_snap_toolbar
    action = Gui.Command.get(cmd).getAction()[0]
list index out of range
Something to do with get_snap_toolbar or FreeCADGui.Snapper.show() !
User avatar
Cuq
Posts: 145
Joined: Tue Jul 06, 2021 10:07 am

Re: GD&T Workbench for FreeCAD

Post by Cuq »

Cuq wrote: Fri Mar 31, 2023 1:13 pm
easyw-fc wrote: Thu Mar 16, 2023 2:00 pm Would you mind to develop on FC0.21 next stabile ?
I tested but obviously the code is not compatible with the 0.21

Code: Select all

  File "GDT.py", line 242, in showGrid
    FreeCADGui.Snapper.show()
  File "FreeCAD 0.21\Mod\Draft\draftguitools\gui_snapper.py", line 1570, in show
    toolbar = self.get_snap_toolbar()
  File "FreeCAD 0.21\Mod\Draft\draftguitools\gui_snapper.py", line 1505, in get_snap_toolbar
    action = Gui.Command.get(cmd).getAction()[0]
list index out of range
Something to do with get_snap_toolbar or FreeCADGui.Snapper.show() !
Temporarily solved by modifying Draft\draftguitools\gui_snapper.py

Freecad 0.20

Code: Select all

    def get_snap_toolbar(self):
        """Returns snap toolbar object."""
        mw = Gui.getMainWindow()
        if mw:
            toolbar = mw.findChild(QtGui.QToolBar, "Draft Snap")
            if toolbar:
                return toolbar
        return None
Freecad 0.21

Code: Select all

    def get_snap_toolbar(self):
        """Get the snap toolbar."""

        if not (hasattr(self, "toolbar") and self.toolbar):
            mw = Gui.getMainWindow()
            self.toolbar = mw.findChild(QtGui.QToolBar, "Draft snap")
        if self.toolbar:
            # Make sure the Python generated BIM snap toolbar shows up in the
            # toolbar area context menu after switching back to that workbench:
            self.toolbar.toggleViewAction().setVisible(True)
            return self.toolbar

        # Code required for the BIM workbench which has to work with FC0.20
        # and FC0.21/1.0. The code relies on the Snapping menu in the BIM WB
        # to create the actions.
        self.toolbar = QtGui.QToolBar(mw)
        mw.addToolBar(QtCore.Qt.TopToolBarArea, self.toolbar)
        self.toolbar.setObjectName("Draft snap")
        self.toolbar.setWindowTitle(translate("Workbench", "Draft snap"))
        for cmd in get_draft_snap_commands():
            if cmd == "Separator":
                self.toolbar.addSeparator()
            else:
                action = Gui.Command.get(cmd).getAction()[0]
                self.toolbar.addAction(action)
        return self.toolbar
        

Freecad 0.21 Modified

Code: Select all

    def get_snap_toolbar(self):
        """Get the snap toolbar."""

        if not (hasattr(self, "toolbar") and self.toolbar):
            mw = Gui.getMainWindow()
            self.toolbar = mw.findChild(QtGui.QToolBar, "Draft snap")
        if self.toolbar:
            # Make sure the Python generated BIM snap toolbar shows up in the
            # toolbar area context menu after switching back to that workbench:
            self.toolbar.toggleViewAction().setVisible(True)
            return self.toolbar

        # Code required for the BIM workbench which has to work with FC0.20
        # and FC0.21/1.0. The code relies on the Snapping menu in the BIM WB
        # to create the actions.
        try:
            self.toolbar = QtGui.QToolBar(mw)
            mw.addToolBar(QtCore.Qt.TopToolBarArea, self.toolbar)
            self.toolbar.setObjectName("Draft snap")
            self.toolbar.setWindowTitle(translate("Workbench", "Draft snap"))
            for cmd in get_draft_snap_commands():
                if cmd == "Separator":
                    self.toolbar.addSeparator()
                else:
                    action = Gui.Command.get(cmd).getAction()[0]
                    self.toolbar.addAction(action)
        except:
            return None
        return self.toolbar
        
Last edited by Cuq on Fri Apr 07, 2023 6:19 am, edited 1 time in total.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: GD&T Workbench for FreeCAD

Post by Roy_043 »

Cuq wrote: Fri Mar 31, 2023 2:05 pmFreecad 0.21
This is not the current V0.21 code.
User avatar
Cuq
Posts: 145
Joined: Tue Jul 06, 2021 10:07 am

Re: GD&T Workbench for FreeCAD

Post by Cuq »

There is certainly a newest code . But for me it was the Last Code installed from the Code coming from the weekly-builds : 2023/03/16 19:25:33

https://github.com/FreeCAD/FreeCAD-Bund ... kly-builds
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: GD&T Workbench for FreeCAD

Post by Roy_043 »

You must have made a copy-paste error:

Code: Select all

        try:
        self.toolbar = QtGui.QToolBar(mw)
User avatar
Cuq
Posts: 145
Joined: Tue Jul 06, 2021 10:07 am

Re: GD&T Workbench for FreeCAD

Post by Cuq »

Addition of the Additional symbols :

Derived toleranced feature specification elements
Derived feature -> A ISO 1101 04/2017 Clause 6 and 8.2.2.2.3

Associated toleranced feature specification element
Minimax (Chebyshev) feature -> C ISO 1101 04/2017 8.2.2.2.2
Least squares (Gaussian) feature -> G ISO 1101 04/2017 8.2.2.2.2
Minimum circumscribed feature -> N ISO 1101 04/2017 8.2.2.2.2
Maximum inscribed feature -> X ISO 1101 04/2017 8.2.2.2.2
A.PNG
A.PNG (6.49 KiB) Viewed 1445 times
Note : Works only with Iso-Gps Font
User avatar
easyw-fc
Veteran
Posts: 3629
Joined: Thu Jul 09, 2015 9:34 am

Re: GD&T Workbench for FreeCAD

Post by easyw-fc »

Cuq wrote: Fri Mar 31, 2023 1:13 pm I tested but obviously the code is not compatible with the 0.21
it seems now it is working... thanks for your work :D
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: GD&T Workbench for FreeCAD

Post by Kunda1 »

Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Cuq
Posts: 145
Joined: Tue Jul 06, 2021 10:07 am

Re: GD&T Workbench for FreeCAD

Post by Cuq »

Kunda1 wrote: Sun Apr 16, 2023 2:50 pm @Cuq see https://github.com/FreeCAD/FreeCAD-addo ... 1510361387
Still working on, but not ready to become the official maintainer of this WB.
maxwxyz
Posts: 158
Joined: Sat Dec 31, 2022 2:42 pm
Location: Munich, Germany
Contact:

Re: GD&T Workbench for FreeCAD

Post by maxwxyz »

How can I install this new fork? I cannot find it in the addon manager.
Post Reply