CAM: Add Machine Library and Editor#26533
Conversation
|
what about #25785 ? |
That was a PoC (Proof of Concept). This one supersedes it. This one has a slightly different machine object structure. The editor updates the object directly instead of updating a dict that then get's converted. This one had some post processor stuff that was added in that's removed for THIS PR that we'll add back in a bit later. The idea is to get this out to everyone for input. |
|
Also, you'll find that this one doesn't have the Machine selector in the template or job at this time. We'll add that back in as we make more progress. This PR doesn't affect ANYTHING functionally at this time. |
maxwxyz
left a comment
There was a problem hiding this comment.
According to https://github.com/FreeCAD/FreeCAD-Enhancement-Proposals/tree/master/FEPs/FEP-0007-consistent-language only buttons should be Title Case, so the labels should all be Sentence case without : at the end.
I really dislike these vertical tab widgets. We've already talked about moving away from them for the operations and using horizontal tabs instead. The tab widget was added here because there are more kinds of CAM assets. The Assets folder is where all of the tools end up already. Fully expect in the future to see vises, tool holders, possibly materials, etc. The tab widget can be removed until necessary though. |
| "suppress_commands": self.processing.suppress_commands, | ||
| "tool_change": self.processing.tool_change, | ||
| "adaptive": self.processing.adaptive, | ||
| "chipbreaking_amount": self.processing.chipbreaking_amount, |
There was a problem hiding this comment.
Why is this defined at the Machine level? Isn't this a property of an operation? Isn't it likely to vary from one op to another?
| } | ||
|
|
||
| # Output options | ||
| data["output"] = { |
There was a problem hiding this comment.
We need to add back the boolean to 'output_bcnc_comments'
I was premature to remove it. Now that I understand what it does, I believe it's valid here.
| data["blocks"] = blocks | ||
|
|
||
| # Processing options | ||
| data["processing"] = { |
There was a problem hiding this comment.
There's two major sections and they pretty closely correspond to the two big phases in postprocessing.
The 'Processing' options correspond to stage 2 and the 'Output' options are used in stage 3 and 4.
So I think this section should keep translate_drill_cycles, split_arcs, suppress_commands, adaptive, tool_before_change, tool_change
show_editor, list_tools_in_preamble, show_op_labels could move to 'output options'
| "line_numbers": self.output.line_numbers, | ||
| "path_labels": self.output.path_labels, | ||
| "machine_name": self.output.machine_name, | ||
| "doubles": self.output.doubles, |
There was a problem hiding this comment.
This 'doubles' property is supposed to be used in suppressing redundant gcode words.
IIRC, there were originally two controls that did this. One suppressed redundant gcode commands (G0, G1, G81) and the other suppressed redundant words within those commands. For example<
G1 X10 Y10 Z10
G1 X10 Y20 Z10
could be flattened to
G1 X10 Y10 Z10
G1 Y10
Or it could be flattened all the way to
G1 X10 Y10 Z10
Y10
Both are valid gcode but people have strong preferences about it.
I think we should have both
'output_double_commands'
'output_double_parameters'
I'm open to better names for these things.
|
|
||
| # Dynamic state (for runtime) | ||
| parameter_functions: Dict[str, Callable] = field(default_factory=dict) | ||
| parameter_order: List[str] = field( |
There was a problem hiding this comment.
I'm skeptical about this.
It doesn't seem like a machine-specific thing. Seems like a postprocessor thing.
Pre-existing. But I’ll change it with next update. :) |
This PR introduces a machine object and a machine library, along with a new machine editor dialog for creating and editing *.fcm machine asset files. The editor is integrated into the CAM preferences panel, with new Python modules for the dialog and minimal model validation. Machine management (add, edit, delete) is now available in the CAM asset preferences panel. Key Features: - Machines now have a type and units property. The machine type can be used to distinguish between different classes of machines (e.g., mill, lathe, laser). - Machine units are stored internally and in the .fcm JSON file as metric. Note: This differs from how toolbits work (which store units in their native units) - Support for 2-5 axis machines. - Support for multiple spindles (up to 9) - Processor defaults - JSON Text Editor with basic validation and line numbers.
Removed explicit colons from all form labels. Fixed lint warnings and replaced wildcard imports with explicit imports for clarity and maintainability. src/Mod/CAM/Path/Machine/ui/editor/machine_editor.py: - Removed ':' from all form labels - Fixed lint warnings (missing docstrings, empty except, etc.) - Replaced wildcard imports with explicit imports src/Mod/CAM/Path/Machine/models/__init__.py: - Updated __all__ and imports for explicit API src/Mod/CAM/Path/Tool/assets/ui/preferences.py: - Updated imports to use package-level import src/Mod/CAM/Path/Machine/models/machine.py: - Added explanatory comments to empty except blocks - Fixed duplicate variable assignment - Added missing class docstrings src/Mod/CAM/CAMTests/TestMachine.py: - Fixed unused variable warning by using returned filepath
added back bcnc comment output
|
@Connor9220 The current HEAD (50c22e1) now fails when I want to change to CAM workbench: No CAM workbench toolbar shows up. I suspect this PR is the cause? I ran |
I just rebuilt from main (cachyOS) and can't duplicate the problem. I also blew away my pixi build directory and ran pixi run configure first. I often have to do this when switching branches or I don't get a clean build. Also, you're rebasing on upstream/main. What changes have you made to your active branch? Anything in CAM? |
|
@karamellpelle I too just did a clean build on Linux with no issues. Could someone else with windows do a build and test? |
I erased the
This is the .py-content of .pixi/envs/default/Library/Mod/CAM/Path/ ( |
|
@karamellpelle I see this I don't see machine_editor.py in your directory structure.. CMakeLists.txt: Path/Machine/ui/editor/machine_editor.py So, the machine_editory.py file IS in the CMakeLists.txt It's like it's not reading your CMakeLists.txt file or something. |
|
Your source tree doesn't match. Try this: git fetch --all (fetch from all repos) |
This is strange. If it works for you, it's good, but maybe keep this in mind if other users gets the same error in the future. |
|
I'm also getting the |
Based on your filepaths, is this Linux or macOS? |
|
Can you guys check your build directory and see if you find these files? ./Mod/CAM/Path/Machine/models/machine.py We might be missing some init files in the CMakeLists.txt file.. can you add the following? Machine/models/init.py I'm not sure WHY my compile works without these.. |
|
I do not have problem described in this issue, but all this files present in FreeCAD/src/Mod/CAM/CMakeLists.txt Lines 173 to 181 in e4eebe5 |
Yea, I'm not sure what's going on. This built and worked fine on a Mac yesterday too. (PIXI) |
|
Those of you having problems with this. Do you have the CAM workbench autoload? What other addons do you have. Again, can you confirm that the python files are in your build director? |
|
Here's my output from According to preferences, CAM workbench is not autoloaded. EDIT: After setting autoload to true and restarting, FreeCAD shows the error in the log window at start. |
|
Try setting it to autoload and restart FC and see if that fixes it. Also what OS and Distro? Paste full info from about page? |
|
Setting CAM wb autoload logs the error: No module named 'Path.Machine.ui' after restart. The preferences window for WBs shows Loaded but the module failed and never loaded fully. This should actually be a new bug report: If a Workbench fails to load, then don't show Loaded. |
|
Here's my Can you reproduce the error on your computer if you clone into a new folder and pixi-build there? Are the module/path names case-sensitive? I don't know Python. |
|
I'm getting this in the app image. Let me look into this. |
|
@karamellpelle Can you change line 929 to this ? and try it again? |
|
There is also no var |
I removed that one.. was old stuff not needed.. |
|
@tarman3 @sliptonic @karamellpelle @jffmichi See if this fixes the issue: #26940 |
|
I did not meet this problem |
Your PR worked on my machine; the error did not show and I was able to create a CAM job :) |
|
@Connor9220 I wanted to add this to the release notes, but I've noticed the following message in the preferences:
So for now, you can define machines, but they can't be used anywhere (only stored in the preferences for reference), right? You can't select them when submitting jobs / selecting postprocessors or anything like that? |
That's correct. We're working on post processors and several other things that needed this code and we didn't want people thinking making changes to the machine would affect things at this time. |
Thanks, I guess I'll wait before adding it to the release notes then. |

This PR introduces a machine object and a machine library, along with a new machine editor dialog for creating and editing *.fcm machine asset files. The editor is integrated into the CAM preferences panel, with new Python modules for the dialog and minimal model validation. Machine management (add, edit, delete) is now available in the CAM asset preferences panel.
Key Features:
Machine Library

Main Machine Editor Screen

Post Processor Parameters

JSON Editor
