sketchupでruby その6
概要
sketchupでrubyやってみた。
material使ってみた。
写真
サンプルコード
def colorbox
model = Sketchup.active_model
entities = model.active_entities
Sketchup.set_status_text "Please wait a little."
for x in 0..8 do
for y in 0..8 do
for z in 0..8 do
group = entities.add_group
entitie = group.entities
pts = []
pts[0] = [x * 10 + 5, y * 10 + 5, z * 10 + 5]
pts[1] = [x * 10 + 10, y * 10 + 5, z * 10 + 5]
pts[2] = [x * 10 + 10, y * 10 + 10, z * 10 + 5]
pts[3] = [x * 10 + 5, y * 10 + 10, z * 10 + 5]
base = entitie.add_face pts
base.pushpull 5
materials = model.materials
m = materials.add "ohi" + String(x) + String(y) + String(z)
m.color = Sketchup::Color.new(x * 32 , y * 32 , z * 32)
m.alpha = 0.7
entitie.each { |e|
case e
when Sketchup::Face
e.material = "ohi" + String(x) + String(y) + String(z)
end
}
end
end
end
end
def colorbox
model = Sketchup.active_model
entities = model.active_entities
Sketchup.set_status_text "Please wait a little."
for x in 0..8 do
for y in 0..8 do
for z in 0..8 do
group = entities.add_group
entitie = group.entities
pts = []
pts[0] = [x * 10 + 5, y * 10 + 5, z * 10 + 5]
pts[1] = [x * 10 + 10, y * 10 + 5, z * 10 + 5]
pts[2] = [x * 10 + 10, y * 10 + 10, z * 10 + 5]
pts[3] = [x * 10 + 5, y * 10 + 10, z * 10 + 5]
base = entitie.add_face pts
base.pushpull 5
materials = model.materials
m = materials.add "ohi" + String(x) + String(y) + String(z)
m.color = Sketchup::Color.new(x * 32 , y * 32 , z * 32)
m.alpha = 0.7
entitie.each { |e|
case e
when Sketchup::Face
e.material = "ohi" + String(x) + String(y) + String(z)
end
}
end
end
end
end
以上。
Author And Source
この問題について(sketchupでruby その6), 我々は、より多くの情報をここで見つけました https://qiita.com/ohisama@github/items/e55f938f0f687d462c4c著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .