feat: Add Parametric Hatch Generator macro - #199
Conversation
|
If you have a package.xml file you don't want to add your macro to this repo, you want to have your own repo that the Addon Manager pulls it in from. Is this work already hosted in a git host someplace? |
galou
left a comment
There was a problem hiding this comment.
The only requested changes are:
- put the macro into the
ParametricObjectCreationdirectory - remove
package.xml
There was a problem hiding this comment.
This file should be ParametricObjectCreation/HatchGenerator.FCMacro.
| __Communication__ = 'https://forum.freecad.org/viewtopic.php?p=806176#p806176' | ||
| # The __Files__ tag in the main macro is not strictly needed when using package.xml, | ||
| # but it's good practice to list dependencies. | ||
| __Files__ = 'Freecad_Hatch_Generator.py;HatchGenerator_Icon.svg;package.xml' |
There was a problem hiding this comment.
__Files__ = 'HatchGenerator.svg,hatch_generator/hatch_generator.py' (adapt if needed).
There was a problem hiding this comment.
Rename to hatch_generator/hatch_generator.py.
| """ | ||
|
|
||
| # The name of the module to import MUST match the library filename. | ||
| import Freecad_Hatch_Generator |
There was a problem hiding this comment.
from hatch_generator.hatch_generator import runHatchGeneratorDialog
runHatchGeneratorDialog()| It imports the main logic from the library file and launches the GUI. | ||
| """ | ||
|
|
||
| # The name of the module to import MUST match the library filename. |
There was a problem hiding this comment.
Remove the comment, this is a general Python knowledge.
| return | ||
|
|
||
| # 2) Create a brand new parametric object | ||
| tempName = "TempHatchParamObj" |
There was a problem hiding this comment.
Why not create a temporary document for this (tmp_doc = FreeCAD.newDocument(hidden=True, temp=True) and FreeCAD.closeDocument(tmp_doc.Name))?
| tempHatch.BaseObjects = selectedBaseObjs | ||
|
|
||
| # Pattern source: | ||
| if self.patternSourceCombo.currentIndex() == 0: |
There was a problem hiding this comment.
Explain the magic number 0.
| # If "HatchPreview" (or HatchPreview001 etc.) already exist, remove them | ||
| preview_existing = [obj for obj in doc.Objects if obj.Name.startswith("HatchPreview")] | ||
| idx = 0 | ||
| while doc.getObject(previewName): |
There was a problem hiding this comment.
Limit idx to avoid an infinite loop.
| self.doc.recompute() | ||
| FreeCAD.ActiveDocument.commitTransaction() | ||
|
|
||
| QtWidgets.QMessageBox.information( |
There was a problem hiding this comment.
A FreeCAD.Console.PrintMessage should be sufficient on success.
| ) | ||
|
|
||
| except Exception as e: | ||
| FreeCAD.ActiveDocument.abortTransaction() |
There was a problem hiding this comment.
Are nested transactions avoided?
Thanks for the comment @chennes but i'm still still new to how github pull requests are made and they are still a bit quite confusing to me to properply understand all and the right order of things. |
For including a macro into the FreeCAD macros listing you have three mutually-exclusive options:
No matter which option you choose, you should first address @galou 's code review comments above. |
Okay thank you, let me review his comments. |
|
So @chennes when i see a request change, that's the next step to do? i've seen the comments @galou made, quite pertinent ones indeed and i thank him for that, but i'm not so sure what to do from here, like should i open the code on my personal repo and make his suggested changes from there? or should i make the changes he suggestes on the freecadmacro repo? |
|
@chopinregis because your PR has not yet been merged, what you should do is continue working on your add-hatch-generator branch. Any change that you push to that branch will be reflected as part of this PR. So if your plan is to continue with Option 1 as I listed them above, that's your process. Just keep editing this branch, committing the changes to your local copy and then pushing to the remote. Let me know if you need the actual git commands for doing those things. |
|
@chopinregis Any progress on this? |
Hello @galou not yet, but intend to make progress, soon eventually, i have been really caughtup with other major activities that completely overwhelmed me and my attention. |

This pull request adds the Hatch Generator, a new parametric tool for creating complex 2D hatch patterns on Part faces.
Author: @chopinregis
Source Repository: https://github.com/chopinregis/FreeCAD-Parametric-Hatch-Generator
Features:
Part::FeaturePythonobject for hatches.Dependencies:
scipyis required to use the "Voronoi" and "VoronoiMesh" patterns. The macro functions without it but will print a warning if a user selects those patterns.This macro is structured as a multi-file addon with a
package.xmlfor integration with the Addon Manager.