首页 > 开发 > 综合 > 正文

Solidworks二次开发—09--添加配合参考

2024-07-21 02:16:08
字体:
来源:转载
供稿:网友
  • 本文来源于网页设计爱好者web开发社区http://www.html.org.cn收集整理,欢迎访问。
  • 下面的代码选择了零件的两个面,然后为此零件添加一个配合参考,先选择的面为配合参考的第一参考面。并且是同向、重合配合。第二个为反向、重合配合。
    需要看part.featuremanager.insertmatereference函数。第一个参数是配合参考的名称,后面三个为一组定义一个参考。第一个为选择的实体entity,然后是配合类型(整数索引),正反向(整数索引)。

    dim swapp as sldworks.sldworks
    dim part as sldworks.modeldoc2
    dim selmgr as sldworks.selectionmgr
    dim feature as sldworks.feature
    dim facefst as sldworks.face2
    dim facesed as sldworks.face2
    dim facefstent as sldworks.entity
    dim facesedent as sldworks.entity
    dim tempfeat as object


    sub addcleatmateref()
    set swapp = application.sldworks
    set part = swapp.activedoc
    set selmgr = part.selectionmanager

    set tempfeat = selmgr.getselectedobject5(1)
    if tempfeat.gettype = 2 then
    set facefst = tempfeat
    set facefstent = facefst
    else
    msgbox "请选择平面"
    end if
    set tempfeat = selmgr.getselectedobject5(2)
    if tempfeat.gettype = 2 then
    set facesed = tempfeat
    set facesedent = facesed
    else
    msgbox "请选择平面"
    end if
    set feature = part.featuremanager.insertmatereference("配合参考1", facefstent, 2, 1, facesedent, 2, 2, nothing, 0, 0)
    end sub
    发表评论 共有条评论
    用户名: 密码:
    验证码: 匿名发表