API EXPORT PNG

API EXPORT PNG

yhonsalas
Enthusiast Enthusiast
73 Views
1 Reply
Message 1 of 2

API EXPORT PNG

yhonsalas
Enthusiast
Enthusiast

yhonsalas_0-1789088490676.png

 

0 Likes
74 Views
1 Reply
Reply (1)
Message 2 of 2

Stephane.kapetanovic
Mentor
Mentor

HI @yhonsalas 

This macro saves a PNG screenshot of the project's first view to a folder named "PNG_Files" automatically appending an incremental number to the filename if a file with that name already exists.

Sub SaveScreenCaptureToFile()
  Dim RobApp As RobotApplication: Set RobApp = New RobotApplication
  
  Dim filePath As String: filePath = GetFolder(RobApp.Project.FileName) & "PNG_Files\"
  Dim fso As Object: Set fso = CreateObject("Scripting.FileSystemObject")
  If Not fso.FolderExists(filePath) Then fso.CreateFolder filePath
  
  Dim baseName As String: baseName = "ScreenCapture"
  Dim ext As String:           ext = ".png"
  Dim fullPath As String: fullPath = filePath & baseName & ext
  
  Do While fso.FileExists(fullPath)
    i = i + 1: fullPath = filePath & baseName & "(" & i & ")" & ext
  Loop
  
  If Not RobApp.Project.viewMngr.GetView(1).Printable.SaveToFile(fullPath, I_OFF_PNG) Then
    MsgBox "Failed to save the screen capture.", vbOKOnly, "Error"
  End If
 
  Set fso = Nothing
  Set RobApp = Nothing
End Sub

for more settings

https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-command-vba-projection-capture-of...

https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-save-a-view-from-robot-on-desktop...

Best Regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature