亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

Sketchup 程序自動化(三)路徑、平面拉升

標簽:
Ruby

路径

个人理解,路径实质上是多条连续的线段进行组合起来具备某些特殊意义,最主要的作用还是为了让自定义的截面进行跟随形成一些我们想要的模型。

代码演示会更直接理解一点:

model = Sketchup.active_model
entities = model.entities
sel = model.selection

pt0 = Array.new()# 原点用数组(矩阵)表示orignPoint = Array.new(3,0)# 绘制简易曲线路径for i in 90..270
    pt = [orignPoint.x + i,orignPoint.y + 100 * Math::sin(i.degrees),orignPoint.z]
    pt0 << pt
end
curveline = entities.add_curve pt0

绘制面:

# 新建面的顶点数组facePointArr = [
    [0,0,10],
    [10,0,10],
    [10,10,10],
    [0,10,10]
]

test_face = entities.add_face facePointArr# 此时我们知道 entities 数组中就有了 5个实体 1曲线、1面、4线# 选中一个面# 提取出这个面的顶点sel.add test_face
verticesArr = sel[0].verticesfor item in verticesArr
    puts item.positionend

补充关于方向:

#  Sketchup 某些矩阵特定意义#  X 轴 :[1,0,0] [-1,0,0]#  Y 轴 :[0,1,0] [0,-1,0]#  Z 轴 :[0,0,1] [0,0,-1]#  某些函数(add_circle、add_nogn)需要指定某些面进行绘制,就要设置normal 参数#  XY面 设置 [0,0,1] [0,0,-1]#  XZ面 设置 [0,1,0] [0,-1,0]#  ZY面 设置 [1,0,0] [-1,0,0]# 我们在建立面时,并没有指定方向# 但我们发现:Z轴不为 0 是 [0,0,1] 为 0 时是 [0,0,-1]# 这个与存储与取出机制有关,实际应用中 正负影响不大puts test_face.normal# 面朝向反向reverseFace = test_face.reverse!# 面的面积 (这里的单位 10 * 10 平方英寸)puts reverseFace.area# 组成面的线对象数组puts reverseFace.edges

pt = [5,5,-10]# 对于 Face 与 点 关系的判断result = reverseFace.classify_point(pt)
puts result# 官方提供了一个枚举类型# 点在面里if result == Sketchup::Face::PointInside
  puts "#{pt.to_s} is inside the face"end# 点在端点上if result == Sketchup::Face::PointOnVertex
  puts "#{pt.to_s} is on a vertex"end# 点在边线上if result == Sketchup::Face::PointOnEdge
  puts "#{pt.to_s} is on an edge of the face"end# 点与面处于同一平面if result == Sketchup::Face::PointNotOnPlane
  puts "#{pt.to_s} is not on the same plane as the face"end

平面拉升

# pushpull 推的方向是按照图形的normal方向# face 没有对于向量进行定义,所以pushpull按照的是face的normal值的反向reverseFace.pushpull 10# 推一个圆柱体circle = entities.add_circle [0,0,40],[0,0,1],5circle_face = entities.add_face circle
circle_face.pushpull 20# followme 进行3D模型构建# 使用followme  对模型进行环切cut_face = entities.add_face Geom::Point3d.new(0,0,10),Geom::Point3d.new(2,2,10),Geom::Point3d.new(0,0,8)
cut_face.followme reverseFace.edges# followfacefollowFace = [
  Geom::Point3d.new(100,95,-5),
  Geom::Point3d.new(100,105,-5),
  Geom::Point3d.new(100,105,5),
  Geom::Point3d.new(100,95,5)
]

followFace = entities.add_face followFace# 跟随的界面一定是在路径的一端followFace.followme curveline



作者:ZhengRongXing
链接:https://www.jianshu.com/p/50c3e44ed0c4

點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消