Using a Object, and making all the properties visible

Find and share HowTos to various installations / configurations!
9 posts • Page 1 of 1
Tykes
Posts:14
Joined: Thu Jul 14, 2016 9:51 pm

Using a Object, and making all the properties visible

Post by Tykes »

I'm very green to OA, and I'm trying to create a panel that allows on mouse click, to make an object i created and saved in it's own panel, become visible without having to type every single element inside the object.
Something like if the panel's name is VFD


VFD.*visible = TRUE;

Any help will be great thanks! :)

EER
Posts:17
Joined: Fri Jun 12, 2015 1:31 pm

Re: Using a Object, and making all the properties visible

Post by EER »

I would guess there is no elegant way to do this.

But is this function really necessary? How many visibility properties does your object have?


Edit:
I am not sure it applies to your problem but maybe the use of visibility layers can help.

RudiKreiner
Posts:198
Joined: Mon May 16, 2011 2:10 pm

Re: Using a Object, and making all the properties visible

Post by RudiKreiner »

It might be easier to use the functions addSymbol() and removeSymbol() instead.
One difference that this approach has though is that any scripting in the symbol (ie reference) that you are adding will only run when it is visible (ie. added)

putting the reference in an diffferent layer and then making that layer visible or invisible should work too, if the above side effects cause a problem.

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: Using a Object, and making all the properties visible

Post by mkoller »

The object you created in a separate panel is inserted into any other panel as a Panel Reference.
The reference has a name. Simply use this name to address this instance and use
setValue("theName", "visible", false);
In version

EER
Posts:17
Joined: Fri Jun 12, 2015 1:31 pm

Re: Using a Object, and making all the properties visible

Post by EER »

Martin Koller wrote:
The object you created in a separate panel is inserted into any other panel as a Panel Reference.
The reference has a name. Simply use this name to address this instance and use
setValue("theName", "visible", false);
In version

RudiKreiner
Posts:198
Joined: Mon May 16, 2011 2:10 pm

Re: Using a Object, and making all the properties visible

Post by RudiKreiner »

I had always thought that setValue did not work for a whole reference but if Martin says it does, then it was time for me to try it again.
Of course he is right, but what does not work is getValue, which I noticed when I tried to make a function to toggle the visible state, like this:

bool state;
setValue("theName", "visible", state);
setValue("theName", "visible", !state);

where I get this error:
Object does not know the attribute "visible" for "getValue()"

I guess that makes sense because the object can contain several elements whose visible states may not all be the same.

So I fixed up my test by declaring state in the scope lib of the panel and writing the script like this

state = !state;
setValue("theName", "visible", state);

So I have learned that setValue actually does work for whole references (not only for visible attribute but others like backCol too)

but getValue doesn't, for the plausible reason above.

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: Using a Object, and making all the properties visible

Post by mkoller »

Absolutely correct.
The following attributes are just write-only and are distributed to all shapes/sub-groups inside:
enabled, visible, foreCol, backCol, color

EER
Posts:17
Joined: Fri Jun 12, 2015 1:31 pm

Re: Using a Object, and making all the properties visible

Post by EER »

Rudi Kreiner wrote:
I had always thought that setValue did not work for a whole reference but if Martin says it does, then it was time for me to try it again.
Of course he is right, but what does not work is getValue, which I noticed when I tried to make a function to toggle the visible state, like this:

bool state;
setValue("theName", "visible", state);
setValue("theName", "visible", !state);

where I get this error:
Object does not know the attribute "visible" for "getValue()"

I guess that makes sense because the object can contain several elements whose visible states may not all be the same.

So I fixed up my test by declaring state in the scope lib of the panel and writing the script like this

state = !state;
setValue("theName", "visible", state);

So I have learned that setValue actually does work for whole references (not only for visible attribute but others like backCol too)

but getValue doesn't, for the plausible reason above.

The "getValue" does work when you try to get values from only one "subobject" in a reference panel.
In this example a text-object inside another panel:

string s;
getValue("object.text_a", "text", s);

Of course, you have to know what objects are inside and I think it will make code messy and difficult to understand if used to often.

Tykes
Posts:14
Joined: Thu Jul 14, 2016 9:51 pm

Re: Using a Object, and making all the properties visible

Post by Tykes »

Thank you all for submitting this help out a lot,
the setValue worked out. Thanks again :D

9 posts • Page 1 of 1