概要
windows11に、sketchup6を入れてみた。
rubyで、3Dを書く。
練習問題、やってみた。
練習問題
sketchupで、view.inputpointを、使え。
写真
サンプルコード
起動 Sketchup.active_model.select_tool InputPointToolTests.new
require 'sketchup.rb'
class InputPointToolTests
def activate
puts "activate called"
@status = 0
depth = 10
width = 10
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
face = entities.add_face pts
face.pushpull 10
end
def deactivate(view)
puts "deactivate called"
end
def onLButtonDown(flags, x, y, view)
case @status
when 0
ip1 = Sketchup::InputPoint.new
ip2 = view.inputpoint x, y
ip1.copy! ip2
status = ip1 == ip2
if (status)
UI.messagebox status
else
UI.messagebox "Failure"
end
@status += 1
when 1
ip1 = view.inputpoint x, y
ip = ip1.clear
if (ip)
UI.messagebox ip
else
UI.messagebox "Failure"
end
@status += 1
when 2
ip1 = Sketchup::InputPoint.new
ip2 = view.inputpoint x, y
ip = ip1.copy! ip2
if (ip)
UI.messagebox ip
else
UI.messagebox "Failure"
end
@status += 1
when 3
ip1 = view.inputpoint x, y
dof = ip1.degrees_of_freedom
if (dof)
UI.messagebox dof
else
UI.messagebox "Failure"
end
@status += 1
when 4
ip1 = view.inputpoint x, y
d = ip1.depth
if (d)
UI.messagebox d
else
UI.messagebox "Failure"
end
@status += 1
when 5
ip1 = view.inputpoint x, y
status = ip1.display?
if (status)
UI.messagebox status
else
UI.messagebox "Failure"
end
@status += 1
when 6
ip1 = view.inputpoint x, y
ip = ip1.draw view
if (ip)
UI.messagebox ip
else
UI.messagebox "Failure"
end
@status += 1
when 7
ip1 = view.inputpoint x, y
e = ip1.edge
if (e)
UI.messagebox e
else
UI.messagebox "Failure"
end
@status += 1
when 8
ip1 = view.inputpoint x, y
f = ip1.face
if (f)
UI.messagebox f
else
UI.messagebox "Failure"
end
@status += 1
when 9
ip1 = view.inputpoint x, y
s = ip1.pick view, x, y
if (s)
UI.messagebox s
else
UI.messagebox "Failure"
end
@status +=1
when 10
ip1 = view.inputpoint x,y
point = ip1.position
if (point)
UI.messagebox point
else
UI.messagebox "Failure"
end
@status +=1
when 11
ip1 = view.inputpoint x, y
tip = ip1.tooltip
if (tip)
UI.messagebox tip
else
UI.messagebox "Failure"
end
@status += 1
when 12
ip1 = view.inputpoint x, y
tform = ip1.transformation
if (tform)
UI.messagebox tform
else
UI.messagebox "Failure"
end
@status += 1
when 13
ip1 = view.inputpoint x, y
status = ip1.valid?
if (status)
UI.messagebox status
else
UI.messagebox "Failure"
end
@status += 1
when 14
ip1 = view.inputpoint x, y
vertex = ip1.vertex
if (vertex)
UI.messagebox vertex
else
UI.messagebox "Failure"
end
@status += 1
when 15
UI.messagebox "ok"
@status += 1
end
end
end
以上。