Secondary Development of SolidWorks-09-add reference

Source: Internet
Author: User
The following code selects the two sides of the part, and then adds a reference for the part. The selected area is the first reference area for the reference. In addition, they are in the same direction and overlap. The second is reverse and overlap.

You need to check the part. featuremanager. insertmatereference function. The first parameter is the reference name, and the last three parameters are a set of definitions. The first is the selected entity, followed by the combination type (integer index), positive and reverse (integer index ).

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 "select plane"
End if
Set tempfeat = selmgr. getselectedobject5 (2)
If tempfeat. GetType = 2 then
Set facesed = tempfeat
Set facesedent = facesed
Else
Msgbox "select plane"
End if
Set feature =Part. featuremanager. insertmatereference ("with reference 1", facefstent, 2, 1, facesedent, 2, 2, nothing, 0, 0)
End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.