Making some features in a part customizable invisible?

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!
User avatar
PedjaS
Posts: 147
Joined: Sat Jan 18, 2020 6:35 pm

Re: Making some features in a part customizable invisible?

Post by PedjaS »

Roy_043 wrote: Mon Sep 14, 2020 10:13 am
PedjaS wrote: Mon Sep 14, 2020 10:04 am It was just I wanted to try with this visibility thing
You need to have a closer look. The visibility of the red and blue objects is changed via expressions. The HowTo is given here by @TheMarkster and also in the link in my first answer. It is only for the cylinder that a workaround is used.
Strange. Few minutes before, when I checked again, Expression was not in the menu. Now it is.

However, it still does not work properly because as soon as I do fusion, visibility property becomes ineffective. I have to use workaround with placement.
andi11
Posts: 6
Joined: Mon Nov 22, 2021 9:13 am

Re: Making some features in a part customizable invisible?

Post by andi11 »

TheMarkster wrote: Sun Sep 13, 2020 5:45 pm Just making something invisible won't remove it from the model, but you can manage the visibility property via a spreadsheet. Suppose your object is named Cylinder and your spreadsheet is named Spreadsheet and the alias is named isVisible. In the python console enter:

Code: Select all

App.ActiveDocument.Cylinder.setExpression('Visibility','Spreadsheet.isVisible')
Can also be done in the Gui with right clicking and choosing Show all, then right click on Visibility property, set Expression, set link to spreadsheet alias.
this trick works great. Just one question to it. How can I do it with link objects?
I have Cylinder1 => no problem setting the visibility expression
Cylinder001 is linked to Cylinder1 => setting the expression throws the error "<Exception> Invalid property owner."
When i try the autocomplete in python console Cylinder001 isn't even listed.
Using Freecad 0.19 and 0.20
Last edited by andi11 on Mon Nov 22, 2021 9:23 am, edited 1 time in total.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Making some features in a part customizable invisible?

Post by TheMarkster »

I'm not an expert on Links. This might be a bug or it might be the expected behavior.
realthunder wrote: pinged by pinger macro
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Making some features in a part customizable invisible?

Post by realthunder »

andi11 wrote: Mon Nov 22, 2021 9:16 am I have Cylinder1 => no problem setting the visibility expression
Cylinder001 is linked to Cylinder1 => setting the expression throws the error "<Exception> Invalid property owner."
When i try the autocomplete in python console Cylinder001 isn't even listed.
Using Freecad 0.19 and 0.20
'Cylinder001' is the label (user changeable) of a Link whose name (readonly) is actually something like 'Link001'. To reference an object by label, the expression syntax is <<Cylinder001>>.Visibility

I have a pending PR for enhanced expression auto complete, which will suggest the correct syntax.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Making some features in a part customizable invisible?

Post by TheMarkster »

I don't think it's an issue of not getting the correct object from the label. When pressing Ctrl+Shift+P the "Link" name is used to set the variable obj. But still the invalid property owner error happens on recompute.

Code: Select all

>>> ### Begin command Std_SendToPythonConsole
>>> obj = App.getDocument("Unnamed").getObject("Link")
>>> ### End command Std_SendToPythonConsole
>>> obj.setExpression("Height","25")
>>> App.activeDocument().recompute(None,True,True)
<Exception> Invalid property owner
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Making some features in a part customizable invisible?

Post by realthunder »

TheMarkster wrote: Tue Nov 23, 2021 1:21 am I don't think it's an issue of not getting the correct object from the label. When pressing Ctrl+Shift+P the "Link" name is used to set the variable obj. But still the invalid property owner error happens on recompute.
I see. An object can only bind expression to its own property, while Link does not own the 'Height' property. You can do this instead, which works for non-Link object as well, since all objects have 'getLinkedObject()' and will return itself if it is not a Link.

Code: Select all

obj.getLinkedObject().setExpression("Height","25")
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
andi11
Posts: 6
Joined: Mon Nov 22, 2021 9:13 am

Re: Making some features in a part customizable invisible?

Post by andi11 »

but when i change the visiblity state by the expression of the original item, i change the state of this ,not the "copy"

i need:
cylinder => don't care
cylinderlink1 to cylinder => not visible
cylinderlink2 to cylinder => visible

or am I wrong?
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Making some features in a part customizable invisible?

Post by TheMarkster »

You might need to find another way instead of using links. Maybe draft clones can work for you instead. Or try using duplicates.
andi11
Posts: 6
Joined: Mon Nov 22, 2021 9:13 am

Re: Making some features in a part customizable invisible?

Post by andi11 »

i placed the link inside an part object. Now it works. I hope that in feature releases the options in the link element will grow a little :D
Post Reply