def lianlun():

from OCC.Display.SimpleGui import init_display
roller_diameter = 10.2  #滚轮直径
pitch = 15.875  #螺距
num_teeth = 40 #齿数
chain_width = 6.35 #链宽#  Dimensions derived from the provided inputs
roller_radius = roller_diameter / 2. #滚轮半径
tooth_angle = (2 * M_PI) / num_teeth #齿数角度
pitch_circle_diameter = pitch / sin(tooth_angle / 2.) #节圆直径
pitch_circle_radius = pitch_circle_diameter / 2. #节圆半径roller_contact_angle_min = (M_PI * 120 / 180) - ((M_PI / 2.) / num_teeth)  #滚轮接触角——最笑
roller_contact_angle_max = (M_PI * 140 / 180) - ((M_PI / 2.) / num_teeth) #滚轮接触角——最大
roller_contact_angle = (roller_contact_angle_min + roller_contact_angle_max) / 2.tooth_radius_min = 0.505 * roller_diameter #齿半径
tooth_radius_max = tooth_radius_min + (0.069 * pow(roller_diameter, 1.0 / 3.0))
tooth_radius = (tooth_radius_min + tooth_radius_max) / 2.#齿半径profile_radius = 0.12 * roller_diameter * (num_teeth + 2) #轮廓班囧
top_diameter = pitch_circle_diameter + ((1 - (1.6 / num_teeth)) * pitch) - roller_diameter
top_radius = top_diameter / 2. #顶部半径thickness = chain_width * 0.95 #厚度# Center hole data #中心数据
center_radius = 125.0 / 2.  #中心半径# Mounting hole data 安装孔数据
mounting_hole_count = 6 #安装孔数
mounting_radius = 153.0 / 2. #安装半径
hole_radius = 8.5 / 2. #孔半径def build_tooth():base_center = gp_Pnt2d(pitch_circle_radius + (tooth_radius - roller_radius), 0) #基圆中心:(节圆半径+(齿半径-滚子半径)base_circle = gp_Circ2d(gp_Ax2d(base_center, gp_Dir2d()), tooth_radius) #基圆trimmed_base = GCE2d_MakeArcOfCircle(base_circle, #修剪基础M_PI - (roller_contact_angle / 2.),M_PI).Value()display.DisplayShape(trimmed_base, update=True, color=rgb_color(0.1, 0.8, 1))

    trimmed_base.Reverse()  # just a trickp0 = trimmed_base.StartPoint() #=修剪_基底。起点p1 = trimmed_base.EndPoint() #=修剪_基底。终点点# print(p0.X())# display.DisplayMessage(p0)# display.DisplayShape(p0, update=True, color=rgb_color(1, 0.8, 1))# Determine the center of the profile circlex_distance = cos(roller_contact_angle / 2.) * (profile_radius + tooth_radius)y_distance = sin(roller_contact_angle / 2.) * (profile_radius + tooth_radius)profile_center = gp_Pnt2d(pitch_circle_radius - x_distance, y_distance)# Construct the profile circle gp_Circ2d #确定轮廓圆的中心profile_circle = gp_Circ2d(gp_Ax2d(profile_center, gp_Dir2d()),profile_center.Distance(p1))geom_profile_circle = GCE2d_MakeCircle(profile_circle).Value()

    # Construct the outer circle gp_Circ2d 构建外圆outer_circle = gp_Circ2d(gp_Ax2d(gp_Pnt2d(0, 0), gp_Dir2d()), top_radius)geom_outer_circle = GCE2d_MakeCircle(outer_circle).Value()

    inter = Geom2dAPI_InterCurveCurve(geom_profile_circle, geom_outer_circle)num_points = inter.NbPoints()assert isinstance(p1, gp_Pnt2d)if num_points == 2:if p1.Distance(inter.Point(1)) < p1.Distance(inter.Point(2)):p2 = inter.Point(1)else:p2 = inter.Point(2)elif num_points == 1:p2 = inter.Point(1)else:sys.exit(-1)# Trim the profile circle and mirror #修剪轮廓圆并镜像trimmed_profile = GCE2d_MakeArcOfCircle(profile_circle, p1, p2).Value()

    # Calculate the outermost point #计算最外面的点p3 = gp_Pnt2d(cos(tooth_angle / 2.) * top_radius,sin(tooth_angle / 2.) * top_radius)# and use it to create the third arc #并使用它来创建第三个弧trimmed_outer = GCE2d_MakeArcOfCircle(outer_circle, p2, p3).Value()# display.DisplayShape(trimmed_outer, update=True, color=rgb_color(0.1, 0.8, 1))# Mirror and reverse the three arcs #镜像并反转三条弧线mirror_axis = gp_Ax2d(gp_Origin2d(), gp_DX2d().Rotated(tooth_angle / 2.))# 镜像_基础= Geom2d _修剪曲线。向下转换(修剪基础。Copy()mirror_base = Geom2d_TrimmedCurve.DownCast(trimmed_base.Copy())mirror_profile = Geom2d_TrimmedCurve.DownCast(trimmed_profile.Copy())mirror_outer = Geom2d_TrimmedCurve.DownCast(trimmed_outer.Copy())mirror_base.Mirror(mirror_axis) #镜像基地。镜像(镜像轴)mirror_profile.Mirror(mirror_axis) #镜像配置文件。镜像(镜像轴)mirror_outer.Mirror(mirror_axis) #镜像_外部。镜像(镜像轴)mirror_base.Reverse() #镜像基地。反向()mirror_profile.Reverse()mirror_outer.Reverse()# Replace the two outer arcs with a single one #用单个弧替换两个外弧outer_start = trimmed_outer.StartPoint()outer_mid = trimmed_outer.EndPoint()outer_end = mirror_outer.EndPoint()outer_arc = GCE2d_MakeArcOfCircle(outer_start, outer_mid, outer_end).Value()# Create an arc for the inside of the wedge  #为楔子内部创建一个弧inner_circle = gp_Circ2d(gp_Ax2d(gp_Pnt2d(0, 0), gp_Dir2d()),top_radius - roller_diameter)inner_start = gp_Pnt2d(top_radius - roller_diameter, 0)inner_arc = GCE2d_MakeArcOfCircle(inner_circle, inner_start, tooth_angle).Value()inner_arc.Reverse()# Convert the 2D arcs and two extra lines to 3D edges# 将2D弧和两条额外的线转换为三维边plane = gp_Pln(gp_Origin(), gp_DZ())arc1 = BRepBuilderAPI_MakeEdge(geomapi_To3d(trimmed_base, plane)).Edge()#(修剪_基础,平面))。边缘()arc2 = BRepBuilderAPI_MakeEdge(geomapi_To3d(trimmed_profile, plane)).Edge()arc3 = BRepBuilderAPI_MakeEdge(geomapi_To3d(outer_arc, plane)).Edge()arc4 = BRepBuilderAPI_MakeEdge(geomapi_To3d(mirror_profile, plane)).Edge()arc5 = BRepBuilderAPI_MakeEdge(geomapi_To3d(mirror_base, plane)).Edge()p4 = mirror_base.EndPoint() #镜像_基底p5 = inner_arc.StartPoint()  #内弧。起点()lin1 = BRepBuilderAPI_MakeEdge(gp_Pnt(p4.X(), p4.Y(), 0),gp_Pnt(p5.X(), p5.Y(), 0)).Edge()arc6 = BRepBuilderAPI_MakeEdge(geomapi_To3d(inner_arc, plane)).Edge()p6 = inner_arc.EndPoint()lin2 = BRepBuilderAPI_MakeEdge(gp_Pnt(p6.X(), p6.Y(), 0),gp_Pnt(p0.X(), p0.Y(), 0)).Edge()wire = BRepBuilderAPI_MakeWire(arc1)wire.Add(arc2) #电线。添加(arc2)wire.Add(arc3)wire.Add(arc4)wire.Add(arc5)wire.Add(lin1)wire.Add(arc6)wire.Add(lin2)face = BRepBuilderAPI_MakeFace(wire.Wire())# 楔形 = BRepPrimAPI_MakePrism(面。形状(),wedge = BRepPrimAPI_MakePrism(face.Shape(), gp_Vec(0.0, 0.0, thickness))

    return wedge.Shape()def round_tooth(wedge):"""圆齿(楔形:param wedge::return:"""round_x = 2.6round_z = 0.06 * pitch #*间距round_radius = pitch #圆形半径=间距# Determine where the circle used for rounding has to start and stop# 确定用于舍入的圆的起点和终点p2d_1 = gp_Pnt2d(top_radius - round_x, 0)p2d_2 = gp_Pnt2d(top_radius, round_z)# Construct the rounding circle# 构建圆形round_circle = GccAna_Circ2d2TanRad(p2d_1, p2d_2, round_radius, 0.01)if (round_circle.NbSolutions() != 2):sys.exit(-2)round_circle_2d_1 = round_circle.ThisSolution(1)round_circle_2d_2 = round_circle.ThisSolution(2)if (round_circle_2d_1.Position().Location().Coord()[1] >= 0):round_circle_2d = round_circle_2d_1else:round_circle_2d = round_circle_2d_2# Remove the arc used for rounding# 移除用于倒圆的弧线trimmed_circle = GCE2d_MakeArcOfCircle(round_circle_2d, p2d_1, p2d_2).Value()# Calculate extra points used to construct lines# 计算用于构建线的额外点p1 = gp_Pnt(p2d_1.X(), 0, p2d_1.Y())p2 = gp_Pnt(p2d_2.X(), 0, p2d_2.Y())p3 = gp_Pnt(p2d_2.X() + 1, 0, p2d_2.Y())p4 = gp_Pnt(p2d_2.X() + 1, 0, p2d_1.Y() - 1)p5 = gp_Pnt(p2d_1.X(), 0, p2d_1.Y() - 1)# Convert the arc and four extra lines into 3D edges# 将圆弧和四条额外的线转换为三维边plane = gp_Pln(gp_Ax3(gp_Origin(), gp_DY().Reversed(), gp_DX()))arc1 = BRepBuilderAPI_MakeEdge(geomapi_To3d(trimmed_circle, plane)).Edge()lin1 = BRepBuilderAPI_MakeEdge(p2, p3).Edge()lin2 = BRepBuilderAPI_MakeEdge(p3, p4).Edge()lin3 = BRepBuilderAPI_MakeEdge(p4, p5).Edge()lin4 = BRepBuilderAPI_MakeEdge(p5, p1).Edge()# Make a wire composed of the edges #制作由边组成的线round_wire = BRepBuilderAPI_MakeWire(arc1)round_wire.Add(lin1)round_wire.Add(lin2)round_wire.Add(lin3)round_wire.Add(lin4)# Turn the wire into a face #把电线变成一张(面)脸round_face = BRepBuilderAPI_MakeFace(round_wire.Wire()).Shape()# Revolve the face around the Z axis over the tooth angle# 在齿角上围绕Z轴旋转面rounding_cut_1 = BRepPrimAPI_MakeRevol(round_face, gp_OZ(), tooth_angle).Shape()# Construct a mirrored copy of the first cutting shape# 构建第一个切割形状的镜像副本mirror = gp_Trsf()mirror.SetMirror(gp_XOY())mirrored_cut_1 = BRepBuilderAPI_Transform(rounding_cut_1, mirror, True).Shape()# and translate it so that it ends up on the other side of the wedge# 转换它,让它在楔子的另一边结束translate = gp_Trsf()translate.SetTranslation(gp_Vec(0, 0, thickness))rounding_cut_2 = BRepBuilderAPI_Transform(mirrored_cut_1, translate, False).Shape()

    # Cut the wedge using the first and second cutting shape# 使用第一个和第二个切割形状切割楔子cut_1 = BRepAlgoAPI_Cut(wedge, rounding_cut_1).Shape()cut_2 = BRepAlgoAPI_Cut(cut_1, rounding_cut_2).Shape()return cut_2def clone_tooth(base_shape):"""克隆牙(基础形状:param base_shape::return:"""clone = gp_Trsf()grouped_shape = base_shape# Find a divisor, between 1 and 8, for the number_of teeth# 为齿数找到一个介于1和8之间的除数multiplier = 1 #乘数max_multiplier = 1for i in range(0, 8):if num_teeth % multiplier == 0:max_multiplier = i + 1multiplier = max_multiplierfor i in range(1, multiplier):clone.SetRotation(gp_OZ(), -i * tooth_angle)rotated_shape = BRepBuilderAPI_Transform(base_shape, clone, True).Shape()grouped_shape = BRepAlgoAPI_Fuse(grouped_shape, rotated_shape).Shape()# Rotate the basic tooth and fuse together# 旋转基本齿并融合在一起aggregated_shape = grouped_shape #聚集形状=分组形状for i in range(1, int(num_teeth / multiplier)):clone.SetRotation(gp_OZ(), - i * multiplier * tooth_angle)# 旋转形状 = BRepBuilderAPI_Transform(分组形状,克隆,真)。形状()rotated_shape = BRepBuilderAPI_Transform(grouped_shape, clone, True).Shape()# 聚集_形状 = BRepAlgoAPI_Fuse(聚集_形状,旋转_形状)。形状()aggregated_shape = BRepAlgoAPI_Fuse(aggregated_shape, rotated_shape).Shape()# 气缸 = brepprimpi _ make  cylinder(gp_XOY(), 顶部半径 - 滚轮直径,厚度)cylinder = BRepPrimAPI_MakeCylinder(gp_XOY(),top_radius - roller_diameter,thickness)# 聚集_形状 = BRepAlgoAPI_Fuse(聚集_形状,圆柱体。Shape())。形状()aggregated_shape = BRepAlgoAPI_Fuse(aggregated_shape,cylinder.Shape()).Shape()

    return aggregated_shapedef center_hole(base):"""中心孔(底部)::param base::return:"""cylinder = BRepPrimAPI_MakeCylinder(center_radius, thickness).Shape()cut = BRepAlgoAPI_Cut(base, cylinder)

    return cut.Shape()def mounting_holes(base):"""安装孔(底部)::param base::return:"""result = basefor i in range(0, mounting_hole_count):center = gp_Pnt(cos(i * M_PI / 3) * mounting_radius,sin(i * M_PI / 3) * mounting_radius, 0.0)center_axis = gp_Ax2(center, gp_DZ())cylinder = BRepPrimAPI_MakeCylinder(center_axis, hole_radius,thickness).Shape()result = BRepAlgoAPI_Cut(result, cylinder).Shape()cone = BRepPrimAPI_MakeCone(center_axis,hole_radius + thickness / 2.,hole_radius, thickness / 2.)result = BRepAlgoAPI_Cut(result, cone.Shape()).Shape()

    return resultdef cut_out(base):# 切出(基础):# 外部 = gp_Circ2d(gp_OX2d(),顶部_半径 - 1.75 * 滚轮_直径)outer = gp_Circ2d(gp_OX2d(), top_radius - 1.75 * roller_diameter)# 内部 = gp_Circ2d(gp_OX2d(),中心_半径 + 0.75 * 滚轮_直径)inner = gp_Circ2d(gp_OX2d(), center_radius + 0.75 * roller_diameter)geom_outer = GCE2d_MakeCircle(outer).Value()geom_inner = GCE2d_MakeCircle(inner).Value()

    geom_inner.Reverse()base_angle = (2. * M_PI) / mounting_hole_counthole_angle = atan(hole_radius / mounting_radius) #孔角度correction_angle = 3 * hole_angle #校正角度= 3 *孔角度left = gp_Lin2d(gp_Origin2d(), gp_DX2d())right = gp_Lin2d(gp_Origin2d(), gp_DX2d())left.Rotate(gp_Origin2d(), correction_angle) #向左。旋转(gp_Origin2d(),校正_角度)right.Rotate(gp_Origin2d(), base_angle - correction_angle) #没错。旋转(gp_Origin2d(),基础_角度-校正_角度)geom_left = GCE2d_MakeLine(left).Value()geom_right = GCE2d_MakeLine(right).Value()

    inter_1 = Geom2dAPI_InterCurveCurve(geom_outer, geom_left)inter_2 = Geom2dAPI_InterCurveCurve(geom_outer, geom_right)inter_3 = Geom2dAPI_InterCurveCurve(geom_inner, geom_right)inter_4 = Geom2dAPI_InterCurveCurve(geom_inner, geom_left)if inter_1.Point(1).X() > 0:p1 = inter_1.Point(1)else:p1 = inter_1.Point(2)if inter_2.Point(1).X() > 0:p2 = inter_2.Point(1)else:p2 = inter_2.Point(2)if inter_3.Point(1).X() > 0:p3 = inter_3.Point(1)else:p3 = inter_3.Point(2)if inter_4.Point(1).X() > 0:p4 = inter_4.Point(1)else:p4 = inter_4.Point(2)trimmed_outer = GCE2d_MakeArcOfCircle(outer, p1, p2).Value()trimmed_inner = GCE2d_MakeArcOfCircle(inner, p4, p3).Value()

    plane = gp_Pln(gp_Origin(), gp_DZ())arc1 = BRepBuilderAPI_MakeEdge(geomapi_To3d(trimmed_outer, plane)).Edge()lin1 = BRepBuilderAPI_MakeEdge(gp_Pnt(p2.X(), p2.Y(), 0),gp_Pnt(p3.X(), p3.Y(), 0)).Edge()#(修剪_外部,平面))。边缘()arc2 = BRepBuilderAPI_MakeEdge(geomapi_To3d(trimmed_inner, plane)).Edge()lin2 = BRepBuilderAPI_MakeEdge(gp_Pnt(p4.X(), p4.Y(), 0),gp_Pnt(p1.X(), p1.Y(), 0)).Edge()cutout_wire = BRepBuilderAPI_MakeWire(arc1)cutout_wire.Add(lin1) #断线。添加(lin1)cutout_wire.Add(arc2)cutout_wire.Add(lin2)# Turn the wire into a face #把电线变成一张脸cutout_face = BRepBuilderAPI_MakeFace(cutout_wire.Wire())filleted_face = BRepFilletAPI_MakeFillet2d(cutout_face.Face())explorer = BRepTools_WireExplorer(cutout_wire.Wire())while explorer.More():vertex = explorer.CurrentVertex()filleted_face.AddFillet(vertex, roller_radius)explorer.Next()cutout = BRepPrimAPI_MakePrism(filleted_face.Shape(),gp_Vec(0.0, 0.0, thickness)).Shape()result = base #结果=基础rotate = gp_Trsf()for i in range(0, mounting_hole_count):rotate.SetRotation(gp_OZ(), i * 2. * M_PI / mounting_hole_count)# 旋转剪切 = BRepBuilderAPI_Transform(剪切,旋转,真)rotated_cutout = BRepBuilderAPI_Transform(cutout, rotate, True)result = BRepAlgoAPI_Cut(result,rotated_cutout.Shape()).Shape()

    return resultdef build_sprocket():# create the sprocket modelwedge = build_tooth()rounded_wedge = round_tooth(wedge)basic_disk = clone_tooth(rounded_wedge)cut_disc = center_hole(basic_disk)mountable_disc = mounting_holes(cut_disc)sprocket = cut_out(mountable_disc)return sprocketsprocket_model = build_sprocket()
