Ticket #6266: recompute undos removeSplitter

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Ticket #6266: recompute undos removeSplitter

Post by Kunda1 »

issue #6266: recompute undos removeSplitter
When calling `move`, the object moves, then I call `obj.Shape.removeSplitter()` and `doc.recompute` and the shifted box is unmoved.

Execute the following in the Python console:

Code: Select all

from freecad import app as FreeCAD

import Draft

doc = FreeCAD.newDocument("testDoc")
box1 = doc.addObject("Part::Box", "Box1")
doc.recompute()
box2 = Draft.move(box1, FreeCAD.Vector(1, 0, 0), copy=True)
box2.Shape = box2.Shape.removeSplitter()

doc.recompute()
Last edited by Kunda1 on Sat Jun 25, 2022 6:44 pm, edited 1 time in total.
Reason: Added GH ticket number to thread title
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #4754: recompute undos removeSplitter

Post by Kunda1 »

@openbrain responds
openbrain wrote: the problem is that you're not authorized to override a Shape property. You should use a new object.
I tested and there seems to me that there are 2 problem though : 1) the rendered shape is temporarily overridden (before change is rejected) + 2) trying to assign a new shape resets the Placement property -- this is what you see --
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Ticket #4754: recompute undos removeSplitter

Post by openBrain »

Kunda1 wrote: Mon Jan 24, 2022 8:17 pm @openbrain responds
Are you expecting something specific from this thread ?
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #4754: recompute undos removeSplitter

Post by Kunda1 »

was just making it more convenient to read ;)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Ticket #4754: recompute undos removeSplitter

Post by adrianinsaval »

I think this is expected behavior so it should probably be closed. When performing such operations on the shape it's unreasonable to expect them to remain after a recompute, recompute recreates the shape using the feature's method with the properties of the object, it cannot know what additional operations the user performed directly on the shape through the python interface. As was said in the tracker if the user wants to keep the modified shape he needs to create a new object to store it.
A feature request could be made for a parametric refine but that should probably be done in a new well written ticket if it doesn't exist already.


Edit: ignore, i missinterpreted the issue as the refniment being lost after recompute but this was not the case at all. regarding a parametric refine feature, it's likely not necessary because AFAIK most parametric features have the refine property to do this
Last edited by adrianinsaval on Tue Jan 25, 2022 6:31 pm, edited 2 times in total.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #4754: recompute undos removeSplitter

Post by Kunda1 »

adrianinsaval wrote: Tue Jan 25, 2022 5:50 pm A feature request could be made for a parametric refine but that should probably be done in a new well written ticket if it doesn't exist already.
Care to make a new one while I close this one? :D
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Ticket #4754: recompute undos removeSplitter

Post by adrianinsaval »

Kunda1 wrote: Tue Jan 25, 2022 5:52 pm Care to make a new one while I close this one? :D
sorry completely missinterpreted the issue, please don't close yet
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Ticket #4754: recompute undos removeSplitter

Post by adrianinsaval »

Two possible issues I see after having a deeper look into it:
1- attempting to change the shape of the box (with whatever shape, removeSplitter is unrelated) resets the placement of the box. I do not know why, I understand it's not allowed to change the shape however IMO it shouldn't change the placement of the object.
2- calling for example the built-in scaled function directly on box1.Shape results in the following error:
>>> box1.Shape.scaled(5)
Traceback (most recent call last):
File "<input>", line 1, in <module>
ReferenceError: This object is immutable, you can not set any attribute or call a non const method
but calling box1.Shape.removeSplitter() is allowed, can anybody explain the rationale here?
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Ticket #4754: recompute undos removeSplitter

Post by openBrain »

adrianinsaval wrote: Tue Jan 25, 2022 6:29 pm Two possible issues I see after having a deeper look into it:
1- attempting to change the shape of the box (with whatever shape, removeSplitter is unrelated) resets the placement of the box. I do not know why, I understand it's not allowed to change the shape however IMO it shouldn't change the placement of the object.
2- calling for example the built-in scaled function directly on box1.Shape results in the following error:
>>> box1.Shape.scaled(5)
Traceback (most recent call last):
File "<input>", line 1, in <module>
ReferenceError: This object is immutable, you can not set any attribute or call a non const method
but calling box1.Shape.removeSplitter() is allowed, can anybody explain the rationale here?
1 is a problem. Not a major one, but can be improved though.
2 is expected (actually, this is even how 1 should behave). You have to call box1.Shape.copy().scaled(5)
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Ticket #4754: recompute undos removeSplitter

Post by adrianinsaval »

openBrain wrote: Tue Jan 25, 2022 6:49 pm 2 is expected (actually, this is even how 1 should behave). You have to call box1.Shape.copy().scaled(5)
but why is removeSplitter() allowed without using copy()?
Post Reply