One object cannot update another

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
iplayfast
Posts: 256
Joined: Sat Sep 07, 2019 6:55 am

One object cannot update another

Post by iplayfast »

I'm trying to split things out of my cycloidal gearbox to make it a bit more readable, and have somehow introduced a bug that I can't figure out. Any help is appreciated. I'm using FreeCad 19, fresh compile.

To reproduce (assuming a linux box)
cd ~/.FreeCAD/Mod
git clone https://github.com/iplayfast/CycloidGearBox.git
cd CycloidGearBox
git checkout splitfiles
start up free cad

you will have new CycloidGearBox workbench, select it.
The toolbar will have one orange icon, click it.
You should see a new document and the gearbox showing up.

The way it works is GearBoxParameters holds all the parameters of the gearbox, as all the parts need to reference common values.
If you change a parameter in GearBoxParameters the model changes (and all the subparts properties reflect the change).

For example, changing the GearBoxParameters.pin_disk_diameter to 30 will make the outer disk small.
If you look at the pin_disk.pin_disk_diameter it will be also set to 30.
So far so good.

The bugs
1. If you change pin_disk.pin_disk_diameter the GearBoxParameters.pin_disk_diameter is updated, but the model doesn't change. (even forcing recalculation doesn't update the model).

2. Changing the value in any property shouldn't cause the recalculate until enter is pushed.

again thanks for any help you can give.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: One object cannot update another

Post by chrisb »

Is this rather about Python programming? If so I would move it to the corresponding forum.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
iplayfast
Posts: 256
Joined: Sat Sep 07, 2019 6:55 am

Re: One object cannot update another

Post by iplayfast »

It is about python programming, but related to how objects work within freecad. If there is a better forum please feel free to move it.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: One object cannot update another

Post by chrisb »

I moved it to the Python forum. It may find more attention there.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
vanuan
Posts: 539
Joined: Wed Oct 24, 2018 9:49 pm

Re: One object cannot update another

Post by vanuan »

chrisb wrote: Wed Sep 16, 2020 7:28 am I moved it to the Python forum. It may find more attention there.
Offtopic: maybe "Python scripting and macros" should be split into "users > addon showcase & user requests" and "developers > addon development and code". This clearly belongs to "development"
User avatar
iplayfast
Posts: 256
Joined: Sat Sep 07, 2019 6:55 am

Re: One object cannot update another

Post by iplayfast »

I think the question I have, (trying to boil it down) is
If my the python code updates
FreeCAD.getDocument('Unnamed').getObject('GearBoxParameters').pin_disk_diameter = '31 mm'

Nothing happens,

But if I put that in the console it updates.

I don't understand why.

Also, why is it that entering a number for a length immediately changes the length, shouldn't it wait until the return key is pushed?
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: One object cannot update another

Post by chrisb »

iplayfast wrote: Thu Sep 17, 2020 6:37 am Also, why is it that entering a number for a length immediately changes the length, shouldn't it wait until the return key is pushed?
Some input fields cause an immediate change of the corresponding object. However, they don't trigger a recompute. You can see this with a Part cube being a member of a union. If you change e.g. the length of the cube, it changes on every keypress. The union recompute is delayed until enter is pressed.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
iplayfast
Posts: 256
Joined: Sat Sep 07, 2019 6:55 am

Re: One object cannot update another

Post by iplayfast »

chrisb wrote: Thu Sep 17, 2020 10:09 am Some input fields cause an immediate change of the corresponding object. However, they don't trigger a recompute. You can see this with a Part cube being a member of a union. If you change e.g. the length of the cube, it changes on every keypress. The union recompute is delayed until enter is pressed.
Exactly. So how to cause this effect? Some of the calculations are CPU intensive and make no sense to do key by key.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: One object cannot update another

Post by chrisb »

It seems to be fast enough for the basic primitives. If the same technique is used for rather complicated things, such as pads or pockets, there usually is - or should be! - a checkbox "Update view" or similar.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
iplayfast
Posts: 256
Joined: Sat Sep 07, 2019 6:55 am

Re: One object cannot update another

Post by iplayfast »

chrisb wrote: Thu Sep 17, 2020 4:17 pm It seems to be fast enough for the basic primitives. If the same technique is used for rather complicated things, such as pads or pockets, there usually is - or should be! - a checkbox "Update view" or similar.
I feel that you are trying to help me, but I don't understand how this leads me to a coding solution. The python code I'm talking about does shape creations, and pads as needed for a rather complex set of objects. The best solution would be to set a variable to not update the property until the enter key is pressed. I don't know of such a variable.
Post Reply