[Solved] Assembly4: Part positions incorrect after parameter changed in spreadsheet

Discussion about the development of the Assembly workbench.
Post Reply
JB2500
Posts: 3
Joined: Sun May 29, 2022 9:28 am

[Solved] Assembly4: Part positions incorrect after parameter changed in spreadsheet

Post by JB2500 »

[Context: I'm new to FreeCAD Forum (first post). I'm relatively new (<100 hours) to using FreeCAD and not at all expert at using it, though I've been watching its development for a few years].

Problem: I've experienced part positions being incorrect when the spreadsheet parameters they depend upon are changed.

Using Assembly4 workbench, I inserted (using "Insert Link to a Part") 13 identical parts. Initially I set each to a different Z position using Property => Placement. Later, I attached the parts to a particular LCS, and in "Property => Assembly => Attachment Offset" gave each a different expression for its Z position e.g. <<Parameters>>.HeightOfLowestSlat + 7 * <<Parameters>>.SlatVerticalSpacing.

I found that the part positions did not update when the parameter "SlatVerticalSpacing" was changed. Selecting all the parts, editing "Property => Placement" and clicking OK fixed the positions temporarily but only until the parameter was changed again, or (I think) the file was reopened.

Looking in Document.xml (in the design file interpreted as a zip file) I found that the expression for AttachmentOffset in terms of the parameters was AFTER the expression for Placement which uses it, as follows:

Code: Select all

<Property name="ExpressionEngine" type="App::PropertyExpressionEngine" status="67108864">
    <ExpressionEngine count="2">
        <Expression path="Placement" expression="Bottom.Placement * Local_CS008.Placement * AttachmentOffset * Local_CS011.Placement ^ -1"/>
        <Expression path=".AttachmentOffset.Base.z" expression="&lt;&lt;Parameters&gt;&gt;.HeightOfLowestSlat + 0 * &lt;&lt;Parameters&gt;&gt;.SlatVerticalSpacing"/>
    </ExpressionEngine>
</Property>
I swapped these two "Expression path" lines for each of the 13 parts and now the parts are updated correctly when the parameters are changed.

All useful advice welcome. Have I found a bug? Am I fighting the software? Is there a way to fix this problem from within the software? Is there a better way to do what I'm doing?

Part of my problem I think is that when using "Insert Link to a Part" to insert a part, the "X Translation" etc fields do not accept expressions (pressing "=" does nothing). If I could enter my parametric expressions there I think the order of expressions would then be correct.

Cheers,
John.

NB: I wonder whether this is a similar problem: https://forum.freecadweb.org/viewtopic.php?f=20&t=68280

FreeCAD version: 0.19 (Branch_19.4).
OS: Windows 10.
Last edited by JB2500 on Sun May 29, 2022 9:36 pm, edited 4 times in total.
JB2500
Posts: 3
Joined: Sun May 29, 2022 9:28 am

Re: Assembly4: Part positions incorrect after parameter changed in spreadsheet

Post by JB2500 »

Update A: My fix turned out not to be permanent. After opening the file in FreeCAD, changing a spreadsheet parameter, and saving the file, the order of the expression lines was reversed again (seen using BeyondCompare on the before and after *.FCStd files) and the parameters no longer worked.

Update B: And it's fixed again: by doing the same thing... (I've compared the files and sure enough the pairs of lines are reversed again).

I have kept all the relevant design (*.FCStd) files in case they are of interest.
User avatar
Kunda1
Veteran
Posts: 12692
Joined: Thu Jan 05, 2017 9:03 pm

Re: Assembly4: Part positions incorrect after parameter changed in spreadsheet

Post by Kunda1 »

Just a tip, probably want to update to v0.20dev since v0.19 is ancient at this point.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
JB2500
Posts: 3
Joined: Sun May 29, 2022 9:28 am

Re: Assembly4: Part positions incorrect after parameter changed in spreadsheet

Post by JB2500 »

Yes that (latest dev version of FreeCAD) seems to have solved the problem. Many thanks! :D
User avatar
Kunda1
Veteran
Posts: 12692
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Solved] Assembly4: Part positions incorrect after parameter changed in spreadsheet

Post by Kunda1 »

Man, can't wait till we publish v0.20
It'll save everyone more time. Hopefully we can backport a lot better in v0.20 too! Of course that requires volunteers <fingers crossed>
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Zolko
Veteran
Posts: 1794
Joined: Mon Dec 17, 2018 10:02 am

Re: [Solved] Assembly4: Part positions incorrect after parameter changed in spreadsheet

Post by Zolko »

JB2500 wrote: Sun May 29, 2022 10:11 am I found that the part positions did not update when the parameter "SlatVerticalSpacing" was changed. Selecting all the parts, editing "Property => Placement" and clicking OK fixed the positions temporarily but only until the parameter was changed again, or (I think) the file was reopened.
Did you use the Update assembly command ? Image.
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
Post Reply