Control: reassign -1 freecad

Using the following hack, I was able to get the fanuc postprocessor to
output G-code.

--- /usr/lib/freecad/Mod/Path/PathScripts/post/fanuc_post.py    2025-10-11 
19:39:13.262502507 +0200
+++ /usr/lib/freecad/Mod/Path/PathScripts/post/fanuc_my_post.py 2025-10-11 
21:45:54.261357653 +0200
@@ -431,17 +431,20 @@
                     continue
 
             # if it's a tap, we rigid tap, so don't start the spindle yet...
+            if hasattr(pathobj, "ToolController") \
+              and hasattr(pathobj.ToolController, "Tool") \
+              and hasattr(pathobj.ToolController.Tool, "ToolType"):
+                tooltype = pathobj.ToolController.Tool.ToolType
+            else:
+                tooltype = "non-tap"
             if command == "M03" or command == "M3":
-                if pathobj.ToolController.Tool.ToolType == "Tap":
+                if tooltype == "Tap":
                     tapSpeed = int(pathobj.SpindleSpeed)
                     continue
 
             # convert drill cycles to tap cycles if tool is a tap
             if command == "G81" or command == "G83":
-                if (
-                    hasattr(pathobj, "ToolController")
-                    and pathobj.ToolController.Tool.ToolType == "Tap"
-                ):
+                if tooltype == "Tap":
                     command = "G84"
                     out += linenumber() + "G95\n"
                     paramstring = ""

This move tool type to a new local variable and only set this if the
ToolType feature is available in FreeCAD.  I do not know in which
version of FreeCAD such tool type string is available, if it used to be
available and have moved location or if it will become available in a
future version of FreeCAD.  For now I assume there is no support for
tapping in FreeCAD, and the code in question in effect just disable such
support in the Fanuc postprocessor.

-- 
Happy hacking
Petter Reinholdtsen

Reply via email to