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)
Renaming alias in spreadsheet changes the name of the spreadsheet in any reference
Forum rules
and Helpful information
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!
Also, be nice to others! Read the FreeCAD code of conduct!
-
- 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
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:
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).
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]
- Attachments
-
- ss-bug-scr1.png (66.5 KiB) Viewed 1931 times
Re: Renaming alias in spreadsheet changes the name of the spreadsheet in any reference
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.
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.
Re: Renaming alias in spreadsheet changes the name of the spreadsheet in any reference
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.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.
Hey @eivindkvedalen care to weigh in?eivindkvedalen wrote:ping
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
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
-
- 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
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).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.
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.
Re: Renaming alias in spreadsheet changes the name of the spreadsheet in any reference
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.