Looking for macro to traverse configurations
Looking for macro to traverse configurations
(OP)
I am looking for a macro to go from configuration to configuration and save a snapshot (jpeg) of each one. Is anyone aware of something like this?
When was the last time you drove down the highway without seeing a commercial truck hauling goods?
Download nowINTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS Come Join Us!Are you an
Engineering professional? Join Eng-Tips Forums!
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting GuidelinesJobs |
Looking for macro to traverse configurations
|
Looking for macro to traverse configurationsLooking for macro to traverse configurations(OP)
I am looking for a macro to go from configuration to configuration and save a snapshot (jpeg) of each one. Is anyone aware of something like this?
Red Flag SubmittedThank you for helping keep Eng-Tips Forums free from inappropriate posts. Reply To This ThreadPosting in the Eng-Tips forums is a member-only feature.Click Here to join Eng-Tips and talk with other members! |
ResourcesWhat is rapid injection molding? For engineers working with tight product design timelines, rapid injection molding can be a critical tool for prototyping and testing functional models. Download Now
The world has changed considerably since the 1980s, when CAD first started displacing drafting tables. Download Now
Prototyping has always been a critical part of product development. Download Now
As the cloud is increasingly adopted for product development, questions remain as to just how cloud software tools compare to on-premise solutions. Download Now
|
RE: Looking for macro to traverse configurations
CODE
' Forcibly rebuild each configuration
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vConfNameArr As Variant
Dim sConfigName As String
Dim nStart As Single
Dim i As Long
Dim bShowConfig As Boolean
Dim bRebuild As Boolean
Dim bRet As Boolean
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Debug.Print "File = " + swModel.GetPathName
vConfNameArr = swModel.GetConfigurationNames
For i = 0 To UBound(vConfNameArr)
sConfigName = vConfNameArr(i)
bShowConfig = swModel.ShowConfiguration2(sConfigName)
nStart = Timer
bRebuild = swModel.ForceRebuild3(False)
Debug.Print " Config = " & sConfigName
Debug.Print " ShowConfig = " & bShowConfig
Debug.Print " Rebuild = " & bRebuild
Debug.Print " Time = " & Timer - nStart & " s"
Next i
End Sub
'--------------------------------------
That may give you a start.
I'm sure someone posted a complete macro a long time ago, but have had no luck finding it yet.
RE: Looking for macro to traverse configurations
RE: Looking for macro to traverse configurations
Actualy I've already found that example and modified it o my needs.
RE: Looking for macro to traverse configurations
Can you post for future reference? This comes up occasionally.
RE: Looking for macro to traverse configurations
CODE
' It assumes a model is open and active.
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vConfNameArr As Variant
Dim sConfigName As String
Dim sFileName As String
Dim sPathName As String
Dim nStart As Single
Dim i As Long
Dim bShowConfig As Boolean
Dim bRebuild As Boolean
Dim bRet As Boolean
Dim longstatus As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
vConfNameArr = swModel.GetConfigurationNames
sPathName = "G:\Working\Design\JPG\" 'change sPathName as per your needs
For i = 0 To UBound(vConfNameArr)
sConfigName = vConfNameArr(i)
bShowConfig = swModel.ShowConfiguration2(sConfigName)
nStart = Timer
'bRebuild = swModel.ForceRebuild3(False) 'Forcing the rebuild will slow down the process
sFileName = sPathName & "A" & sConfigName & ".JPG" 'Use A, B, C, ... to save in different views
longstatus = swModel.SaveAs3(sFileName, 0, 0)
Next i
End Sub