Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

API Question - Getting the list of child files for a drawing 2

Status
Not open for further replies.

Guest
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
 
Replies continue below

Recommended for you

This is a fragment from a program I wrote not long ago with help from dsi (the top expert).
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
 
I am not getting any results with this. When the code reaches 'Set View = Part.GetFirstView', I get an error. 'Object doesn's support this property or method'. Am I doing something wrong?
 
JP:

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.
 
I am running Option Explicit. As I understand it, the error that I am getting is because VBA doesn't know that .GetFirstView is a method of the Part Object. I am hoping that all I have to do is register a .dll or something. This could also come from a missing reference. I just don't know which one. I am trying to get running with VBA for Solidworks, but am finding that the lack of documentation and examples is really setting me back.
 
This should work in VBA as well. Could you post your code? DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Please check my new post "Document Routine Needed"

This will more accurately depict what I am trying to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor