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

Posted at

概要

windows11に、sketchup6を入れてみた。
rubyで、3Dを書く。
FunShapes.rb、見つけたのでやってみた。

写真

image.png

サンプルコード

def jet_surface
	prompt = ["# Iterations : "]
	params = [5]
	result = inputbox(prompt, params, "Imput Jet Surface Parameters")
	if result
		it = [2, result[0]].max
	else
		return
	end
	entities = Sketchup.active_model.entities
	group = entities.add_group
	group_ents = group.entities
	mesh_js = Geom::PolygonMesh.new
	indexes = [0]
	aux_vect = []
	for ind_u in (0..2 * it)
		u = Math::PI * ind_u / (2 * it)
		for ind_v in (0..2 * it - 1)
			v = 2 * Math::PI * ind_v / (2 * it)
			x = (1 - cos_hip(u)) * Math::sin(u) * Math::cos(v) / 2
			y = (1 - cos_hip(u)) * Math::sin(u) * Math::sin(v) / 2
			z = cos_hip(u)
			pt = Geom::Point3d.new(1 * x, 1 * y, 1 * z)
			index = mesh_js.add_point(pt)
			indexes.push(index)
		end
	end
	for ind_u in (1..2 * it)
		for ind_v in (1..2 * it - 1)
			aux_ind = 2 * it * (ind_u - 1) + ind_v
			aux_vect = [indexes[aux_ind], indexes[aux_ind + 1], indexes[aux_ind + 2 * it]]
			mesh_js.add_polygon(aux_vect)
			aux_vect = [indexes[aux_ind + 1], indexes[aux_ind + 1 + 2 * it], indexes[aux_ind + 2 * it]]
			mesh_js.add_polygon(aux_vect)
		end
		aux_vect = [indexes[aux_ind + 1], indexes[aux_ind + 2 - 2 * it], indexes[aux_ind + 1 + 2 * it]]
		mesh_js.add_polygon(aux_vect)
		aux_vect = [indexes[aux_ind + 2 - 2 * it], indexes[aux_ind + 2], indexes[aux_ind + 1 + 2 * it]]
		mesh_js.add_polygon(aux_vect)
	end
	group_ents.add_faces_from_mesh(mesh_js)
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?