Dynamic component: compute angle with the default axis of the world

Hello everyone,

I have just discovered dynamic components.

I am designing an object with feet. I would like that whatever the orientation of my object, these feet are always vertical. So, I have to measure the angle between my object and the Z axis of the world (default axis).

Is there a way to do this with the CURRENT(“attributeName”) function?

Thank you for your help

The “Current” formula only locks the rotation, you would need to cause a redraw for the leg to update to the new body orientation. Unless the body orientation is a DC action like onclick with animation or set, there is no connection (or trigger) between the DC ruby code and the SU main code, it does not update itself.

So build the model at rest, the legs will need to be nested and their rotation opposite to the body, multiple rotations nested again or work from one single attribute.

It may pay to upload your model and explain the complexity of the movements, simple one plane rotation is easy enough, but you may need some work around for multiple rotations and movement

DynamicTable.skp (171.7 KB)

Yes, it will be easier if I share my file with you.

The user can place the table in the orientation of his choice. The legs must always remain vertical. I would like the Pitch and Roll variables to be measured automatically (so I don’t need to adjust them manually)

My next question would be, how do you measure the length of each foot so that they all touch the ground?

You could work out the roll and pitch effects using trigonometry.

DynamicTable.skp (180.3 KB)

as far as “sensing” another surface, the faces would need to be DCs as well, with the connection formulas in the table DC

I would, instead of rotating, try using the vertical scale of the object to drive the rotation angle of the table surface and the position of the “upper” pair of legs.

But then wouldn’t you have to reposition the leg positions as well for the roll and pitch, this way they remain attached

Of course, and fix their scale and position, but not angle. I was just wondering if the trigonometry would be a bit simpler. The first pair of legs just needs to stay in place. I’ll try something when I am back from my errands.

Anyway note I attached the solution using basic trig for the roll, width/2sin(roll) then allowing for roll of the pitch by multiple the length/2sin(pitch) with cos(roll)

this is probably a better view of this solution with component axes on

Hello and thank you for your work.

However, I am clarifying my questions.
I would like that if I place the table above a stairs or a sloping surface, the length of the legs will automatically adjust so that they come into contact with the surface. Since we do not know the ground, we must therefore measure the distance for each foot between the corner of the table and the ground. Is that possible?

Can the pitch and roll angle of the table be automatically measured against the sketchup world axis?
Thus the user would not need to adjust them manually.