Ruby-Sketchup 更改面部颜色
Ruby-Sketchup change color of faces
我想将此形状的顶部着色为 rfClr,有什么想法吗?我可以把整个东西改成灰色,但是如何把顶部变成蓝色?
l=100
w=60
h=20
hl=8
slope=4
clr='Gray'
rfClr='blue'
ent = Sketchup.active_model.entities
#---------Clear All
Sketchup.active_model.entities.clear!
#----------------
model = Sketchup.active_model
model.start_operation "Create Box"
#-----------------------------------------------------------------------------
entities = model.active_entities
group = entities.add_group
entities = group.entities
group.name="Box"
@pt0 = [0, 0, 0]
@pt1 = [0, 0, h*12+hl]
@pt2 = [w*12/2, 0, 12*h+hl+(w/2)*slope]
@pt3 = [w*12, 0, 12*h+hl]
@pt4 = [w*12, 0, 0]
newface = entities.add_face(@pt0, @pt1, @pt2, @pt3 , @pt4)
newface.material=Sketchup::Color.new clr
#newface.reverse!
newface.pushpull l*12
我找到了这个答案。
我猜它会找到具有 z 值的面
vfaces = entities.grep(Sketchup::Face).find_all{|f| f.normal.z.abs != 0 }
vfaces.each{|f| f.material = rfClr }
我想将此形状的顶部着色为 rfClr,有什么想法吗?我可以把整个东西改成灰色,但是如何把顶部变成蓝色?
l=100
w=60
h=20
hl=8
slope=4
clr='Gray'
rfClr='blue'
ent = Sketchup.active_model.entities
#---------Clear All
Sketchup.active_model.entities.clear!
#----------------
model = Sketchup.active_model
model.start_operation "Create Box"
#-----------------------------------------------------------------------------
entities = model.active_entities
group = entities.add_group
entities = group.entities
group.name="Box"
@pt0 = [0, 0, 0]
@pt1 = [0, 0, h*12+hl]
@pt2 = [w*12/2, 0, 12*h+hl+(w/2)*slope]
@pt3 = [w*12, 0, 12*h+hl]
@pt4 = [w*12, 0, 0]
newface = entities.add_face(@pt0, @pt1, @pt2, @pt3 , @pt4)
newface.material=Sketchup::Color.new clr
#newface.reverse!
newface.pushpull l*12
我找到了这个答案。 我猜它会找到具有 z 值的面
vfaces = entities.grep(Sketchup::Face).find_all{|f| f.normal.z.abs != 0 }
vfaces.each{|f| f.material = rfClr }