variant Link

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
a.l
Posts: 86
Joined: Thu Apr 09, 2020 7:14 pm

Re: variant Link

Post by a.l »

Thanks

To have some sort of model tree that covers the most important things I have put the details in the below code block.
Please scroll it to read the lower lines of text:

Code: Select all

MainAssembly
|
| - Aggregate_var_# (Level) ← a value entered
|   |
|   | - PartB
|   | - PartA_var (Level) ← variable
|   |   |
|   |   | - Body:
        ◦ Variables.Variables_Level is set by Aggregate_var_# (Level) via PartA_var (Level)
        
        ◦ Spreadsheet uses the Variables.Variables_Level in B1
        
        ◦ B1 is used by:
            ▪ B2 to calculate calculatedAngle.
              It describes/converts the level to a specific angle.
              That angle defines the step (the ”angular width”) that each level covers of say a dome/orb.
              
            ▪ D2 to calculate startAngle.
              It is an offset angle that defines where the base sketch of PartA_var needs to be rotated, because...
              
        ◦ … The sketch “Sketch-base-NOTICE-Attachment-is-adjusted-by-Variables.Level-around-z-axis”
           is then rotated using “Map mode” re. “Attachment Offset” - “Around z-axis”.
           This is the main "trick" to modify the form of the later finished part so that it bends correct
           and has the right size etc. …
           
        ◦ … And together with the sketch path “Sketch061-path”, which is a simple 90 degrees circle arc…
        
        ◦ … AdditivePipe then creates the final PartA_var.
Together with that I have also attached this annotated screenshot that hopefully also explains the model tree a bit.
AnnotatedModelTree.png
AnnotatedModelTree.png (231.47 KiB) Viewed 3099 times
I hope it makes some kind of sense. :)
Thanks again!
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: variant Link

Post by Zolko »

a.l wrote: Thu Jan 13, 2022 10:51 pm PartA is a "template" part consisting of a bent arc.
Ah OK, I understand. Actually, this is a typical toponaming problem, and is unrelated to the variant link: if you take only PartA, alone, and change levels between 5 and 6, you can see that the attachment LCS (LCS_1_AttachmentPoint) changes orientation. This LCS is attached with MapMode InertialCS, which, by experience, is quite prone to the TPN.

I modified your PartA to include a specific sketch for the LCS, and this seems to do the trick:

dome.png
dome.png (384.83 KiB) Viewed 3069 times
Attachments
PartA.FCStd
(23.31 KiB) Downloaded 92 times
try the Assembly4 workbench for FreCAD — tutorials here and here
a.l
Posts: 86
Joined: Thu Apr 09, 2020 7:14 pm

Re: variant Link

Post by a.l »

Thanks a lot Zolko :) It worked!
Now I will try doing something similar to my larger model.
martinda
Posts: 1
Joined: Mon Aug 15, 2022 12:20 am

Re: variant Link

Post by martinda »

This is my first post, I apologize in advance if this is the wrong place to post my comment.
2. So another "problem" is that in an assembly it is not possible to link a normal part to a variant linked part.
The normal part is in this case the left hand side of the "Move/Attach a Part in the assembly" (yellow part symbol with the blue crossed direction arrows) dialog window whereas the variant linked part is found in the drop down menu "Attach to".
I am seeing the same. I link the first variant part to the parent assembly, and I would like to link the second part to the first part, but I can't. The variant parts are not listed in the "Attach to" drop down. I don't know if this is something I can fix or not. Maybe if it is trivial I can send a PR. Do you have any advice? Thanks.

If it helps, here is a trivial example of what I describe.
AttachToLCSOfVariantPart.FCStd
(16.4 KiB) Downloaded 54 times
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: variant Link

Post by Zolko »

martinda wrote: Mon Aug 15, 2022 12:44 am The variant parts are not listed in the "Attach to" drop down. I don't know if this is something I can fix or not.
No, you can't. A variant link points to an object in a hidden temporary document created on the fly, and is thus different at each restoration. Therefore, you can't reliably attach anything to it.
try the Assembly4 workbench for FreCAD — tutorials here and here
CharlesLeeScoville
Posts: 8
Joined: Wed Mar 25, 2020 10:10 am

Re: variant Link

Post by CharlesLeeScoville »

Zolko wrote: Fri Sep 02, 2022 3:14 pm No, you can't. A variant link points to an object in a hidden temporary document created on the fly, and is thus different at each restoration. Therefore, you can't reliably attach anything to it.
I must say, this is pretty clearly a feature breaking bug. As you said in post #1, a major use case for this feature is for standard stock that is expected to be custom lengths. So, for things like T-slot extrusion, the very next expected thing to do in an assembly is to anchor something to the T-slot you just dropped in. If the LCS's don't even TRY to carry over to the linked part, then . . . What's the point again?

Currently running into this bug in a 3D printer I'm designing and the only thing I can do is fall back to manually making variants of my parts. Though, I *AM* at least getting great use out of the feature to find my dimensions. [Some things you just can't get a feel for with the measurement tool. ;) ]

To be clear, I'm not at all trying to disrespect the achievement. Up and until this problem, it worked wonderfully. I can totally see myself using this feature all the time when it gets more polish. For being experimental, that's pretty damn good! You're almost there man! Please consider just tossing a slap-dash POC solution onto this one problem and it will be functional for at least 99% of #1 foreseeable use cases. It's a pretty useful time saver for dropping in numerous T-Slot extrusions with different lengths, for sure, but not so much if I can't attach anything to the result. :cry:
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: variant Link

Post by Zolko »

CharlesLeeScoville wrote: Mon Nov 14, 2022 4:41 am So, for things like T-slot extrusion, the very next expected thing to do in an assembly is to anchor something to the T-slot you just dropped in. If the LCS's don't even TRY to carry over to the linked part, then . . . What's the point again?
you didn't think it through.

The "correct" – as designed – way to use them is to set an LCS in the assembly where you attach the beam (I suppose you do that anyway) and then add a second LCS also in the assembly, attached to the previous LCS and offset by the amount which is the length of the beam. Since it's a variant link you know this dimension (either set it by a variable or extract the dimension from the variant link itself). And then, you attach whatever you wanted to attach to the end of the beam, but to the second LCS in the assembly, which is where the end of the beam is by construction. This way you're even protected from any TNP things.

Does that make sense ?
try the Assembly4 workbench for FreCAD — tutorials here and here
CharlesLeeScoville
Posts: 8
Joined: Wed Mar 25, 2020 10:10 am

Re: variant Link

Post by CharlesLeeScoville »

Does that make sense ?
I believe I understand your explanation, and your workaround. . . However, doing that appears to go against the intentions of LCS attachment points.

The value of LCS attachments is - to me - a way to enable the creation of a kinematic chain. That is, if parts are attached A to B to C, then it should follow that moving part A – also – moves C because it moves B, and B is attached to C. With your workaround, however, one ends up attaching A directly to C by this new LCS. This is fine if all you want to do is independently move B or C with respect to A. The problem is, if you intend for movement of B with respect to A to also move C with respect to A... it won't work.

Said again, this time with a concrete example.

A typical Cartesian printer has a frame/base (A) where the Z motion system is mounted. This system moves a gantry (B) up and down with respect to the frame. This gantry itself holds the X or Y motion system, which in turn moves the hotend (C). if the parts that the motion system or gantry are constructed from are imported as variants, your workaround would prevent a system where a gantry height change moves the height of the hotend with respect to the frame. That is, I could do as you say and add a second LCS to the base (A), being careful to match the length and position of the gantry (B) and have the hotend(C) attach to this new LCS.... but then moving the gantry would not move the hotend, even though that should be the intended and expected behavior.

... At least, if I'm understanding your explanation. Not going to lie tho... I'm way past ready for bed rn.... so maybe I missed something??? I do recall something about complexity building up to the point that a skeletal sketch technique ends up being more fruitful... maybe I need to look into that.
DidierJ
Posts: 17
Joined: Wed Dec 23, 2020 12:20 pm
Location: Switzerland
Contact:

Re: variant Link

Post by DidierJ »

Hi,
I like the Idea of the variant link for parametric parts, but it is still missing a few features.

