|
本帖2#,ODM:
8.#運(yùn)算時間的計算 9.#類型轉(zhuǎn)換也可以這樣用,長度轉(zhuǎn)字符型
10.#打開面板選擇輸出的文件,標(biāo)題、目錄、文件名
11.#數(shù)學(xué)方程的應(yīng)用,簡單的方法定義 12.#for循環(huán)的應(yīng)用
13.#push 多個面 14.#組的另類用法 15.#VCB 前字符的定義- #運(yùn)算時間的計算
- def
- st = Time.new #獲取開始時間,放在計算過程的前面
- et = Time.new #獲取結(jié)束時間,放在計算過程的結(jié)束
- puts "#{et - st}" #輸出兩時間差,字符中的計算用: #(..)
- end
- #類型轉(zhuǎn)換也可以這樣用,長度轉(zhuǎn)字符型
- def l2str(len)
- if len < 0.0
- aux_str = "-" + (-len).inch.to_s.to_f.to_s
- else
- aux_str = len.inch.to_s.to_f.to_s
- end
- return aux_str
- end
- #打開面板選擇輸出的文件,標(biāo)題、目錄、文件名
- def
- value = UI.openpanel("Export title", "", "*.xx")
- if value
- file=File.new(value.to_s,"w") #新建文件
- file.puts("code:...")
- file.close
- end
- end
- #數(shù)學(xué)方程的應(yīng)用,簡單的方法定義
- def cos_hip(x)
- return (Math::exp(x) + Math::exp(-x))/2
- end
- #for循環(huán)的應(yīng)用
- for example in (0..10)
- ...
- end
- #push 多個面
- indexes.push(hight)
- #組的另類用法
- def
- entities = Sketchup.active_model.entities
- group = entities.add_group #增加組
- group_ents = group.entities #得到組的實體信息
- group_ents.add_faces_from_mesh(mesh_et) #對實體信息進(jìn)行操作
- end
- #VCB 前字符的定義
- #語法:result = Sketchup.set_status_text “status text” position
- #position的值:SB_PROMPT- 最左邊的提示值,SB_VCB_LABEL -VCB提示值,SB_VCB_VALUE -VCB值
- def
- Sketchup::set_status_text("str", 1) #SB_PROMPT為0,SB_VCB_LABEL為1,SB_VCB_VALUE為2
- end
復(fù)制代碼 |
|