Sketchup Ruby,为Face添加纹理

问题描述 投票:0回答:1

我正在使用它,添加绘制框,然后着色框。

l=96
w=60
h=60
clr='Gray'
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, l*12, 0]
@pt2 = [w*12.0, l*12, 0]
@pt3 = [w*12, 0, 0]

newface = entities.add_face(@pt0, @pt1, @pt2, @pt3)
newface.material = Sketchup::Color.new clr
newface.reverse!
newface.pushpull h*12

我还想添加纹理,但无法找到如何做到这一点。

像“金属波纹闪亮”,但一直未能找到如何做到这一点。

有人知道如何用红宝石添加纹理吗?

enter image description here

ruby sketchup
1个回答
0
投票

你想要的元素是Texture。这是暴露有关图像纹理信息(例如宽度和高度,平均颜色等)的类对象。

设置纹理的最简单方法是直接在材质上。

newface.material = Sketchup::Color.new clr
newface.material.texture = "C:\\MyMaterialDirectory\\MyMaterial.jpg"

显然,该文件需要是一个有效的图像并在相应的目录中。

https://ruby.sketchup.com/Sketchup/Texture.html

© www.soinside.com 2019 - 2024. All rights reserved.