Let me explain what I like to achieve:
I'd like to design a model-truck with lot of (im- :D )possible features. For that I rely heavily on "machine parts" like gears, spacer (sort of thick washer) and bearings. I designed These parts parametric with configuration table (attached a ball bearing as example). Each part includes a "top LCS" and a "bootom LCS", so I can stack them on an axle. This way, when I need more room in an already designed configuration, I can modify e.g. a spacer and all the other elements on the axle get realigned correctly.

At the moment I encounter following errors:
1. when inserting the part with "Create a variant part", I get an error. The script doesn't seem to like the enum type:

Code: Select all

09:37:46  Initialising ...
09:37:46  Attaching VariantLink ...
09:37:46  Traceback (most recent call last):
  File "C:\Users\tweety\AppData\Roaming\FreeCAD\Mod\Assembly4\.\Asm4_objects.py", line 83, in execute
    self.fillVarProperties(obj)
  File "C:\Users\tweety\AppData\Roaming\FreeCAD\Mod\Assembly4\.\Asm4_objects.py", line 154, in fillVarProperties
    setattr( obj, prop, getattr( variables, prop ))
<class 'ValueError'>: 'MR52-ZZ' is not part of the enumeration in assembly#Kugellager_var.Typ
09:37:46  Traceback (most recent call last):
  File "C:\Users\tweety\AppData\Roaming\FreeCAD\Mod\Assembly4\.\Asm4_objects.py", line 77, in execute
    setattr( variantVariables, prop, getattr( obj, prop ))
<class 'TypeError'>: PropertyEnumeration varTmpDoc_5#Variables.Typ expects type to be int, string, or list(string), or list(list, int)
09:38:26  Part is now manually placed
... and the part gets a nasty red exclamation point

2. the local LCS (bottom-LCS & top-LCS) of the part are not visible from outside, so I can't stack the parts.
I haven't tried yet if it is possible to change the "part" to an "assembly".

3. the BOM doesn't seem to recognize the parts. This is essential for me, since the full design will have 100+ elements, and I'm not going to count the washer, bearings, screws,... by hand.

Could someone help me out? I'm not familiar with python, so I could tweak the code (java, c++, Delphi would be less a problem)
I also tried to insert my parametric parts in other ways into the assembly, but none seems to work as desired.
Attachments
Kugellager MRxx-ZZ.FCStd
(12.33 KiB) Downloaded 39 times
DidierJ
Posts: 17
Joined: Wed Dec 23, 2020 12:20 pm
Location: Switzerland
Contact:

Re: variant Link

Post by DidierJ »

DidierJ wrote: Thu Feb 02, 2023 9:31 am 1. when inserting the part with "Create a variant part", I get an error. The script doesn't seem to like the enum type:
I found in a night-session a manual workaround for the first problem:
1. open your parametric file (in my case "Kugellager MRxx-ZZ.FCStd")
2. navigate to the spreadsheet and make sure that the cell with the "hiddenref" (in my case cell A2) is inactiv by adding a quote as the first character
paramPart1.png
paramPart1.png (18.5 KiB) Viewed 1301 times
3. insert the part into the assembly with "Create a varant part"
paramPart2.png
paramPart2.png (50.85 KiB) Viewed 1301 times

4. select the newly created part, right-click in the property pane and select "show all"
paramPart3.png
paramPart3.png (19.33 KiB) Viewed 1301 times

5. expand the Enumeration property (in my case "Typ")
6. right-click in the value of the Enum-property and select "Expression..."
paramPart4.png
paramPart4.png (17.57 KiB) Viewed 1301 times

7. enter "varTmpDoc_1#<<Parameter>>.cells[<<A3:|>>]" make sure that "varTmpDoc_?" matches the one in the "Linked Object" property
paramPart5.png
paramPart5.png (23.22 KiB) Viewed 1301 times

8. navigate to the spreadsheet of the created part and remove the quote at the beginning of cell A2

There is one drawback: when you end Freecad, restart it and reopen the assembly the variant Link parts might be broken. The index in the name of the temporary document ("varTmpDoc_1") is autogenerated and it depends in which order the variant Link parts are loaded. If this happens repeat step 5-7. For me this happens only once, afterwards I can close and reopen the assembly as much as I like, the names of the temporary documents do not change anymore.
Post Reply