Is this a good Python-FreeCAD script?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
PaulCobbaut
Posts: 26
Joined: Mon Oct 03, 2022 9:29 am

Re: Is this a good Python-FreeCAD script?

Post by PaulCobbaut »

dprojects wrote: Sun Dec 04, 2022 2:03 pm
PaulCobbaut wrote: Sun Dec 04, 2022 12:30 pm I don't know what "import something as" does, still learning Python.
Your code at github not looks like newbie code ;-) You know a lot about FreeCAD and python ;-)
It looks like you are good developer but you want to test us, if we will see all the "mistakes" or not, for me this is a little funny, because I see you are good developer ;-)
Not sure how to react here. I am honestly not 'testing' anyone, I am just eager to learn.

I am 52 and have been a system administrator, not a developer, really. I did try to read a lot about Python, and looked at other people's code. The commenting of code is what I learned from looking at my own bash scripts years after writing them. Also I wrote https://linux-training.be, so I have a bit of experience in documentation :)

I spent a lot of time on FreeCAD the past seven months, but am still definitely a newbie!
dprojects wrote: Sun Dec 04, 2022 2:03 pm Personally, I would change the big-mambo-jumbo create_cup function into several smaller ones to get better control over the code and make the function shorter and clear, but you probably know about it ;-)
That would be a fun exercise to do.
dprojects wrote: Sun Dec 04, 2022 2:03 pm Also at the end there is beauty test flower ;-)

Code: Select all

FreeCADGui.ActiveDocument.ActiveView.fitAll()
without importing FreeCADGui ;-) this will be working as macro at editor maybe but if you move the code as tool "icon" at workbench this will not be working without FreeCADGui import. At FreeCAD it is better to import everything what you use, so the code will be more flexible, mobile, you save your time later, for example if you want to move it as workbench tool.
That is a leftover from when testing the code and looking at the result in the GUI. Will comment it out.
User avatar
dprojects
Posts: 721
Joined: Mon Mar 06, 2017 6:02 pm
Location: Poland
Contact:

Re: Is this a good Python-FreeCAD script?

Post by dprojects »

PaulCobbaut wrote: Sun Dec 04, 2022 8:45 pm I am 52 and have been a system administrator
my own bash scripts years after writing them. Also I wrote https://linux-training.be
If someone can program well in one language, he will also be good at programming in any language. Programming is about problem solving, analytical thinking, not about knowing a language. So, good luck at FreeCAD and welcome on board ;-)

Thanks
Darek
github.com/dprojects

workbench for woodworking is available at: github.com/dprojects/Woodworking
Post Reply