4 Star 1 Fork 4

乐园 / 钢之术士工具条

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sleeve.rb 3.07 KB
一键复制 编辑 原始数据 按行查看 历史
乐园 提交于 2023-09-12 17:15 . 9-12
##########
##参数定义
##########
radius = 11.75.mm
pitchofscrew = 3.mm
halfpitchofscrew = pitchofscrew/2
scale = halfpitchofscrew*1.732/radius+1
##########
##群组结构
##########
group = Sketchup.active_model.entities.add_group #最外层群组
group1 = group.entities.add_group #圆环体群组
##########
##圆环柱群组
##########
#entities = Sketchup.active_model.entities
center_point = Geom::Point3d.new([0,0,0])
# Create a circle perpendicular to the provided vector.
normal = vector = Z_AXIS
edges = group1.entities.add_circle(center_point, vector, 18.5.mm) #添加一个直径37mm的圆边线
face = group1.entities.add_face(edges) #以边为界添加面
status = face.pushpull(-60.mm, true) #推拉-60mm形成向上的圆柱体
edges2 = group1.entities.add_circle(center_point, vector, 11.75.mm) #在圆柱底部画一个直径23mm的圆边线
face2 = edges2[0].common_face(edges2[1]) #利用两边共面引用内径圆的面
status = face2.pushpull(60.mm, true) #推拉60mm形成圆环柱
group1.entities.erase_entities(face2) #删除内径圆的面
##########
##螺旋线1
##########
group2 = group.entities.add_group #螺旋线1群组
for i in 0..19
new_edges = group2.entities.add_arc([0,0,pitchofscrew*i], [1,0,0], [0,0,1], radius, 0, 180.degrees)
curve = new_edges.first.curve
points = curve.vertices.map(&:position)
points.each_with_index { |pt, j| pt.z = (j * halfpitchofscrew/(points.length-1))+ pitchofscrew*i}
curve.move_vertices(points)
new_edges = group2.entities.add_arc([0,0,pitchofscrew*i+halfpitchofscrew], [1,0,0], [0,0,1], radius, 180.degrees, 360.degrees)
curve = new_edges.first.curve
points = curve.vertices.map(&:position)
points.each_with_index { |pt, j| pt.z = (j * halfpitchofscrew/(points.length-1)) +halfpitchofscrew + pitchofscrew*i }
curve.move_vertices(points)
end
##########
##螺旋线2
##########
group3 = group.entities.add_group #螺旋线2群组
for i in 0..19
new_edges = group3.entities.add_arc([0,0,pitchofscrew*i], [-1,0,0], [0,0,1], radius, 0, 180.degrees)
curve = new_edges.first.curve
points = curve.vertices.map(&:position)
points.each_with_index { |pt, j| pt.z = (j * halfpitchofscrew/(points.length-1))+ pitchofscrew*i}
curve.move_vertices(points)
new_edges = group3.entities.add_arc([0,0,pitchofscrew*i+halfpitchofscrew], [-1,0,0], [0,0,1], radius, 180.degrees, 360.degrees)
curve = new_edges.first.curve
points = curve.vertices.map(&:position)
points.each_with_index { |pt, j| pt.z = (j * halfpitchofscrew/(points.length-1)) +halfpitchofscrew + pitchofscrew*i }
curve.move_vertices(points)
end
##########
##炸开与缩放
##########
array = group3.explode
group2.explode
arcLine3 = array.first.edges.first.all_connected
group1.explode
tr = Geom::Transformation.scaling scale, scale, 1
group.entities.transform_entities(tr, arcLine3)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rebarpark/steel-warlock-tool-bar.git
git@gitee.com:rebarpark/steel-warlock-tool-bar.git
rebarpark
steel-warlock-tool-bar
钢之术士工具条
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891