API Question - Getting the list of child files for a drawing
API Question - Getting the list of child files for a drawing
(OP)
I am writing a VB routine to determine all of the children files for a given SolidWorks file and have been quite successful for assemblies but the routines I use utilize the swFile.GetActiveConfiguration() and then the Configuration.GetRootComponent() routines to insure that I have the root component. Drawings are not particularly fond of that API call.
I only need the first level children as the system handles the recursion by keeping a table of all parent - child pairs and applying the relationships downward.
I guess my question is - how do I (in VB using the SW API) determine which files a drawing (.SLDDRW) uses?
Frank
I only need the first level children as the system handles the recursion by keeping a table of all parent - child pairs and applying the relationships downward.
I guess my question is - how do I (in VB using the SW API) determine which files a drawing (.SLDDRW) uses?
Frank






RE: API Question - Getting the list of child files for a drawing
It checks the current sw document and, if it is a drawing, jumps to the first view which is the drawing template, then goes to the next view and gets the file name of the model used to create that view. My program stops there but probably you can loop thru the views with
Set View = View.GetNextView
until you get nothing or error (I dont know what the above statement returns when there is no next view.)
Dim docType As Integer
Dim swApp As Object
Dim Part As Object
Dim View As Object
Dim sModelName As String
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
If Part Is Nothing Then
msg = "A SolidWorks document needs to be loaded!"
Style = vbExclamation ' Error style dialog
Titlemsg = "Model Properties" ' Define title
Call MsgBox(msg, Style, Titlemsg) 'Display error message
End ' If no model currently loaded, then exit
Else
docType = Part.GetType
End If
If (docType = swDocDRAWING) Then
Set View = Part.GetFirstView 'dwg template is the first view
Set View = View.GetNextView 'first dwg view
'get referenced model
sModelName = View.GetReferencedModelName()
End If
Hope this helps,
Andrew
RE: API Question - Getting the list of child files for a drawing
RE: API Question - Getting the list of child files for a drawing
Are you doing this in VB or SolidWorks VBA?
Are you running with Option Explicit?
Have you defined swDocDRAWING = 3?
The GetFirstView method is only available for the DrawingDoc object.
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: API Question - Getting the list of child files for a drawing
RE: API Question - Getting the list of child files for a drawing
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: API Question - Getting the list of child files for a drawing
This will more accurately depict what I am trying to do.