windows11で、sketchup6 その101

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

# 練習問題
ハノイの塔をアニメーションせよ。

# 写真

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/18104/4c398adc-3a3e-4627-af6c-493ed778c2e4.png)

# サンプルコード

```

# Hanoi.new

require 'sketchup.rb'


class Hanoi
	def initialize
		entities = Sketchup.active_model.entities
		@disk3 = entities.add_group
		tube_inner = @disk3.entities.add_circle Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1), 2, 8
		tube_outer = @disk3.entities.add_circle Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1), 8, 20
		cross_section_face = @disk3.entities.add_face tube_outer
		inner_face = @disk3.entities.add_face tube_inner
		@disk3.entities.erase_entities inner_face
		cross_section_face.pushpull -2, false
		trans = Geom::Transformation.translation [0, 0, 0]
		@disk3.transform! trans
		@disk2 = entities.add_group
		tube_inner = @disk2.entities.add_circle Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1), 2, 8
		tube_outer = @disk2.entities.add_circle Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1), 6, 20
		cross_section_face = @disk2.entities.add_face tube_outer
		inner_face = @disk2.entities.add_face tube_inner
		@disk2.entities.erase_entities inner_face
		cross_section_face.pushpull -2, false
		trans = Geom::Transformation.translation [0, 0, 2]
		@disk2.transform! trans
		@disk1 = entities.add_group
		tube_inner = @disk1.entities.add_circle Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1), 2, 8
		tube_outer = @disk1.entities.add_circle Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1), 4, 20
		cross_section_face = @disk1.entities.add_face tube_outer
		inner_face = @disk1.entities.add_face tube_inner
		@disk1.entities.erase_entities inner_face
		cross_section_face.pushpull -2, false
		trans = Geom::Transformation.translation [0, 0, 4]
		@disk1.transform! trans
		poolA = entities.add_group
		tube_outer = poolA.entities.add_circle Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1), 1, 8
		cross_section_face = poolA.entities.add_face tube_outer
		cross_section_face.pushpull -20, false
		trans = Geom::Transformation.translation [0, 0, 0]
		poolA.transform! trans
		poolB = entities.add_group
		tube_outer = poolB.entities.add_circle Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1), 1, 8
		cross_section_face = poolB.entities.add_face tube_outer
		cross_section_face.pushpull -20, false
		trans = Geom::Transformation.translation [20, 0, 0]
		poolB.transform! trans
		poolC = entities.add_group
		tube_outer = poolC.entities.add_circle Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1), 1, 8
		cross_section_face = poolC.entities.add_face tube_outer
		cross_section_face.pushpull -20, false
		trans = Geom::Transformation.translation [40, 0, 0]
		poolC.transform! trans
		@state = 0
		@tid = UI.start_timer(1.9, true) {
			tick
		}
	end
	def tick
		case @state
#move disk1 from A to B
		when 0
			trans = Geom::Transformation.translation [0, 0, 16]
			@disk1.transform! trans
		when 1
			trans = Geom::Transformation.translation [20, 0, 0]
			@disk1.transform! trans
		when 2
			trans = Geom::Transformation.translation [0, 0, -20]
			@disk1.transform! trans
#move disk2 from A to C
		when 3
			trans = Geom::Transformation.translation [0, 0, 18]
			@disk2.transform! trans
		when 4
			trans = Geom::Transformation.translation [20, 0, 0]
			@disk2.transform! trans
		when 5
			trans = Geom::Transformation.translation [20, 0, 0]
			@disk2.transform! trans
		when 6
			trans = Geom::Transformation.translation [0, 0, -20]
			@disk2.transform! trans
#move disk1 from B to C
		when 7
			trans = Geom::Transformation.translation [0, 0, 20]
			@disk1.transform! trans
		when 8
			trans = Geom::Transformation.translation [20, 0, 0]
			@disk1.transform! trans
		when 9
			trans = Geom::Transformation.translation [0, 0, -18]
			@disk1.transform! trans
#move disk3 from A to B
		when 10
			trans = Geom::Transformation.translation [0, 0, 20]
			@disk3.transform! trans
		when 11
			trans = Geom::Transformation.translation [20, 0, 0]
			@disk3.transform! trans
		when 12
			trans = Geom::Transformation.translation [0, 0, -20]
			@disk3.transform! trans
#move disk1 from C to A
		when 13
			trans = Geom::Transformation.translation [0, 0, 18]
			@disk1.transform! trans
		when 14
			trans = Geom::Transformation.translation [-20, 0, 0]
			@disk1.transform! trans
		when 15
			trans = Geom::Transformation.translation [-20, 0, 0]
			@disk1.transform! trans
		when 16
			trans = Geom::Transformation.translation [0, 0, -20]
			@disk1.transform! trans
#move disk2 from C to B
		when 17
			trans = Geom::Transformation.translation [0, 0, 20]
			@disk2.transform! trans
		when 18
			trans = Geom::Transformation.translation [-20, 0, 0]
			@disk2.transform! trans
		when 19
			trans = Geom::Transformation.translation [0, 0, -18]
			@disk2.transform! trans
#move disk1 from A to B
		when 20
			trans = Geom::Transformation.translation [0, 0, 20]
			@disk1.transform! trans
		when 21
			trans = Geom::Transformation.translation [20, 0, 0]
			@disk1.transform! trans
		when 22
			trans = Geom::Transformation.translation [0, 0, -16]
			@disk1.transform! trans
		end
		@state += 1
	end
end





```

以上。