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

Posted at

概要

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

練習問題

sketchupでペジェ曲線を描くrubyスクリプトは

写真

image.png

サンプルコード


def create_bezi
	model = Sketchup.active_model
	entities = model.active_entities
	p0x = 0
	p0y = 0
	p1x = 10
	p1y = 10
	p2x = 20
	p2y = 20
	p3x = 30
	p3y = 0
	prompts = ["p0 x", "p0 y", "p1 x", "p1 y", "p2 x", "p2 y","p3 x", "p3 y"]
	values = [p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y]
	results = UI.inputbox(prompts, values, "Bezier")
	if results
		p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y = results
	else
		return
	end
	x2 = 0 
	y2 = 0
	(100).times { |i|
		t	= (i.to_f) / 100
		x1 = (1 - t) * (1 - t) * (1 - t) * p0x + 3 * t * (1 - t) * (1 - t) * p1x + 3 * t * t * (1 - t) * p2x + t * t * t * p3x
		y1 = (1 - t) * (1 - t) * (1 - t) * p0y + 3 * t * (1 - t) * (1 - t) * p1y + 3 * t * t * (1 - t) * p2y + t * t * t * p3y
		if i > 1
			line1 = entities.add_line [x1, y1, 0] , [x2, y2, 0]
		end
		x2 = x1
		y2 = y1
	}
	UI.messagebox "ok"
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?