4 Replies Latest reply on Apr 18, 2016 11:54 PM by Deepak Gupta

    Saving Image Capture to File

    Alan Thomason

      Does anyone have any advice to save the image capture to a file?


      The following link was very helpful in guiding me to a solution to actually capture the image, but I am working in VBA and cannot seem to find a way to save the clipboard image to a filename.


      https://forum.solidworks.com/thread/113240?q=Saving Image Capture To File


      I modified the syntax from what I presume is VB.NET to VBA to get:

      swApp.RunCommand swCommands_ScreenCapture, Empty


      And this does seem to get the image on the clipboard, but I can't seem to get any further.

      Thanks in advance.

        • Re: Saving Image Capture to File
          Deepak Gupta

          Check if the macros posted here helps: Macro to save jpg of iso view

            • Re: Saving Image Capture to File
              Alan Thomason

              Hi Deepak...

              Thanks very much but unfortunately, what I need is a simple screen grab. The reason that I need this is one of those nested loop situations...

                - Customer needs a simulation of a cable actuated door.

                - This assembly can be modeled in motion, including the speed up/down of the motor, but the cable can't be shown visually.

                        If this was an animation, I can draw the cable in context and it rebuilds nicely every frame like in the following...   

                        Rotary Flexure PMI 2014 06 18 - YouTube

                       But the situation (motor sizing, etc) really needs the physics calculations.

                -  I wrote a macro that interrupts the motion simulation every step and rebuilds.  Unfortunately when you replay the

                     animation it reverts to not rebuilding so the cable stays the same length.

                -  Next tried the print screen (SaveAs3) but it stops the Motion study.

                 - Next thought, a simple Image Grab after each frame rebuild.  It does grab the image during the motion study but with no

                        way to save the images off, I only see the last one.


              Bummer.  So my need is to be able to save what is in the clipboard to a file.  This is one of those situations where one feels quite surprised that something that seems so fundamental is so difficult.  I have found some examples, but they are quite old (<2009) and when you try to use them the first step is that the compiler rejects the " Declare Function" lines and suggests you investigate that these functions are applicable to 64 bit systems and then change this to "Declare PtrSafe Function".  This works sometimes, but once in a while corrupts the base memory (yikes).  This seems possible in VB.NET but so far no luck in VBA.


              Anyway, this would be a good opportunity to thank you for all the selfless work you do.  I find your name at the top of so many useful posts that I have mentioned to people your name to look for when they have SolidWorks problems and need to look through the forum posts.