I have a model of a piping elbow in which I have given the on click demand to rotate on the blue axis through 90 degree increments. Is it possible to make the same component rotate around the x or y axis also in the same way.
Without seeing your model, I have to answer this generically.
I assume that, as part of your OnClick action, you are directly altering the RotZ attribute through a “set” or “animate” command.
If you want OnClick to affect more than one attribute, you have two choices:
- You can have multiple OnClick actions if you separate them with a semicolon.
- You can create a custom attribute, have the OnClick action act on that, then populate your rotation variables with formulas that refer to the custom attribute.
Hope this helps!
Thanks for responding to my post.
I am attaching a model which will make it very simple to see what I
would like to be able to do. The elbow needs to be able to connect with
all the pipes surrounding it.
If you could just add the attributes and send back the model, then it
will probably be quicker and easier for you.
Thanks again for your time.
dynamic; elbow.skp (704 KB)
You could add a small “target” components for each axes you want to rotate around. So instead of clicking anywhere on the elbow, you would need to click on the target to rotate around that particular axis. Here’s an example with only one axis. The target (child) component animates an attribute in its parent, and the parent uses the attribute as the rotation. You would of course need to add targets for the other axes.
dynamic-elbow-jf.skp (303.0 KB)
Thanks for the tip. It could very well be the answer. I will get back to
you as soon as I figure it out.
Nope. Sorry. I’m not going to do your work for you. However, I’m happy to point out a few things that, if done correctly, will make your task far easier:
Make the elbow a component - right now you have it as a group!
Change the axes of the component. When you create it, Sketchup will choose an origin and axis orientation of the component that will like on one corner of the bounding box. You need the components axis to be coincident with the models origin and axis. To help with this, I suggest adding guidelines within the group that duplicate the model’s axis. That way, once you’ve converted the group to a component, you’ll have geometry to which you can easily “snap to” then you change the axis of the component. You can always delete (or hide) the guidelines once the axis is correctly set.
Item 1 is essential. You can’t have a dynamic component if you don’t have a component! Item 2 will “only” make your attribute formulas far simpler, as you’ll have to deal only with rotation in each of the 3 axes. If you don’t correctly locate the axis, you’ll end up having to do some fairly complex calculations to determine the correct position values as well.
@jim_foltz’s target suggestion is intriguing. Since there is a pair of the pipes for each axis, and each pipe is (conceptually) representing it’s axis (one in the positive direction, one in the negative direction) you could make the pipes be the targets which, when clicked, rotate the elbow around the represented axis - one for +90 degree rotation and one for -90 degree rotation.This would, however, require you to have nested components as follows:
"Master" Component Enclosing: !-- Elbow !-- Pipe 1 !-- Pipe 2 !-- Pipe 3 !-- Pipe 4 !-- Pipe 5 !-- Pipe 6
The Elbow component would have attributes RotX, RotY and RotZ
The Pipe X components would have “on click” actions that appropriately alter the RotX, RotY and RotZ attributes of the Elbow component
Note that this approach will result in some (visually) counterintuitive results! Approaching this from a user’s point of view, I’d expect that click on a pipe would align one end of the elbow to that pipe, then clicking on a 2nd pipe would move the elbow to connect the two pipes, but that’s not how this would work!
Intuitively, I’d actually prefer that you structure this so that you can select which two pipes you want connected by the elbow, but that would likely be far easier to achieve in Ruby than in Dynamic Components. And as I’m not even a beginner at Ruby work, I can’t help you down that path.
Thanks again. I will need to sort out the group to component conversion first as this seems to be the first step. I will then try out the axis orientation, and probably get back to you with good news. Thanks for pointing out the component problem as I was under the impression that I had a component already.
---- Steven Dorst wrote ----