Bug when using draft modifiers on a part container

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Bug when using draft modifiers on a part container

Post by carlopav »

Something not working good when using draft modifiers to app:part container.
MOVE: When trying to move a part with draft move the action is applied to the part and also to the contained elements, so the action results to be applied twice.
ROTATE: This provoke an error:

Code: Select all

('[Draft.todo.commit] Unexpected error:', <class 'AttributeError'>, 'in ', ['Draft.rotate([FreeCAD.ActiveDocument.Part,FreeCAD.ActiveDocument.Polygon,FreeCAD.ActiveDocument.Rectangle,FreeCAD.ActiveDocument.Wall],326.1078720523758,FreeCAD.Vector(21799.54587525629, 13207.747492836314, 0.0),axis=FreeCAD.Vector(0.0, 0.0, 1.0),copy=False)', 'FreeCAD.ActiveDocument.recompute()'])
SCALE: this seems ok: the console prompts:

Code: Select all

Unable to scale objects: Wall002,WallTrace,Wall001,WallTrace002,Wall003 - This object type cannot be scaled directly. Please use the clone method.

Code: Select all

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18629 (Git)
Build type: Release
Branch: master
Hash: bb1aec9e60faa8b279306bfebe672b8d4e77351d
Python version: 3.6.7
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Italian/Italy (it_IT)
follow my experiments on BIM modelling for architecture design
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Bug when using draft modifiers on a part container

Post by Roy_043 »

I have also noticed noticed the move issue:
https://forum.freecadweb.org/viewtopic. ... 80#p337866
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Bug when using draft modifiers on a part container

Post by carlopav »

Thanks, I didn't notice it. Let's see if I can find a way to solve it.
follow my experiments on BIM modelling for architecture design
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Bug when using draft modifiers on a part container

Post by carlopav »

seems like it's because of this line:
https://github.com/FreeCAD/FreeCAD/blob ... s.py#L2387

Code: Select all

self.selected_objects = Draft.getGroupContents(self.selected_objects, addgroups=True, spaces=True, noarchchild=True)
If addgroups is set to True also the group is added to the modifier. I dont think this make sense:
- if the group is a "group" there is no point in moving it;
- if the group is an "App:part" we can decide to move contained objects (but that's already possible selecting them without the part) or to move just the "App:Part". I'd prefer the second choice.

so I propose to modify:
def getGroupContents(objectslist,walls=False,addgroups=False,spaces=False,noarchchild=False):
https://github.com/FreeCAD/FreeCAD/blob ... ft.py#L397
to return the following behaviour:
if objectlist contains an App:Part we discard every other object and return just it.
Anybody see any problem?
follow my experiments on BIM modelling for architecture design
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Bug when using draft modifiers on a part container

Post by Roy_043 »

If a group is selected then the user will expect its content to be modified.

Related issues:
Door does not move with Floor
Component does not move with host
In these two cases there is also a problem with undo: the 'before' state cannot be restored.

A. Another use case:
Wall (based on a sketch, Move With Host=True, Move Base=True) nested in a building part.
Move the building part.
Result: sketch is not moved, wall is moved relative to the sketch.

B. And one more:
Nest the building part from A. in a group.
Move the group.
Result: error:
('[Draft.todo.commit] Unexpected error:', <class 'AttributeError'>, 'in ', ['Draft.move([FreeCAD.ActiveDocument.Group,FreeCAD.ActiveDocument.BuildingPart,FreeCAD.ActiveDocument.Wall],FreeCAD.Vector(1000.0, 1.1368683772161603e-13, 0.0),copy=False)', 'FreeCAD.ActiveDocument.recompute()'])

Code: Select all

OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18615 (Git)
Build type: Release
Branch: master
Hash: a801ff5a236d9275c2dc184db5a457589b3eabc4
Python version: 3.6.7
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Dutch/Netherlands (nl_NL)
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Bug when using draft modifiers on a part container

Post by carlopav »

Roy_043 wrote: Mon Oct 28, 2019 9:05 am If a group is selected then the user will expect its content to be modified.
Yes, of course.

Thanks for the usecases: the problem is indeed well complicated.
So.... I know this conversation is perhaps be made thousand of times. But I still don't have a clear idea about how it should behave and in which way I should be supposed to act to fix it. I beg for HELP :)

We probably should define a behaviour for when Draft modifiers try to guess what object they should apply the transformation:
If selection contains:
- a group -> every object inside the group should receive the transformation.
- a part (or every other container that have a placement?) -> only the part should receive the transformation, contained objects should be discarded;
- a part inside a part -> only the upper part should receive the transformation;
- an object that have a base -> if "move base" is true, only the base should receive the transformation (i think this should be the default);
- an object that have a base -> if "move base" is false, only the object itself should receive the transformation;

- an object that have a host-> here i think that the obj placement should already be determined in respect to the host placement (like Partdesign attachment property?) (ex if we are moving the wall we should not move also the window, this should be updated automatically when wall placement changes), but i'm getting lost, HELP me please!

BTW A transfomation should never be applied twice to an object. And neither to the object itself and it's base or its host. Or not?
follow my experiments on BIM modelling for architecture design
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Bug when using draft modifiers on a part container

Post by Roy_043 »

It is indeed difficult and confusing.

- An object with a base inside a part or other container with placement -> ...?
- The user selects a container but also (accidentally) an object nested in the container -> ...?
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Bug when using draft modifiers on a part container

Post by carlopav »

I think we should simplify and base everything in these cases:
-obj have a group property but no placement;
-obj have a group property and a placement;
-obj have a base and move base is true;
-obj have a base and move base is false;
-obj have a host and move with host is true;
-obj have a host and move with host is false;
Every case should include/exclude related objects and the object itself.
Objects that are excluded are not processed in the algorithm.

I think I'll give a try in this direction. Perhaps some cases are not comprised in those?
follow my experiments on BIM modelling for architecture design
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Bug when using draft modifiers on a part container

Post by ickby »

One remark: Your proposal currently use duck typing to check if a object is a Part or a group, meaning you check if it has Group property and Placement. You could also use a different way. In FreeCAD different kinds of objects can be a "Group" or a Part like object, called GeoFeatureGroup. To check weather an object is a GeoFeatureGroup you can check for the extension:

Code: Select all

obj.hasExtension("App::GeoFeatureGroupExtension")
obj.hasExtension("App::GroupExtension")
If it returns true it is guaranteed that it has all relevant properties and functions of a Group or GeoFeatureGroup. This may be less coding effort than checking for a multitude of properties and functions.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Bug when using draft modifiers on a part container

Post by carlopav »

ickby wrote: Tue Oct 29, 2019 6:49 am

Code: Select all

obj.hasExtension("App::GeoFeatureGroupExtension")
obj.hasExtension("App::GroupExtension")
That's more elegant, but my problem is i have not just to deal with groups and parts, but also with "BuildingPart", "Space", "Project", "Site", "Building" and whatever will come in the future. Some of them ("space") are neither "GeoFeatureGroup" nor "Group", but have a placement and a group property.

AFAICS if an object have a placement i must transform its placement and not the placement of it's children (obj inside the group field). Else, if it has no placement I must transform all of its children (obj inside the group field).

What do you think?
follow my experiments on BIM modelling for architecture design
Post Reply