0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

windows11で、sketchup6 その87

Last updated at Posted at 2025-04-29

概要

windows11に、sketchup6を入れてみた。
rubyで、3Dを書く。
練習問題やってみた。

練習問題

時計を動かせ。

写真

image.png

サンプルコード

起動 Tokei2.new

class Tokei2
	def initialize
		model = Sketchup.active_model
		entities = model.active_entities
		@view = model.active_view
		@id = 0
		group_circle = entities.add_group
		circle = group_circle.entities.add_circle [0, 1, 22], [0, 1, 0], 22
		circle_face = group_circle.entities.add_face circle
		circle_face.pushpull -0.1
		depth = 10
		width = 1
		pts = []
		pts[0] = [0, 0, 0]
		pts[1] = [width, 0, 0]
		pts[2] = [width, 0, depth]
		pts[3] = [0, 0, depth]
		group_hour = entities.add_group
		face_hour = group_hour.entities.add_face pts
		face_hour.material = "black"
		face_hour.pushpull 0.015
		trans = Geom::Transformation.translation [-0.5, 0, 21]
		group_hour.transform! trans
		rot = Geom::Transformation.new [0, 0, 22], [0, 1, 0], Time.now.hour * 30.degrees
		group_hour.transform! rot
		depth = 16
		width = 1
		pts = []
		pts[0] = [0, 0, 0]
		pts[1] = [width, 0, 0]
		pts[2] = [width, 0, depth]
		pts[3] = [0, 0, depth]
		group_minute = entities.add_group
		face_minute = group_minute.entities.add_face pts
		face_minute.material = "black"
		face_minute.pushpull 0.015
		trans = Geom::Transformation.translation [-0.5, 0, 21]
		group_minute.transform! trans
		rot = Geom::Transformation.new [0, 0, 22], [0, 1, 0], Time.now.min * 6.degrees
		group_minute.transform! rot
		depth = 20
		width = 1
		pts = []
		pts[0] = [0, 0, 0]
		pts[1] = [width, 0, 0]
		pts[2] = [width, 0, depth]
		pts[3] = [0, 0, depth]
		@group_second = entities.add_group
		face_second = @group_second.entities.add_face pts
		face_second.material = "red"
		face_second.pushpull 0.01
		trans = Geom::Transformation.translation [-0.5, 0, 21]
		@group_second.transform! trans
		rot = Geom::Transformation.new [0, 0, 22], [0, 1, 0], Time.now.sec * 6.degrees
		@group_second.transform! rot
		@id = UI.start_timer(1.0, true) {
			tick
		}
	end
	def tick
		rot = Geom::Transformation.new [0, 0, 22], [0, 1, 0], 6.degrees
		@group_second.transform! rot
		@view.invalidate
	end
end




以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?