One object cannot update another
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
One object cannot update another
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.
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.
Working on...
https://github.com/iplayfast/CycloidGearBox
https://github.com/iplayfast/CycloidGearBox
Re: One object cannot update another
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.
Re: One object cannot update another
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.
Working on...
https://github.com/iplayfast/CycloidGearBox
https://github.com/iplayfast/CycloidGearBox
Re: One object cannot update another
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.
Re: One object cannot update another
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?
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?
Working on...
https://github.com/iplayfast/CycloidGearBox
https://github.com/iplayfast/CycloidGearBox
Re: One object cannot update another
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.
Re: One object cannot update another
Exactly. So how to cause this effect? Some of the calculations are CPU intensive and make no sense to do key by key.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.
Working on...
https://github.com/iplayfast/CycloidGearBox
https://github.com/iplayfast/CycloidGearBox
Re: One object cannot update another
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.
Re: One object cannot update another
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.
Working on...
https://github.com/iplayfast/CycloidGearBox
https://github.com/iplayfast/CycloidGearBox