Deleting an Object Breaks Expressions

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!
davidhuwmorgan
Posts: 3
Joined: Mon Jun 10, 2019 1:00 am

Deleting an Object Breaks Expressions

Postby davidhuwmorgan » Mon Jun 10, 2019 1:35 am

Hello all,

I believe this is a bug.
When deleting an unused object of the same type a reference to a similar object is replace by the object which has been deleted.

Procedure:
1) New Document
2) Go to Part Workbench
3) Create a Cube (name = Cube)
4) Create another cube (name = Cube001)
5) Make Cube001's Z equal to Cube's height using formula editor in the properties dialog.
6) Look in isometric view the boxes are stacked above each other.
7) Create another cube (name = Cube002). All looks good.
8) Delete Cube002 using Combo view.
9) Note the error flagged against Cube001.
10) Cube001's Z in the expression now refers to the non-existent Cube002. <--- not good my model is now broken.

If there's anything else needed to help here, just let me know.



FreeCAD Version:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16110 (Git)
Build type: Release
Branch: (HEAD detached at upstream/releases/FreeCAD-0-18)
Hash: f7dccfaa909e5b9da26bf50c4a22ccca9bb10c40
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)

OS:
Windows 10 Pro Version 1803
OS Build 17134.765

FreeCAD log extract:
...
Log: Init: Loading FreeCAD GUI
Log: Init: Running FreeCADGuiInit.py start script... done
Log: Init: Activating default workbench StartWorkbench
Log: Loading GUI of Web module... done
Log: Loading GUI of Start module... done
Log: Loading Start module... done
Log: Init: Showing main window
Log: Main window restored
Log: Show main window
Log: Toolbars restored
Log: 3Dconnexion device not attached.
Log: Init: Entering event loop
Log: Init: Processing command line files
Log: Module: Part
Log: Loading Part module... done
Log: Loading Sketcher module... done
Log: Loading PartDesign module... done
Log: Loading GUI of Part module... done
Log: Loading GUI of Sketcher module... done
Log: Loading GUI of PartDesign module... done
Err: App::Document::recompute(): cyclic dependency detectedErr:
Err: App::Document::recompute(): cyclic dependency detectedErr:
Err: Exception (Sun Jun 9 20:25:50 2019): Property not found: Cube002
Log: Hide main window
davidhuwmorgan
Posts: 3
Joined: Mon Jun 10, 2019 1:00 am

Re: Deleting an Object Breaks Expressions

Postby davidhuwmorgan » Mon Jun 10, 2019 4:25 am

And just as a follow up,

it doesn't appear to be the delete that breaks the reference to "Cube" but the more like the creation of "Cube002". If after Step 7, I click on "Cube002" cube in the Combo view, then click back on the "Cube001", it can be seen that the Expression for the Z value already references "Cube002". So it seems that the delete merely exposes the change in "Cube001"'s Z value, which can only have been changed during the creation of "Cube002".

OK, hope that helps shed some light,

DHM
openBrain
Posts: 2132
Joined: Fri Nov 09, 2018 5:38 pm

Re: Deleting an Object Breaks Expressions

Postby openBrain » Mon Jun 10, 2019 8:05 am

Confirmed with :

Code: Select all

OS: Ubuntu 18.04.2 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19. (2019/06/09)
Build type: Release
Python version: 3.6.7
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)
Moreover, when Cube002 is added, FC complains about a "cyclic dependency". ;)
This is a serious weird bug. :) Deserve a ticket.
TheMarkster
Posts: 1060
Joined: Thu Apr 05, 2018 1:53 am

Re: Deleting an Object Breaks Expressions

Postby TheMarkster » Mon Jun 10, 2019 5:18 pm

Workaround: instead of using Unnamed#Cube.Height use Unnamed#Box.Height in your formula.
openBrain
Posts: 2132
Joined: Fri Nov 09, 2018 5:38 pm

Re: Deleting an Object Breaks Expressions

Postby openBrain » Mon Jun 10, 2019 5:50 pm

TheMarkster wrote:
Mon Jun 10, 2019 5:18 pm
Workaround: instead of using Unnamed#Cube.Height use Unnamed#Box.Height in your formula.
I.e. use the internal name instead of the label. ;)
openBrain
Posts: 2132
Joined: Fri Nov 09, 2018 5:38 pm

Re: Deleting an Object Breaks Expressions

Postby openBrain » Mon Jun 10, 2019 6:16 pm

davidhuwmorgan wrote:
Mon Jun 10, 2019 4:25 am
And just as a follow up,
Oups, was blind it was your first posts here => Welcome to the forum ! :lol:
I created issue #4015
davidhuwmorgan
Posts: 3
Joined: Mon Jun 10, 2019 1:00 am

Re: Deleting an Object Breaks Expressions

Postby davidhuwmorgan » Tue Jun 11, 2019 3:21 am

Thanks for opening up the issue report.

I think my workaround is just to always rename an object as soon as its created. Now I know to do that things should be a little easier.

Once again, thanks for the help all.

DHM
jmaustpc
Posts: 9566
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Deleting an Object Breaks Expressions

Postby jmaustpc » Tue Jun 11, 2019 6:01 am

davidhuwmorgan wrote:
Tue Jun 11, 2019 3:21 am
Thanks for opening up the issue report.

I think my workaround is just to always rename an object as soon as its created. Now I know to do that things should be a little easier.

Once again, thanks for the help all.

DHM
A tip, you may not know, all objects in FreeCAD have both a name which is created by FreeCAD on creation of the object which can not be edited as well as a label which can be edited by a user at any time. It is the label that you see, and can edited, in the GUI. When you use expressions or macros/Python, the difference matters and can be useful. The others are referring to this.
openBrain
Posts: 2132
Joined: Fri Nov 09, 2018 5:38 pm

Re: Deleting an Object Breaks Expressions

Postby openBrain » Tue Jun 11, 2019 7:29 am

jmaustpc wrote:
Tue Jun 11, 2019 6:01 am
A tip, you may not know, all objects in FreeCAD have both a name which is created by FreeCAD on creation of the object which can not be edited as well as a label which can be edited by a user at any time. It is the label that you see, and can edited, in the GUI. When you use expressions or macros/Python, the difference matters and can be useful. The others are referring to this.
Very nice addition, as the obvious may indeed not be for everyone. ;)

@DHM : following jmaustpc, there is an easy way to get the internal name in the GUI. When you hover an object in the tree view with your mouse, the Internal Name is displayed in the status bar (ensure status bar is enabled in View -> Status bar). ;)