|
本帖2#,ODM:
8.#运算时间的计算 9.#类型转换也可以这样用,长度转字符型
10.#打开面板选择输出的文件,标题、目录、文件名
11.#数学方程的应用,简单的方法定义 12.#for循环的应用
13.#push 多个面 14.#组的另类用法 15.#VCB 前字符的定义- #运算时间的计算
- def
- st = Time.new #获取开始时间,放在计算过程的前面
- et = Time.new #获取结束时间,放在计算过程的结束
- puts "#{et - st}" #输出两时间差,字符中的计算用: #(..)
- end
- #类型转换也可以这样用,长度转字符型
- 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
- #打开面板选择输出的文件,标题、目录、文件名
- def
- value = UI.openpanel("Export title", "", "*.xx")
- if value
- file=File.new(value.to_s,"w") #新建文件
- file.puts("code:...")
- file.close
- end
- end
- #数学方程的应用,简单的方法定义
- def cos_hip(x)
- return (Math::exp(x) + Math::exp(-x))/2
- end
- #for循环的应用
- 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) #对实体信息进行操作
- 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
复制代码 |
|