1
大家好,我叫Jim,我剛剛在sketchup頁面上顯示了我的第一個ruby Sketchup代碼。 我有Windows 8 Sketchup的2016親紅寶石代碼「Automatic Sketchup」二十面體
下面基本上是複製出來的書「自動Sketchup的」 的文件中的Ruby代碼我很新的,我不能發現什麼是被排除在外。 必須有其他東西需要使其運行。 這是假設添加一個二十面體的草圖。
如果我能克服這個駝峯,我會非常高興。 如果有人能指引我正確的方向,我會永遠感激你的幫助。
mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
view = mod.active_view
Ss = 1.11935599 # Short side
Gr = 1.65742 # Long side
pt0 = Geom:: Point3d.new 0,Ss,Gr
pt1 = Geom:: Point3d.new 0,-Ss,GS
pt2 = Geom:: Point3d.new Gr,0,Ss
pt3 = Geom:: Point3d.new -Gr,0,Ss
pt4 = Geom:: Point3d.new Ss,-Gr,0
pt5 = Geom:: Point3d.new -Ss,-Gr,0
pt6 = Geom:: Point3d.new 0,Ss,-Gr
pt7 = Geom:: Point3d.new 0,-Ss,-Gr
pt8 = Geom:: Point3d.new Gr,0.-Ss
pt9 = Geom:: Point3d.new -Gr,0,-Ss
pt10 = Geom:: Point3d.new Ss,Gr,0
pt11 = Geom:: Point3d.new -Ss,Gr,0
pm = Geom:: PolygonMesh.new 12, 20
#Top half
pm.add_polygon pt0, pt1, pt2
pm.add_polygon pt0, pt1, pt3
pm.add_polygon pt1, pt4, pt5
pm.add_polygon pt1, pt4, pt2
pm.add_polygon pt1, pt3, pt5
#Middle
pm.add_polygon pt4, pt5, pt7
pm.add_polygon pt2, pt8, pt4
pm.add_polygon pt10, pt11, pt0
pm.add_polygon pt3, pt9, pt5
pm.add_polygon pt2, pt8, pt10
pm.add_polygon pt2, pt0, pt10
pm.add_polygon pt9, pt5, pt7
pm.add_polygon pt7, pt8, pt4
pm.add_polygon pt11, pt9, pt3
pm.add_polygon pt11, pt3, pt0
#Bottom half
pm.add_polygon pt6, pt7, pt8
pm.add_polygon pt6, pt7, pt9
pm.add_polygon pt6, pt10, pt11
pm.add_polygon pt6, pt10, pt8
pm.add_polygon pt6, pt9, pt11
#Draw face in the mesh
ent = Sketchup.active_mod.entities
ent.add_faces_from_mesh pm
嘿吉姆,當您嘗試運行此代碼時實際發生了什麼? – Zajn