×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Batch Image Export of Configurations
3

Batch Image Export of Configurations

Batch Image Export of Configurations

(OP)
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!

RE: Batch Image Export of Configurations

In SolidWorks Help look up Animation.
hopefully that will help.

RE: Batch Image Export of Configurations

3
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

RE: Batch Image Export of Configurations

(OP)
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.

RE: Batch Image Export of Configurations

(OP)
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 --> VBa

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 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources