Document Routine Needed
Document Routine Needed
(OP)
I am trying to automate the process of converting thousands of MDT files to Solidworks. We have already broken down our product lines into part types and have begun the process of creating part files and configurations. What I need now is an automated way to output drawing files. I have a template drawing set up with the dimension scheme that I like. I just need to be able to cycle through the configurations and do a save copy as with the configuration name as the name of the file.
The only part of this routine that I am having problems with is the cycling through the configurations. I cannot seem to grab the available configurations from the view. Am I doing something wrong? Do I need to load the part/assembly file to grab the configurations?
Any Ideas?
My Sample Code:
Option Explicit
Dim swApp As Object
Dim Drawing As SldWorks.DrawingDoc
Sub main()
Dim View As SldWorks.View
Dim Model As String
Dim Configuration As String
Set swApp = CreateObject("SldWorks.Application")
Set Drawing = swApp.ActiveDoc
Set View = Drawing.IGetFirstView()
Set View = View.GetNextView
Model = View.GetReferencedModelName
Configuration = View.ReferencedConfiguration
End Sub
The only part of this routine that I am having problems with is the cycling through the configurations. I cannot seem to grab the available configurations from the view. Am I doing something wrong? Do I need to load the part/assembly file to grab the configurations?
Any Ideas?
My Sample Code:
Option Explicit
Dim swApp As Object
Dim Drawing As SldWorks.DrawingDoc
Sub main()
Dim View As SldWorks.View
Dim Model As String
Dim Configuration As String
Set swApp = CreateObject("SldWorks.Application")
Set Drawing = swApp.ActiveDoc
Set View = Drawing.IGetFirstView()
Set View = View.GetNextView
Model = View.GetReferencedModelName
Configuration = View.ReferencedConfiguration
End Sub






RE: Document Routine Needed
I will look into the rest of it and get back to you.
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: Document Routine Needed
Option Explicit
Dim swApp As Object
Dim swDwg As Object
Dim swView As Object
Sub main()
Dim sViewName As String
Dim sModelName As String
Dim sConfigName As String
Dim sMsg As String
Set swApp = CreateObject("SldWorks.Application")
Set swDwg = swApp.ActiveDoc
Set swView = swDwg.GetFirstView() 'Drawing Template
sMsg = "VIEW NAME : MODEL NAME : COFIGURATION NAME" & vbCrLf
On Error Resume Next
Set swView = swView.GetNextView
Do While Not swView Is Nothing
sViewName = swView.Name
sModelName = swView.GetReferencedModelName
sConfigName = swView.ReferencedConfiguration
'Build String
sMsg = sMsg & sViewName & " : " & _
sModelName & " : " & _
sConfigName & vbCrLf
Set swView = swView.GetNextView
If Err.Number <> 0 Then
Err.Clear
Exit Do
End If
Loop
MsgBox sMsg
Set swView = Nothing
Set swDwg = Nothing
Set swApp = Nothing
End Sub
Hope this helps...
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: Document Routine Needed
Will I need to open the part or assembly file sModelName in order to get a list of available configurations? I think that is the only to do it.
RE: Document Routine Needed
For a list of available configurations:
Dim swApp As Object
Dim Part As Object
Dim ConfigNames As Variant
Dim iConfigs As Long
Dim i As Long
Set swApp = GetObject(, "SldWorks.Application")
Set Part = swApp.ActiveDoc
'Get a list of Configurations
iConfigs = Part.GetConfigurationCount
ConfigNames = Part.GetConfigurationNames
For i = 0 To (iConfigs - 1)
MsgBox ConfigNames(i)
Next
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: Document Routine Needed