Sketchup 程式自動化(三)路徑 平面拉公升

2021-09-11 13:49:44 字數 2923 閱讀 7469

個人理解,路徑實質上是多條連續的線段進行組合起來具備某些特殊意義,最主要的作用還是為了讓自定義的截面進行跟隨形成一些我們想要的模型。

**演示會更直接理解一點:

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

endcurveline = 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].vertices

for item in verticesarr

puts item.position

end複製**

補充關於方向:

#  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 "# is inside the face"

end# 點在端點上

if result == sketchup::face::pointonvertex

puts "# is on a vertex"

end# 點在邊線上

if result == sketchup::face::pointonedge

puts "# is on an edge of the face"

end# 點與面處於同一平面

if result == sketchup::face::pointnotonplane

puts "# 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],5

circle_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

# followface

followface = [

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

複製**

自動化問題三

1 以下 json 格式資料,錯誤的是 您的答案是 a c 答案分析 a錯誤,首先a為json物件,物件要求屬性的key必須為加雙引號。b正確。c錯誤,加大括號的表示物件,物件必須由屬性組成,屬性是由鍵值對組成。d正確。2 下列對於request引數說法不正確的是 a.params 引數傳遞的是字典...

web自動化 三 pytest 引數化

前言 環境 centons 7.6 python 3.6 chrome 80.0.3987.132 chromedriver 80.0.3987.16 selenium 3.14 自動化測試過程中,經常會出有些場景需要測試多種場景,例如 常見的登入頁面需要對賬號的型別,種類,長度等分別進行測試,引用...

0317 2辦公自動化(三)

要求 資料 計數 import pandas as pd import datetime while true try date start input 請輸入起始日期 如 2019 02 03 輸入起止日期及間隔時間 date end input 請輸入截止日期 如 2019 02 03 peri...