Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Batch Image Export of Configurations 3

Status
Not open for further replies.

Guest0527211403

Mechanical
Apr 24, 2004
1,125
Hi Folks,

I work on assemblies of automation systems where we generate configurations of the various "states" of the various axes.

As part of our design review process I often generate images from a single viewpoint of the assembly in various states, so we can "jog" through the process with management and other engineers, typically in a powerpoint presentation.

As we change the assembly, I often have to update my slides to reflect the latest version. What I presently do is switch to that configuration and take a screenshot (macro for the screenshot), then paste into my powerpoint. It's a pretty tedious process and I'd like to automate it somehow.

I'm looking for a method or technique where I can tell Solidworks to generate an image of each of my configurations at a given orientation, and save these images to a folder with incremented file names.

Is this something that's exclusively in the domain of VB scripting, or is there another tool or technique I could use to generate these images?

Thanks in advance!
 
Replies continue below

Recommended for you

In SolidWorks Help look up Animation.
hopefully that will help.
 
Try these codes

Code:
Sub main()

    Dim swApp                       As SldWorks.SldWorks
    Dim swModel                     As SldWorks.ModelDoc2
    Dim vConfigNameArr              As Variant
    Dim vConfigName                 As Variant
    Dim swConfig                    As SldWorks.Configuration
    Dim swConfMgr                   As SldWorks.ConfigurationManager
   
    Set swApp = CreateObject("SldWorks.Application")
    Set swModel = swApp.ActiveDoc
    Set swConfMgr = swModel.ConfigurationManager
    Set swConfig = swConfMgr.ActiveConfiguration

    vConfigNameArr = swModel.GetConfigurationNames

    For Each vConfigName In vConfigNameArr
        Set swConfig = swModel.GetConfigurationByName(vConfigName)
    swModel.SaveAs3 swConfig.Name & ".jpg", 0, 1

    Next

End Sub

Deepak Gupta
CSWE, CSWP, CSDA
SW 2012 SP4.0 & 2013 PR1
Boxer's SolidWorks™ Blog
SolidWorks™ Rendering Contest

 
Thanks Deepak.
Will try shortly and let you know how it goes.
This helps strengthen my resolve to go through the available tutorials on vb in Solidworks.
 
Had to add a boolean and a ShowConfiguration line in order to make the above macro switch configurations. Thanks again Deepak for steering me in the right direction. This is going to be a HUGE time saver in my group.

Code:
Dim swApp As Object
Sub main()
    Dim swApp                       As SldWorks.SldWorks
    Dim swModel                     As SldWorks.ModelDoc2
    Dim vConfigNameArr              As Variant
    Dim vConfigName                 As Variant
    Dim swConfig                    As SldWorks.Configuration
    Dim swConfMgr                   As SldWorks.ConfigurationManager
    Dim boolstatus                  As Boolean
    
   
    Set swApp = CreateObject("SldWorks.Application")
    Set swModel = swApp.ActiveDoc
    Set swConfMgr = swModel.ConfigurationManager
    Set swConfig = swConfMgr.ActiveConfiguration

    vConfigNameArr = swModel.GetConfigurationNames

    For Each vConfigName In vConfigNameArr
        Set swConfig = swModel.GetConfigurationByName(vConfigName)
        boolstatus = swModel.ShowConfiguration2(vConfigName)
        swModel.SaveAs3 swConfig.Name & ".jpg", 0, 1

    Next

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor