-
Notifications
You must be signed in to change notification settings - Fork 152
feat: Add Parametric Hatch Generator macro #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only requested changes are:
- put the macro into the
ParametricObjectCreation
directory - remove
package.xml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__Files__ = 'HatchGenerator.svg,hatch_generator/hatch_generator.py'
(adapt if needed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limit idx
to avoid an infinite loop.
self.doc.recompute() | ||
FreeCAD.ActiveDocument.commitTransaction() | ||
|
||
QtWidgets.QMessageBox.information( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A FreeCAD.Console.PrintMessage
should be sufficient on success.
) | ||
|
||
except Exception as e: | ||
FreeCAD.ActiveDocument.abortTransaction() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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::FeaturePython
object for hatches.Dependencies:
scipy
is 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.xml
for integration with the Addon Manager.