SKETCHUP RUBY開發實驗一 畫球的外掛程式

來源:互聯網
上載者:User

SKETCHUP帶有RUBY介面,可以輕鬆開發自己需要的外掛程式。先做一個畫球的實驗一下,效果還可以。不過有一個小問題,就是連續畫同一個球(半徑和球心相同)時,不僅新的球看不到,連原來的也刪除了,還要再研究研究,呵呵。

代碼如下:

require 'sketchup.rb'

@cx = 0
@cy = 0
@cz = 0

def drawShpere(center, radius)
 # Access the Entities object
 ents = Sketchup.active_model.entities
 
 # Create the initial circle
 circle = ents.add_circle center, [0, 0, 1], radius
 circle_face = ents.add_face circle
     
 # Create the circular path
 path = ents.add_circle center, [0, 1, 0], radius + 1

 # Create the sphere
 circle_face.followme path
 
 # Remove the path
 ents.erase_entities path
end

def auto_sphere
 prompts=["CX","CY","CZ","R"]
 types=["","","",""]
 title="Shpere Parameter"

 @cx=0 if not @cx
    @cy=0 if not @cy
    @cz=0 if not @cz
    @radius=5 if not @radius
 
 values=[@cx,@cy,@cz,@radius]
 popups=["","","",""]

 results=inputbox( prompts, values, popups, title )
 return nil if not results
 
 @cx=results[0]
    @cy=results[1]
    @cz=results[2]
    @radius=results[3]
    
 center = [@cx,@cy,@cz] 
 drawShpere(center, @radius) 
end

if( not file_loaded?(__FILE__) )
   UI.menu("Plugins").add_item("AutoSphere"){auto_sphere}
end

file_loaded(__FILE__)

 

輸入參數:

 

產生球體:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.