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 その9

Posted at

概要

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

練習問題

SGIのロゴを作れ。

写真

image.png

サンプルコード


require 'sketchup.rb'

#Sgi_logo.new.run

class Sgi_logo
	def initialize
		@model = Sketchup.active_model
		@entities = @model.active_entities
		@x = 0
		@y = 0
		@z = 0
		@v = "x"
	end
	def run
		enjin(9, 0) #1
		enjin(8, 0) #2
		enjin(8, 3) #3
		enjin(9, 3) #4
		enjin(9, 0) #5
		enjin(8, 3) #6
		enjin(8, 1) #7
		enjin(9, 2) #8
		enjin(7, 1) #9
		enjin(9, 3) #10
		enjin(8, 0) #11
		enjin(8, 3) #12
		enjin(9, 3) #13
		enjin(9, 0) #14
		enjin(8, 3) #15
		enjin(8, 1) #16
		enjin(9, 2) #17
		enjin(7, 1) #18
	end
	def enjin(move, vec)
		p1 = Geom::Point3d.new(@x, @y, @z)
		x1, y1, z1 = 0, 0, 0
		case @v + String(vec)
		when "x0"
			y1 = move
			@v = "y"
		when "x1"
			z1 = move
			@v = "z"
		when "x2"
			y1 = -move
			@v = "-y"
		when "x3"
			z1 = -move
			@v = "-z"
		when "-x0"
			y1 = -move
			@v = "-y"
		when "-x1"
			z1 = -move
			@v = "-z"
		when "-x2"
			y1 = move
			@v = "y"
		when "-x3"
			z1 = move
			@v = "z"
		when "y0"
			z1 = move
			@v = "z"
		when "y1"
			x1 = move
			@v = "x"
		when "y2"
			z1 = -move
			@v = "-z"
		when "y3"
			x1 = -move
			@v = "-x"
		when "-y0"
			z1 = -move
			@v = "-z"
		when "-y1"
			x1 = -move
			@v = "-x"
		when "-y2"
			z1 = move
			@v = "z"
		when "-y3"
			x1 = move
			@v = "x"
		when "z0"
			x1 = move
			@v = "x"
		when "z1"
			y1 = move
			@v = "y"
		when "z2"
			x1 = -move
			@v = "-x"
		when "z3"
			y1 = -move
			@v = "-y"
		when "-z0"
			x1 = -move
			@v = "-x"
		when "-z1"
			y1 = -move
			@v = "-y"
		when "-z2"
			x1 = move
			@v = "x"
		when "-z3"
			y1 = move
			@v = "y"
		end
		case @v
		when "x", "-x"
			p2 = Geom::Point3d.new(@x + x1, @y + y1, @z + z1)
			circleBase1 = @entities.add_circle(p1, X_AXIS, 0.4, 24)
			circleBase2 = @entities.add_circle(p2, X_AXIS, 0.4, 24)
			curve = @entities.add_arc p2, Y_AXIS, X_AXIS, 0.4, 0, -Math::PI / 2 , 24
		when "y", "-y"
			p2 = Geom::Point3d.new(@x + x1, @y + y1, @z + z1)
			circleBase1 = @entities.add_circle(p1, Y_AXIS, 0.4, 24)
			circleBase2 = @entities.add_circle(p2, Y_AXIS, 0.4, 24)
			curve = @entities.add_arc p2, Y_AXIS, X_AXIS, 0.4, 0, -Math::PI / 2 , 24
		when "z", "-z"
			p2 = Geom::Point3d.new(@x + x1, @y + y1, @z + z1)
			circleBase1 = @entities.add_circle(p1, Z_AXIS, 0.4, 24)
			circleBase2 = @entities.add_circle(p2, Z_AXIS, 0.4, 24)
			curve = @entities.add_arc p2, Y_AXIS, X_AXIS, 0.4, 0, -Math::PI / 2 , 24
		end
		base = @entities.add_face(circleBase1)
		base1 = @entities.add_face(circleBase2)
		status = base1.followme(curve)
		line1 = @entities.add_line(p1, p2)
		status = base.followme(line1)
		@x, @y, @z = @x + x1, @y + y1, @z + z1
	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?