How to create Dynamic Component for clock? (just type the numbers)

Hello all, this is my first time using this forum. I want to ask if anyone knows how to create this? So you can just type the numbers you want and the clock hand will move. Thank you very much for your help. :smile:

Hello @lyn95 ,

Looks like you oculd achieve this simply by having parametric rotations :

  • For the minutes, you do a RotZ of MinuteValue / 60 * 360° (assuming the rotation starts at the top of the clock).
  • For the hours, another rotation of HourValue / 12 * 360. This would put the hour hand right at the HourValue. However, if you want to be accurate and have that hand in the middle of 10 and 11 when the minute hand is on 30 (for example), then you would need to add MinuteValue / 60 * 360 / 12. So the final code for the hours would be : HourValue /12 * 360° + MinuteValue / 60 * 360 / 12

Hello, sorry for the late reply and thank you. I tried following your formula but it didn’t work. Do I put it in RotZ like this?

Screenshot 2024-07-21 230008

Hi @lyn95 ,

What is not working exactly ? Do you have a MinuteValue attribute in your component ?

I don’t have Sketchup installed so I can’t test it but this should work. Probably as a negative value though so rather -MinuteValue / 60 * 360

Hi @MetalFingerz , no I don’t think I have a MinuteValue attribute in my component. How do I create it? Thank you.

How about this?

Corrected the hour hand math.

clock2

It requires entering the time in a 12 hour format, four digits with or without the colon between hours and minutes. You could add a second hand with a little more math.

4 Likes

Hi @daveR , thank you this looks amazing! It’s just like the screenshot I provided :slight_smile: I will try this tomorrow and let you know if it works or not for me.

Hi @DaveR I followed the exact formula and it worked! Thank you very much!


I have a slight problem though, when I open Component Options, it doesn’t show the blank space to type in the time like yours did.

I tried going into the group to click on the Clock Hands like yours, but it didn’t appear either. What did I do wrong?

Share the component.

How did you save the component after your created it? How did you add it into your model?

@DaveR I just saved it with the file name “Clock”, and haven’t added it into any models yet. Here is the Sketchup file:
Clock.skp (210.5 KB)

The file you saved and shared contains multiple levels of nesting with the clock hands buried deeply within the file. You also made the clock hands dynamic but did not make the CLOCK HANDS component dynamic. Here I’ve imported your file into a blank SketchUp file rather than opening it so that Outliner will show all of the levels of nesting. Note the Dynamic Component indications on the hands in the In Model components.

If you look at my screen shot you can see that I made a custom attribute for the Clock hands component which shows in the Component Options panel as an option the user can enter. Then that attribute is used by both the Hour and Minute hand components.

After creating the complete Dynamic Component don’t just save it as you would save other files. Create a component collection to hold it via the Components panel and, with the secondary pane open and set to that collection, drag the component thumbnail from In Model to the collection. When you want to use the component in future models, open the collection and drag the component into your project.

@DaveR

so should I explode the clock so that there aren’t too many levels of nesting?

and how do I make the “CLOCK HANDS” component dynamic? I did the same thing and made a custom attribute “Time”. Is there another step I must do?
image

Get rid of the excess levels of nesting so you have a component that just contains the two clock hands. Explode any levels above. Then set up the CLOCK HANDS component so the Time field can be seen in the Component Options panel and the user can enter the time.

dc

And, since I made these, here’s saving the component correctly so it is easy to use in other models.
comp save

And then actually using the component in a model.
comp use

@DaveR I got it! :slight_smile: I never knew about the “Display Rule” option when clicking on the arrow next to “Time”.

I have never saved components to use in other models, usually I just copy and paste them between models. I will try and learn more about creating my own library to save components, seems like a very convenient way to store them all in one place!

Thank you very much for your help :slight_smile: I am still a newbie in Dynamic Components so your answer was really helpful for me.

Much more efficient to save your components into collections for later use. Much easier than trying to remember what other model you used them in. If you set the component’s axes correctly, it’s also much easier to insert them where you want them. I set the origin of my Clock hands component slightly behind the hands and centered on the hole. That makes it siimple to place it at the center of the clock face and slightly forward of the face surface.

1 Like