[Solved] Copy a part body that depends on a spreadsheet

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
User avatar
iogui
Posts: 95
Joined: Tue Mar 19, 2019 3:44 pm
Location: São Paulo
Contact:

[Solved] Copy a part body that depends on a spreadsheet

Post by iogui »

I'm working on a part in part design but in order to reuse some parameters in other parts I've put all those common parameters in a spreadsheet that is referenced by all the parts of my document.
Now I want to build a part that is similar to the part that I've modeled before but with difference in just one of it's properties. Then I've made a copy of the original Part Body to build a second PartBody but when I paste it, a copy of the spreadsheet is automatically made by freecad.
Considering that I just want to have one spreadsheet centralizing all main parameters, that is an odd behavior.
Conceptually am I doing it the wrong way? Or is it a bug?

The file is:
cavalete-mandala-redonda-60.FCStd
(78.21 KiB) Downloaded 47 times
The body I'm trying to copy is the one named BodyBaseEstrutural.

------------------------

OS: Ubuntu 16.04.6 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.1.
Build type: Release
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Portuguese/Brazil (pt_BR)
Last edited by Kunda1 on Fri Feb 19, 2021 5:08 pm, edited 1 time in total.
Reason: marked thread [SOLVED]
Be the change you want to see in the world. - Mahatma Gandhi
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Copy a part body that depends on a spreadsheet

Post by NormandC »

On very quick inspection, although a duplicate spreadsheet is created, the second Body actually links to the original spreadsheet. Have a look at the dependency graph. So I think you can safely delete the duplicate spreadsheet.


OS: Ubuntu 18.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.1.
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/Canada (fr_CA)
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: Copy a part body that depends on a spreadsheet

Post by kisolre »

Shouldn't copying everything down the dependency graph and properly changing links to the new objects be the expected behavior? What if I wanted to make two completely independent copies? Should I change all the expressions to point to the new spreadcheet? It might be worth special treatment of the spreadsheets in the copy operation - ask the user what is current desired behavior?
User avatar
iogui
Posts: 95
Joined: Tue Mar 19, 2019 3:44 pm
Location: São Paulo
Contact:

Re: Copy a part body that depends on a spreadsheet

Post by iogui »

NormandC wrote: Wed May 01, 2019 3:49 am On very quick inspection, although a duplicate spreadsheet is created, the second Body actually links to the original spreadsheet. Have a look at the dependency graph. So I think you can safely delete the duplicate spreadsheet.
In my environment, if you already have two bodies referencing the same spreadsheet and you try to copy one of the bodies the new body links to the original spreadsheet but the body that wasn't copied gets all its links updated to the new spreadsheet. A bizarre behavior!
cavalete-mandala-redonda-60_original.FCStd
The file before the copy
(35.46 KiB) Downloaded 30 times
cavalete-mandala-redonda-60_error_copy.FCStd
The same file after the copy
(62.38 KiB) Downloaded 50 times
This behavior is really bad because if you have many bodies referencing one centralizing spreadsheet and you make a copy of one of the bodies, you will have a massive rework to correct all things to reproduce the desired result. With this behavior I will have to completely avoid coping things so I will have a lot more work because I will not be able to reuse similar shapes.
Be the change you want to see in the world. - Mahatma Gandhi
User avatar
iogui
Posts: 95
Joined: Tue Mar 19, 2019 3:44 pm
Location: São Paulo
Contact:

Re: Copy a part body that depends on a spreadsheet

Post by iogui »

kisolre wrote: Wed May 01, 2019 6:33 am Shouldn't copying everything down the dependency graph and properly changing links to the new objects be the expected behavior?
I don't think so...
kisolre wrote: Wed May 01, 2019 6:33 am What if I wanted to make two completely independent copies? Should I change all the expressions to point to the new spreadcheet? It might be worth special treatment of the spreadsheets in the copy operation - ask the user what is current desired behavior?
I think a better behavior would be a conditional one:
  • If the user selects just the body, the copied object should be just the selected body and all it's links should then reference to the same spreadsheet. (At least that's what I was expecting to happen)
  • If the user selects both the body and the spreadsheet, then both objects should be copied and then FreeCAD could have one of two behaviors: 1) Make a copy of both features and automatically reference the body to the new copied spreadsheet or 2) Ask the user what the current desired behavior (to update the references to the new copies or maintain the old references)
I understand though that to implement this conditional behavior is not so easy and it can exist use cases that I'm not thinking about now. But I agree with you when you say that spreadsheets should require special treatment in copy operations.
Last edited by iogui on Wed May 01, 2019 5:52 pm, edited 2 times in total.
Be the change you want to see in the world. - Mahatma Gandhi
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: Copy a part body that depends on a spreadsheet

Post by kisolre »

iogui wrote: Wed May 01, 2019 5:28 pm In my environment, if you already have two bodies referencing the same spreadsheet and you try to copy one of the bodies the new body links to the original spreadsheet but the body that wasn't copied gets all its links updated to the new spreadsheet. A bizarre behavior!
Now that you mention that I remember discusing similar behavior in the past with one of my designs but can't find the thread :(
M4dEngin33r
Posts: 2
Joined: Tue Feb 16, 2021 3:34 pm

Re: Copy a part body that depends on a spreadsheet

Post by M4dEngin33r »

Hello,

I recently have started working with FreeCAD and noticed the same behavior.
When copying a part, it copies your Spreadsheet to "Spreadsheet001". After deleting that, you need to "fix" all links in constraints etc.
Strangely not all variables in formulas are changed to the new Spreadsheet, only the first mentioned.

Now I think I have found a quick workaround though:
start your formulas, where you are using variables with 1-1+ [...]

e.g.: 1-1+Spreadsheet.variable

Because the spreadsheet variable is not the first "number" it is not changed to a spreadsheet-copy when copying the part.

Its a small extra work, but for me way better than changing everything afterwards again.
User avatar
Roy_043
Veteran
Posts: 8583
Joined: Thu Dec 27, 2018 12:28 pm

Re: Copy a part body that depends on a spreadsheet

Post by Roy_043 »

In V0.19 you can specify if you want to include the spreadsheet in the copy-paste operation. So there should be no need for your workaround.
chrisb
Veteran
Posts: 54302
Joined: Tue Mar 17, 2015 9:14 am

Re: Copy a part body that depends on a spreadsheet

Post by chrisb »

Hi and welcome to the forum!
M4dEngin33r wrote: Tue Feb 16, 2021 3:41 pm Now I think I have found a quick workaround though:
You didn't post your FreeCAD infos, but in 0.19 you can unselect the spreadsheet to be copied with the body. This keeps the expressions correct without any workaround.

Edit: Roy beat me to it. He probably knew the answer, while I had to check.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
M4dEngin33r
Posts: 2
Joined: Tue Feb 16, 2021 3:34 pm

Re: Copy a part body that depends on a spreadsheet

Post by M4dEngin33r »

Well, time to updadte I guess!
Thank you for the info!
Post Reply