Python scripted object as part of a boolean.

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Python scripted object as part of a boolean.

Post by keithsloan52 »

Okay I have a python scripted object and when a user changes one of the parameters the onchange function of the objects class gets
driven and I can perform the appropriate redraw.

Now how do I handle the situation if the object is part of a Boolean? i.e. How do I get the boolean to redraw?
Note: I need to handle this whether the object is part of a Boolean or not and also if there is a hierarchic of booleans.
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Python scripted object as part of a boolean.

Post by ickby »

In general the "onChange" function is only to be used for simple and responsive user feedback, so it should trigger a object recompute only if the redraw is almost instant. It is also not part of the freecad document updates. The real execution logic for objects work without "onChange" but with "execute". Whenever you change a property in your object it gets marked as "to be recomputed" and the recompute button in freecad gets active. Once you hit it the whole document get recomputed, including your object by calling the "execute" method and all other objects that depends on it, like the mentioned booleans.

So to answer your question: use execute instead of onChange.
Post Reply