Python API Question

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
onekk
Veteran
Posts: 6208
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Python API Question

Post by onekk »

Aleks wrote: Fri Apr 29, 2022 4:59 pm
wmayer wrote: Fri Apr 29, 2022 1:59 pm This works for me without any problems
I am using the partdesign object

Code: Select all

box = FreeCAD.ActiveDocument.addObject("PartDesign::FeatureAdditivePython","PDBox")
pdboxx.PDBox(box)
pdboxx.PDBoxViewProvider(box.ViewObject)
active_body.addObject(box)
Maybe that is the reason why is does not work.
Maybe if there are not errors, some .recompute() on the Active document could trigger the recomputing, I've noted that sometimes, changing a "property" of an object is not triggering a "recompute" but I've not played with PartDesign Objects a part for some test some time ago.

My two cents.

Regards

Carlo D.
Last edited by onekk on Fri Apr 29, 2022 5:19 pm, edited 1 time 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/
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Python API Question

Post by wmayer »

Aleks wrote: Fri Apr 29, 2022 4:59 pm I am using the partdesign object
Doesn't make a difference for me. It works perfectly, too.
User avatar
Aleks
Posts: 309
Joined: Sun Mar 08, 2020 5:27 pm
Location: Bonn, Germany
Contact:

Re: Python API Question

Post by Aleks »

I will investigate it and isolate the code bit by bit. I will post here once I have found the root cause.
FreeCAD als Maschinenbauer in die Konstruktion und Fertigung integrieren. Schulung buchen: www.alsado.de/freecad-schulungen
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Python API Question

Post by TheMarkster »

wmayer wrote: Fri Apr 29, 2022 1:59 pm This works for me without any problems:

Code: Select all

obj.ViewObject.Proxy = 1
Also when changing the properties in the editor the box will be correctly updated.
What is the difference between obj.ViewObject.Proxy = 1 and obj.ViewObject.Proxy = 0?
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Python API Question

Post by wmayer »

TheMarkster wrote: Sat Apr 30, 2022 3:04 pm What is the difference between obj.ViewObject.Proxy = 1 and obj.ViewObject.Proxy = 0?
There is no difference. When not using a real proxy class as view provider then it's only important to set a value different to None.
User avatar
Aleks
Posts: 309
Joined: Sun Mar 08, 2020 5:27 pm
Location: Bonn, Germany
Contact:

Re: Python API Question

Post by Aleks »

The problem I had was probably caused because the Macro does not automatically reload upon change. I had other problems that also seemed random, but after understanding that I need to restart FreeCAD for Macro changes to take effect, I did not run into these issues anymore.
FreeCAD als Maschinenbauer in die Konstruktion und Fertigung integrieren. Schulung buchen: www.alsado.de/freecad-schulungen
Post Reply