Hello, I'm experimenting a little with some scripting.
My new frontier is to make a standalone FCStd file that is autonomous from the creation script, but, as the document is complex and rely on many expressions stored in a spreadsheet "Dimensions" that do the hard work of automating things and with some documentation in "Documentation" as a bonus to add instructions on what to do with parameters.
This is a working example as it is a "side result" of some jobs I have recently done (more complex things could be obtained).
Note the very different dimension of files, the script and the produced file.
Hoping it will be useful for someone.
I'm interested in some suggestion and "constructive critics".
Regards
Carlo D.
Script to create a proper standalone document with some automation on it
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Script to create a proper standalone document with some automation on it
Last edited by onekk on Sat Dec 10, 2022 9:59 pm, edited 2 times in total.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
-
- Veteran
- Posts: 3192
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Script to create a proper standalone document with some automation on it
Looks to be a simpler template than having to learn about QT i/o. I personally have less interest in tweaking the UI than working on algorithms.
@onekk
@onekk
Re: Script to create a proper standalone document with some automation on it
So you prefer this approach over as example a QtDialog taylor made to input data?edwilliams16 wrote: ↑Fri Dec 09, 2022 12:42 am Looks to be a simpler template than having to learn about QT i/o. I personally have less interest in tweaking the UI than working on algorithms.
@onekk
It is less powerful, but probably with some more research and maybe some "Feature Request" about improving Spreadsheet it could lead to something interesting.
Script could do a very good job on filling spreadsheet cells, I have done more complex things as you could leverage for loop and such things to automate repetitive tasks, thing of filling proper tuning as example to make a shelve or a drawers chest with different drawers front heights.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Script to create a proper standalone document with some automation on it
I have a minor glitch:
If I color a part and then modify a dimension using "Dimensions" spreadsheet, solids are "recalculated" but:
- Shapecolor is not "honoured" and the solids are the "usual grey" (204, 204, 204) in decimal.
- but Shapecolor is correcly set to the desired color, only color is not "re-applied" to the recalculated shape.
I have solved it with this little Macro:
But is a suboptimal solution, as the file is not anymore "standalone"
Regards
Carlo D.
If I color a part and then modify a dimension using "Dimensions" spreadsheet, solids are "recalculated" but:
- Shapecolor is not "honoured" and the solids are the "usual grey" (204, 204, 204) in decimal.
- but Shapecolor is correcly set to the desired color, only color is not "re-applied" to the recalculated shape.
I have solved it with this little Macro:
Code: Select all
import FreeCAD
import FreeCADGui
doc = FreeCAD.ActiveDocument
for obj in doc.Objects:
if obj.TypeId in ('Part::Box', 'Part::Cut'):
color = obj.ViewObject.ShapeColor
obj.ViewObject.ShapeColor = color
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/