Learn Python in FreeCAD: 07 Refactoring, functions, while loop clash detection. Macro Scripting

preview_player
Показать описание
Part 7 covers refractoring our code into function blocks reducing and optimising our code. We learn about variable scope and then implement the while loop to make our clash / collision detection real time. Using FreeCAD 0.19 or above this beginners series helps you learn the python language from the ground up by building macros to solve real world problems.

Learning the Python language in freeCAD for beginners series we will take you through understanding the python language but with a FreeCAD twist.

In our next video we further optimise our code and learn about the python collection type 'dictionary'. We will use this to keep tract of what objects have collided and use this to colour the individual object

PART 8: Check back next Sunday !

#FreeCAD , #CAD , #Python
Journey with me and

Donate:

Subscribe:

Browse my Redbubble Shop:
Рекомендации по теме
Комментарии
Автор

Your tutorials are a good idea and well done. Keep it up and thank you.

eddrake
Автор

Thank you very much! Thanks a lot for your effort. You deserve more than a Coffe.

atabodur
Автор

Good sir: i have been enjoying this series immensely.
But I must confess to a specific need: To wit, import measurements from a database to construct an irregular block.
Imagine a chunk of baseboard trim with an inside corner on one side, and an outside corner on the other. The walls aren't plumb, and the corners aren't 90 degrees, so there are a bunch of measurements.
The math is not the problem, I've cut trim for the Emperor of Japan. (and I've learned that Freecad will do trig functions like a rental.)
Yet for various reasons, I must create a 3D model of our piece of baseboard.
My approach... and please feel free to suggest a better solution... is to draw the front face in XZ, set back a datum plane by the thickness of the trim and draw the back face. Loft. Then use a longer pad of the actual trim profile to cut with the "and" button.
So. My questions are:
Can I learn how to do it with this series?
In no, can you point me in the right direction.
If no, can you suggest a better approach.

tedwakefield
Автор

Do you know why the causes FreeCAD to crash, I think there is something wrong with this function

amirclash
Автор

so, I get that the rest of the script does not "see" the green variable when it is inside the function, but I do not get (and did not expect that behavior neither) that the function "sees" the green variable if it was defined previously to the definition of it. I thought that the function would be completely isolated from the outside variables. As it is not the case, if the function uses a variable E.G. green, and inside of the function (inside def) you say green= (1.0, 0.0, 0.0) the green outside of the function will keep the original value of (0.0, 1.0, 0.0) and only inside the function it will act as a variable with another value? I am correct?. oh if thats the case and I understood correctly, why this behavior is desired? (of being able of seen external variables inside the function) Thanks a lot for the videos, I finished the 7 videos in one afternoon (and I still have some to watch :D ) they are great!

francootaola
welcome to shbcf.ru