# display.DisplayShape(sprocket_model, update=True, color=rgb_color(1, 0.8, 1))  #
# display.DisplayShape(TopoDS_Shape_chengtao.Shape(), update=True, color=rgb_color(0.1, 0.2, 1))  #

pythonocc_链轮相关推荐

  1. teleport 组件的作用_承德专业做链轮组件哪家好

    承德专业做链轮组件哪家好 yjkss9 承德专业做链轮组件哪家好 通常加工企业为了保证圆弧和倒角的糖确度,般会采用数控装迓进行加工.进而保证元件加工的精确.第三是清洗作用:在金属切削过程中,要求切削液 ...

  2. SEO优化:什么是SEO链轮?站群与博客群的优劣比较!

    SEO链轮是指通过在互联网上建立大量的独立站点或是在各大门户网站上开设博客,这些独立站点或是博客群通过单向的.有策略.有计划紧密的链接,并都指向要优化的目标网站,以达到提升目标网站在搜索引擎结果中的排 ...

  3. 外(内,交叉)链接,链轮,黑链

    外部链接 外部链接又叫"反向链接"或"导入链接"是指其他 网站的链接指向你的网站 外部链接包括:单项外链和双向外链(友情链接) *什么是外链?* 全称为外部链接 ...

  4. 6天百度第一3321链轮模型大曝光

    上周三写了一篇文章<6天百度第一链轮操作大曝光>受到广大朋友们的欢迎,一度保持A5今日TOP第一三天时分荣幸,对于支持的朋友们表示感谢.期间很多朋友加我的QQ询问关于3321链轮模型的事情 ...

  5. 2021年全球链轮收入大约415百万美元,预计2028年达到496.1百万美元

    本文研究全球市场.主要地区和主要国家链轮的销量.销售收入等,同时也重点分析全球范围内主要厂商(品牌)竞争态势,链轮销量.价格.收入和市场份额等. 针对过去五年(2017-2021)年的历史情况,分析历 ...

  6. ug链轮设计软件_同为三维设计软件,solidworks与ug有何不同

    solidworks和ug都是三维设计软件,那就先跟我一起来了解一下这两款软件吧. 1.用途方面的差距: UG偏向于曲面.模具.数控制造,功能丰富. solidworks偏向于机械设计.钣金,目前国内 ...

  7. ug链轮设计软件_正版UG软件,UG软件代理,正版UG软件模块功能介绍

    身处制造业的朋友们都知道,制造业离不开二维软件和三维软件,三维软件中尤其是UG软件因功能最强大,模块最全面而闻名,广泛应用于:CAE(结构有限元分析,热仿真,应力仿真,TMG仿真),CAD(产品设计, ...

  8. 各大高权重搜索引擎博客矩阵链轮?

    客营销在现实网络环境中还是有着较大的作用,搜索引擎对博客的收录也是较快的.在百度收录新站小技巧和新站外链建设文章中,陈迪均提到利用目前比较高权重的博客创造外链,新站都不好找外链,好好利用这些博客,虽然 ...

  9. pythonocc_如何在pythonOCC中使用样条曲线?

    需要修改代码C++BOOST_PYTHON_MODULE(Spline) { import_array(); boost::python::numeric::array::set_module_and ...

  10. PythonOCC基础使用:opencascade三维建模命令——一个链轮的绘制(很重要)

    先上效果图: import sys from math import pi as M_PI, sin, cos, atanfrom OCC.Core.gp import (gp_Pnt2d, gp_A ...

最新文章

  1. 无法量产自动驾驶汽车的企业,与谷歌公司差在哪儿
  2. IMX51---GPIO
  3. Divide and conquer:K Best(POJ 3111)
  4. 宏光MINI EV收割的年轻人,又被苏宁、小米、欧拉盯上了
  5. 日常生活小技巧 -- 重装win10系统
  6. all ,any,abs的使用
  7. c++ 访问控制与封装
  8. 【Playable API】不用Animator如何播放动画?
  9. 主机_云服务器vps价格比对[博]
  10. 正向混合云和反向混合云解析
  11. 在IIS上SSL的部署和启动SSL安全
  12. 软件工程:NFR与NFP
  13. 2021-11-13 变电站综合自动化 二次系统安全
  14. python 百度ai json解析_百度AI接口调用
  15. Android 获取圆角图标bitmap黑色背景问题解决
  16. Java技术栈学习路线
  17. python的猴子补丁(Monkey Patching)
  18. 【Monica的android学习之路】四大组件的生命周期
  19. Voting mechanism
  20. 盘点那些你不知道却很有效果的网络推广方法

热门文章

  1. 剖析《Linux 平均负载:解开谜团》
  2. Remoting技术
  3. 可怕的pyspider猫途鹰
  4. P6647 [CCC 2019] Tourism
  5. 网易云音乐java_网易云音乐被下架?掌握这几步,你也能做出网易云!
  6. 数学建模计算机部分知识,数学建模中计算机知识的运用
  7. spyder下载python3.5_ubuntu14.04 anaconda tensorflow spyder(python3.5) + opencv3
  8. c语言开发的烟花表白程序,C语言实战之浪漫烟花表白程序(2020年十二月整理).doc...
  9. java pdf合并_利用iText 合并PDF与分解PDF的例子
  10. 金税盘显示frm000013_开票软件(金税盘版)2020年4月征期抄报方法/季报方法!