• python二次开发Solidworks:扫描


    新零件文档中创建一个圆形草图和两条线段草图,并将它们插入到模型中。接着,选中圆形草图作为扫描轮廓,并选中两条线段草图并将它们分组为一个对象。最后,使用特征管理器的InsertProtrusionSwept4方法创建扫描特征。

    1. import win32com.client as win32
    2. import pythoncom
    3. swApp = win32.Dispatch('sldworks.application')
    4. swApp.Visible = True
    5. Nothing = win32.VARIANT(pythoncom.VT_DISPATCH, None)
    6. swModel = swApp.NewDocument(r"C:\ProgramData\SolidWorks\SOLIDWORKS 2018\templates\gb_part.prtdot", 0, 0, 0)
    7. swModelDocExt = swModel.Extension
    8. swSketchManager = swModel.SketchManager
    9. swFeatureManager = swModel.FeatureManager
    10. #Create sketch of circle for the sweep profile
    11. swSketchSegment = swSketchManager.CreateCircle(0, 0, 0, 0.002394, -0.006333, 0)
    12. swSketchManager.InsertSketch(True)
    13. #Create sketches of lines for the sweep path
    14. status = swModelDocExt.SelectByID2("右视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
    15. swSketchManager.InsertSketch(True)
    16. swSketchSegment = swSketchManager.CreateLine(-0, 0, 0, 0.088481, 0.035691, 0)
    17. swSketchManager.InsertSketch(True)
    18. swModel.ClearSelection2(True)
    19. status = swModelDocExt.SelectByID2("右视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
    20. swSketchManager.InsertSketch(True)
    21. swSketchSegment = swSketchManager.CreateLine(0.088481, 0.035691, 0, 0.079214, 0.076295, 0)
    22. swSketchManager.InsertSketch(True)
    23. swModel.ClearSelection2(True)
    24. #Select the sketch of the circle for the sweep profile
    25. status = swModelDocExt.SelectByID2("草图1", "SKETCH", -5.86834883582351E-03, -3.37646707201764E-03, 0, False, 1, Nothing, 0)
    26. #Select the sketches of the lines for the sweep path and group them as an object
    27. status = swModelDocExt.SelectByID2("直线1@草图2", "EXTSKETCHSEGMENT", 3.79259971310087E-02, 1.52983890733924E-02, 0, True, 4, Nothing, 0)
    28. status = swModelDocExt.SelectByID2("直线1@草图3", "EXTSKETCHSEGMENT", 8.48435978763939E-02, 5.16285284155501E-02, 0, True, 4, Nothing, 0)
    29. status = swModelDocExt.SelectByID2("Unknown", "SELOBJGROUP", 0, 0, 0, True, 4, Nothing, 0)
    30. #Create the sweep feature
    31. swFeature = swFeatureManager.InsertProtrusionSwept4(False, False, 0, False, False, 0, 0, False, 0, 0, 0, 0, True, True, True, 0, True, False, 0, 0)
    32. swModel.ShowNamedView2("*上下二等角轴测", 8)
    33. swModel.SelectionManager.EnableContourSelection = False
    34. swModel.ViewZoomtofit2()

  • 相关阅读:
    8.1.1 创建空数据表
    PureFlash云原生存储部署方法
    http和https的区别!
    JUC包(java.util.concurrent)下的常用子类
    这3款音频文件转文字工具,操作真的很简单
    私信功能的设计与实现
    mybatis plus 常用方法
    NATAPP使用详细教程(免费隧道内网映射)
    有效的网络带宽监控策略
    echarts实现如下图功能代码
  • 原文地址:https://blog.csdn.net/T20151470/article/details/133914354