Clicking on repeated (copied) sub component

I made a dynamic component for a ‘venetial blind’ (I hope this is the correct translation in English), made by two frame bars top and bottom, and a variable number of adjustable horizontal plates, copies of one original element.
I want to have a dual behaviour when clicking:

  1. rotate the elements of some degrees (i.e. 60) with one click
  2. raise or lower the elements pack with another click.

I did it separately and the two behaviours are correct.
The problem comes from where to click to select which animation must be performed.
If I insert the onClick event at model level I can only have one of the two animations.
Would be nice to use a single action at model level maybe distinguishing with a left / right button click.

I decided to apply the Raise/Lower event clicking on the top frame bar and this is ok.
Now I tried to delegate the second animation (turn/unturn) clicking on any of the elements. since this should be more intuitive, but actually only the clicked single element turns
Is there any way to extend (propagate) the click to all the elements copies?
Thanks

There is no way to have the ‘onclick behavior’ respond to left or right mouse button.
One could solve this by adding an additional attribute called ‘state’ that controls the next step. (Eg. First step would be setting the angle, the next step controlling the raise.
I think @nnijmeijer has got an example?

click on blades for angle, click on base for draw

DC in the file

amended too many spaces, weight was off center
venetian blind.skp (42.8 KB)

1 Like

Thanks pcmoor, but I forgotten to say that I use SU 2020 and I can not open your model
Could you please post it in this version?

venetian blind.skp (139.2 KB)

the trick is to place the copies in a lower nesting

note: if you do not move the mouse position, the animation will not swap

Thanks Mike. I can not find the example you stated.

I understand the logic of executing different formulas depending on a ‘state’ variable, lile a ‘switch’ in C, but I do not know how to arrange it in SU.

How do I tie the State change to the Animate formulas? I found that inserting an Animate inside another formula (i.e. =if(state=0, Animate…) is not allowed.
Againg, If I SET the state in the onClick event how can I then proceed with the Animate?

on behalf of “Jack”

venetian blind set states.skp (142.1 KB)

1 Like

Many thanks; I will study your solution and let you know.

Hi ‘pcmoor’, DCs are driving me crazy, I am totally lost in the fog.
I looked to your example, which was not too far from mine, and then I recreated the model with different, unpredicatable and illogic results.
I post 3 examples (translated in English for your convenience)
:

  1. ‘Veneziana_English_OK’: a working model with 4 ‘states’ (0,1,2,3), where state 0 is really unuseful but used to see the changes; this apparently working as expected…

  2. ‘Veneziana_English_bad’: the same as the previous model where I just deleted the state 0. This did not flow anymore as expected so I reintroduced the state 0 as in original; still, it does follow a differente path.
    It seems to me that the sequence of 3 ‘SET’ in the same formula (is it allowed, right?) loose the syncronization; some attributes changes on different states.

  3. ‘Veneziana_English_NoAction’: at the end, I returned to my very original attempt () where the onClick just advance the state and the formulas for ‘blade!rotX’ and ‘spacing’ should be change values depending on state. This model does not work at all: the state changes but the formulas are not evaluated…crazy.

I’m sure it is not a SU bug, so the bug must be in my brain…but where?
I really would appreciated your help if available, thanks

Veneziana_English_bad.skp (180.8 KB)
Veneziana_English_OK.skp (180.0 KB)
Veneziana_English_NoAction.skp (177.7 KB)

P.S. I use SU Pro 2020

Follow up to the previous post.
I wonder how and when the attributes, including ‘state’ are resetted; I mean: I load the model, click on it to correctly change the values, then I made a simple modification (not even in one of the involved formulas - maybe just a change in syntax somewhere) and then I click again on the model: the correct sequence is lost.
Forcing a model redraw does not fix the problem; if I close the file and reload it, everything turns ok.

I looked at the model Veneziana_Englisch_NoAction.skp.
The IF formulas were incorrect causing the DC to not work properly.
Note how you refer to other parameters and the use of periods and commas.

The options of the IF formula are separated with a comma ( , ).
IF(test,thenValue,elseValue)

The decimal point of units is separated in the formula with a period ( . ).
You do not need to enclose the parameters you refer to in " ".

Use an exclamation mark (!) to provide a value outside of a subcomponent.
Please note that you are referring to one level higher in the component hierarchy.

Tip: Refer with the help of parent! to the item one level up in the hierarchy.
This prevents future problems if component (definition) names are changed at a later stage.

Hereby the improved version in SU2020 format:
Veneziana_updated.skp (188.1 KB)

1 Like

Thanks nnijmeijer, your help was definitive.
Firstly let me say about the errors in my model: In the ‘rotX’ formula I forgotter to update it with a reference to the Veneziana upper lever; it was only a distraction.
The problem with periods and commas are serious instead, but not for my fault. I have some sighting problem and the two signs are barely visible to my eyes. I would need somehow to zoom-in the formula windows, but I do not find a way.
Now, I discovered and double checked that the real mistake in my formulas was to enclose the attibute reference with doublequotes; this prevents, at least for me, to execute the formula, without raising any error by SU; the formula is just skipped.

If this confirmed by you or someone else, your sentence:

  • You do not need to enclose the parameters you refer to in " ".

should be changed in:

  • You MUST not enclose the parameters you refer to in " ".

Anyway, finally the model is working very well, complete with all the actions and the choice of materials, but this is not important; it is important instead that I learned something really useful for the future use.
Thank again