×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Get External Reference Configuration name API-solidworks 2012

Get External Reference Configuration name API-solidworks 2012

Get External Reference Configuration name API-solidworks 2012

(OP)
Hi , I want to get a external reference configuration name of a derivated part and put it in a custom property. I used this code to print properties of external references..
 

CODE

'-------------------------------------------
'  Preconditions:
'  1. Open an assembly or part document.
'  2. Select:
'     * a component in an assembly document.
'       - or -
'     * a feature in an assembly or part document.
'       - or -
'     * Nothing in either type of document.
'
' Postconditions: Examine the Immediate window
' to see the name of the part or assembly document
' and the external references for the
' selected component, selected feature, or
' document.
'-------------------------------------------
Option Explicit
Sub main()
    Dim swApp                   As SldWorks.SldWorks
    Dim swModel                 As SldWorks.ModelDoc2
    Dim swModDocExt             As SldWorks.ModelDocExtension
    Dim swSelMgr                As SldWorks.SelectionMgr
    Dim swFeat                  As SldWorks.Feature
    Dim swComp                  As SldWorks.Component2
    Dim vModelPathName          As Variant
    Dim vComponentPathName      As Variant
    Dim vFeature                As Variant
    Dim vDataType               As Variant
    Dim vStatus                 As Variant
    Dim vRefEntity              As Variant
    Dim vFeatComp               As Variant
    Dim nConfigOpt              As Long
    Dim sConfigName             As String
    Dim nRefCount               As Long
    Dim nSelType                As Long
    Dim i                       As Long
    Set swApp = CreateObject("SldWorks.Application")
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swModDocExt = swModel.Extension
    nSelType = swSelMgr.GetSelectedObjectType3(1, -1)
    Select Case nSelType
        ' Selected component in an assembly document
        Case swSelCOMPONENTS
            Set swComp = swSelMgr.GetSelectedObjectsComponent3(1, -1)
            nRefCount = swComp.ListExternalFileReferencesCount
            swComp.ListExternalFileReferences2 vModelPathName, vComponentPathName, vFeature, vDataType, vStatus, vRefEntity, vFeatComp, nConfigOpt, sConfigName
 
        Set swModel = swComp.GetModelDoc2
        ' Selected feature in a part or assembly document
        Case swSelBODYFEATURES, swSelSKETCHES
            Set swFeat = swSelMgr.GetSelectedObject6(1, -1)
            nRefCount = swFeat.ListExternalFileReferencesCount
           swFeat.ListExternalFileReferences2 vModelPathName, vComponentPathName, vFeature, vDataType, vStatus, vRefEntity, vFeatComp, nConfigOpt, sConfigName
        
        ' Part document only
        Case Else
            nRefCount = swModDocExt.ListExternalFileReferencesCount
            swModDocExt.ListExternalFileReferences vModelPathName, vComponentPathName, vFeature, vDataType, vStatus, vRefEntity, vFeatComp, nConfigOpt, sConfigName
    End Select

    Debug.Print "Model name = " + swModel.GetPathName
    Debug.Print "    Reference count        = " + Str(nRefCount)
    Debug.Print ""
    For i = 0 To nRefCount - 1
        Debug.Print "    Model path + name      = " + vModelPathName(i)
        Debug.Print "    Component path + name  = " + vComponentPathName(i)
        Debug.Print "    Feature                = " + vFeature(i)
        Debug.Print "    Data type              = " + vDataType(i)
        Debug.Print "    Status                 = " + Str(vStatus(i))
        Debug.Print "    Reference entity       = " + vRefEntity(i)
        Debug.Print "    Feature component      = " + vFeatComp(i)
        Debug.Print "    Configuration option   = " & nConfigOpt
        Debug.Print "    Configuration name     = " & sConfigName
        Debug.Print " "
    Next i
End Sub

And it returns

Model name = X:\Encaixotadoras\Drop Packer\DPMK- 1200-A\Peças\90960100.SLDPRT
    Reference count        =  1

    Model path + name      = X:\_BIBLIOTECA\BASE PARTS\RODA DENTADA\RODA DENTADA ASA.SLDPRT
    Component path + name  = X:\_BIBLIOTECA\BASE PARTS\RODA DENTADA\RODA DENTADA ASA.SLDPRT
    Feature                = RODA DENTADA ASA
    Data type              = Corpo
    Status                 =  3
    Reference entity       = Corpo de RODA DENTADA ASA
    Feature component      =
    Configuration option   = 0
    Configuration name     =
 
The configuration options = 0 means swExternalFileReferencesConfigNone

But I choose the configuration of the external reference so i thin k the correct should be
configuration options = 2 that means
swExternalFileReferencesNamedConfig

Is there a way to change the configuration options? No matter if it uses api or not.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources