In both SU 2014 and 2015 pro when using “onclick” and the “animate” function to rotate a component about the “Y” axis it does not work properly for me for values of 0 to 180 degrees. In other words when I enter this "animate(“RotY”,0,180) it fails on the second click. First click rotates the component 180 degrees, but second click fails to return it to zero degrees. The components seems to want to return and animation seems to show it going about 100 degrees towards the zero value, but it bounces back to the 180 degree point. Also when looking at the value for RotY it does not show 180 when the component is rotate on the first click, it show no value at all. This happens in both 2014 and 2015 recently downloaded and installed. Strangely the values from 0 to 180 degrees work just fine for RotZ and RotX, but not RotY Equally strange all other values work fine in the RotY axis except 0 to 180 degrees.
Could you attach the model without any changes.
Yes, here is the model. It is a small block top red the rest green. I set up a rotation about RotY and then an onclick function. It flips over 180 degrees on the first click but refuses to return to 0 degrees on the second click. Notice also there is no value shown in the RotY box when the component is flipped 180 degrees. I am planning to take my other computer and try this on it also to reduce this down to either hardware or software.
Thanks for the attention. Until I find a solution I will just adjust my models that I want to rotate between 0 and 180 degrees to do so about the X axis.
I just loaded SU pro 2015 64bit version on my other computer. It is doing the very same thing as my 32bit machine. Both are running Windows 7 one is Starter and the other is Home Premium.
I am able to reproduce this. Clearly buggy behavior.
A work-around would be to use an animation attribute, similar to the “anim” attr shown in the image.
Not only should you avoid using RotX, RotY and RotZ directly in an OnClick → animate(____,value1,valu2 etc.) but use an extra atribute as Jim mentions, but do not forget to wrap it in quotatian marks to accept negative values.
Example:
RotY _______ =angle
Onclick _____ animate(“*angle”,0,90,180,405,-70)
angle ______ 0
Jim,
Strange the values of 0 to 180 work for the “X” and “Z” axis, but not the “Y”. Equally strange all other values on the “Y” axis work except for these two values. Well thanks for the help and advice. Now I don’t have to rotate all my components which I plan to rotate about the Y axis to make the model work. I see a lot of examples out on the net showing my syntax of “animate(“RotY”,angle 1, angle 2, …… angle N) being used. I guess no one tried 0 to 180 on the Y axis or this would have been reported sooner.
Thanks again.
Steven
Jim,
I was wondering if you might offer some insight into how DC work regarding passing of variable values from component to component.
I have been having trouble checking on values of a component from within another component using the if statement.
cid:image002.png@01D051A4.082B5B90
As an example consider the picture above. It has three components named “leftblock, rightblock and “circle”. Also it and a parent component named “frame”.
Say I want to do an axis rotation about any given axis on “leftblock”. I then want to decide if “circle” should be hidden based upon the value of rotation for “leftblock” after an onclick. I find that I can’t inspect the value of the rotation angle in “leftblock” directly from “circle” using the hidden command and an if statement such as;
Hidden if(leftblock!Rot Angle=180,1,0)
which would change the value of the hidden attribute from 0 to 1 and hide “circle”. I must place the rotation value of “leftblock” inside of the parent component so the “if statement” will work and return the proper value to either hide or unhide component “circle”.
From this I have come to the conclusion the following:
· Inspection of values from within any given component which is at the same level as the component making inspection CAN’T be done directly.
· Only values placed in the parent can be inspected from child components
· There is no way to assign global variables within the parent component
· Any attribute where one component is desired to change or alter another component requires both components be within one encompassing parent component.
Can you tell me if these thoughts are correct and offer any other insights into how values of variables are passed from component to component?
Sincerely,
Steven
@bpetnoi1 - the first image did not post. Also, it makes things easier if you can attach the model.
Jim,
I was wondering if you might offer some insight into how DCs work regarding passing of variable values from component to component, especially from child to child components.
I have been having trouble checking on values of a child component from within another child component using the if statement. In the example I attached I was trying to inspect the value of animation attribute “rz” or rotate about Z for the component named “left” the yellow block to see if it had been rotated 180 degrees. When I place the animation attribute “rz” within the “left” component the component rotates properly, but when I try to inspect the value of “rz” from the component name “legs” with the if statement it does not evaluate to true or false even though “rz” clearly shows 180 of rotation. When I move “rz” up to the parent component which in my example I call “frame” everything works correctly, as when the yellow block rotates onto the top of the green block through 180 degrees the legs are then hidden.
I am wondering why I can’t just use this statement from within the “legs” component. “=if(left!rz=180,1,0)” and leave the animation attribute “rz” in the same child component. In order to get the DC to work properly I must place the animation attribute “rz” within the parent component and inspect it with this statement “if(frame!rz=180,1,0)”. It seems I can’t look at variable values in other child components from another child component.
From this I have come to the conclusion the following:
· Inspection of values from within any given component which is at the same level as the component making inspection CAN’T be done directly.
· Only values placed in the parent can be inspected from child components
· There is no way to assign global variables within the parent component
Can you tell me if these thoughts are correct and offer any other insights into how values of variables are passed from component to component?
Sincerely,
Steven
folding table.skp (84 KB)
You are correct in that there are no “global” variables in DC’s. An attribute can access and be accessed by parent, child, or sibling components. If you need to use an attribute across deeper relationships, you need to pass the value to each intermediate component. It is common to use the same attribute name but that is not required.
There is a useful although undocumented attribute named “Parent” which can be used whenever you need to access an attribute in a parent from a child. It can make replacing components easier since you don’t need to rename the parent name in any formulas.
When creating Dynamic Components, it is usually safe to think they are updated outside-in (or top-bottom.) The top-level component typically is where use-editable attributes are defined. Child components reach up to the parent for the values.
Is there a reason you have the onClick
function on a child component rather than the top-level? Do you want the component to animate only when the user clicks the yellow component, or when they click anywhere?
This is how I would do it:
Jim,
Thanks for the information. Yes having the onclick on the child component was intentional as I wanted the DC to activate only when the yellow block was clicked. I was thinking that sometime in the future I might like to click on the other block to have something else done. I am trying different approaches in my attempt to learn how one can manipulate DCs differently so when I finally go to the model I really want to work with I will not be so frustrated with mistakes and dead ends.
So is it true that I can’t inspect the value of a variable from child to child and expect a value to be returned as in the example below? It would seem logical that I could inspect the value of “ry” in the “left” child component and have its value returned to the “legs” component to be used to hide or not hide the “legs” component, but it doesn’t work for me. I must place the “ry” in the parent component to make it work. When the yellow component is folded the value in “ry” clearly is shown as 180, but the Hidden attribute is not evaluated correctly in the “legs” component. I included the model this time which uses this code and does not work as intended.
Thank you for the info on the “parent” attribute, which I already found in reading on the net. I can see where it could be useful for naming changes.
So do you know a way to get the value of a user defined variable in a child component and pass it to another child component, without having that user defined variable reside in the parent component?
Steven
folding table NOT working.skp (84.3 KB)
Try adding an attribute in the left component named “show_legs” , and then use it in the hidden formula in the legs component.
So basically move the formula from the legs component to the left component, and reference it from legs.
This should work. It could be failing because the comparison may be performed before the animation is complete. Or that the legs component is simply not being updated by the dc engine because no top-level attributes are changing. I don’t know enough about dc internals to know for sure.
I know how to get it to work. In my mind it is a over site bug in sketch-up. If you enter any variable or formula into the RotZ or X,Y it loses its degree Value and takes on a decimal or mm valve and so errors are produced.
I know how to get it to work. In my mind it is a over site bug in sketch-up. If you enter any variable or formula into the RotZ
or X,Y it loses its degree Value and takes on a decimal or mm valve and so errors are produced.
the issue is to do with the placement of the onclick function. to drive separate children it must be placed in the parent,
folding table working.skp (93.4 KB)
Was having similar problem, solved thanks to you (again)!