Renaming alias in spreadsheet changes the name of the spreadsheet in any reference

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!
Post Reply
lokomoko
Posts: 4
Joined: Sat Aug 11, 2018 4:23 pm

Renaming alias in spreadsheet changes the name of the spreadsheet in any reference

Post by lokomoko »

Hi I observe the above behaviour. Here is how to reproduce it:

1. Create new document
2. In spreadsheet workbench create a spreadsheet by the name "MyData"
3. Create cell with an alias e.g. "BoxSize" and a value
4. In part workbench create a 3D-object (e.g. cube) and therein a reference to the alias (e.g. "=MyData.BoxSize").
5. In spreadsheet change name of alias to BoxLength

Actual Result: The reference in the 3D-Object is "=Spreadsheet001.BoxLength" now, that is the alias was changed, but also the name of the spreadsheet
Expected Result: The reference in the 3D-Object should be "=MyData.BoxLength"

Is this a Bug?

Cheers!
lokomoko

OS: Ubuntu 16.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13528 (Git) AppImage
Build type: None
Branch: releases/FreeCAD-0-17
Hash: 5c3f7bf8ec51e2c7187789f7edba71a7aa82a88b
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Renaming alias in spreadsheet changes the name of the spreadsheet in any reference

Post by TheMarkster »

Looks like a bug, but a relatively harmless one. In FreeCAD objects have 2 properties internally, one is the Name and the other is the Label. The Label is what you see in the tree view. The name is held internally. Many times these are both the same, but when you change the label in the tree view they become different. It looks like what's happening here is when the object's (in this case Cube's) property gets updated the spreadsheet's name is used (instead of its label) to reconstruct the expression linked to that property.

As a sidenote, do you see the word "Box" in the attached screenshot? That's the Cube's internal name "Box", not "Cube".

Try this in the python console:

Code: Select all

spByName = App.ActiveDocument.getObject('Spreadsheet')
spByLabel = App.ActiveDocument.getObjectsByLabel('MyData')
spByName == spByLabel[0]
The last line returns True because it's the same object, the spreadsheet object. Only difference getObjectsByLabel returns in the form of a list of objects, so we have to index into the list with the [0] bit. Luckily, expression engine references work whether the name or the label is used, which is why this bug doesn't break any models (probably doesn't break any, anyway).
Attachments
ss-bug-scr1.png
ss-bug-scr1.png (66.5 KiB) Viewed 1931 times
lokomoko
Posts: 4
Joined: Sat Aug 11, 2018 4:23 pm

Re: Renaming alias in spreadsheet changes the name of the spreadsheet in any reference

Post by lokomoko »

Thanks for explanation! I agree, this bug is rather harmless. Would it be worth filing a bug for it or is the bugtracker rather kept low bandwith?

Previously I discovered a related phenomenon and I created the topic "Copying and Pasting an object destroys references to that object". I think that one is a bit more harmfull, but sofar nobody commented on it.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Renaming alias in spreadsheet changes the name of the spreadsheet in any reference

Post by Kunda1 »

lokomoko wrote: Tue Aug 14, 2018 11:03 pm Thanks for explanation! I agree, this bug is rather harmless. Would it be worth filing a bug for it or is the bugtracker rather kept low bandwith?

Previously I discovered a related phenomenon and I created the topic "Copying and Pasting an object destroys references to that object". I think that one is a bit more harmfull, but sofar nobody commented on it.
Yes, please open a ticket and in regard to the previous time let you opened, I'm sure the spreadsheet dev has seen it so it's not in vain. Remember to reference the ticket number here and reference this thread in the ticket.
eivindkvedalen wrote:ping
Hey @eivindkvedalen care to weigh in?
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
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Renaming alias in spreadsheet changes the name of the spreadsheet in any reference

Post by TheMarkster »

lokomoko wrote: Tue Aug 14, 2018 11:03 pm Thanks for explanation! I agree, this bug is rather harmless. Would it be worth filing a bug for it or is the bugtracker rather kept low bandwith?

Previously I discovered a related phenomenon and I created the topic "Copying and Pasting an object destroys references to that object". I think that one is a bit more harmfull, but sofar nobody commented on it.
I found your other post. I believe these are related somehow, perhaps might even have the same root cause. Could be the issue is not in the spreadsheet code at all, but rather in the app document code. Note, once again, Cube is the label, Box is the name. If you make your reference to Box.Placement.Base.x + Box.Length instead of to Cube.Placement.Base.x + Cube.Length it works as expected (it did for me when I tried it anyway).

Try something similar with cylinders, linking to the radius and x position. Works as expected unless you relabel Cylinder (the object being copied). I believe (should test to verify this) if you make your references to the object's underlying name instead of to its label it will always work.
chrisb
Veteran
Posts: 53935
Joined: Tue Mar 17, 2015 9:14 am

Re: Renaming alias in spreadsheet changes the name of the spreadsheet in any reference

Post by chrisb »

Link to the other topic concerning names and references: https://forum.freecadweb.org/viewtopic. ... 56#p249817
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply