How can we create an WB project schematic image similar to those created by ExportReport()?

Erik Kostson
Erik Kostson Member, Moderator, Employee Posts: 335
50 Answers 100 Comments Second Anniversary 25 Likes
✭✭✭✭
edited May 29 in Structures

A project schematic image is created when executing the ExportReport() method (workbench scripting). This image is located in a folder with the same name as the report name (+ _images) and in the same directory. How can we though generate this or similar image but without executing the ExportReport() method?

Best Answer

  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 335
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    Answer ✓

    The way to do that is to use system.drawing and bitmap class. An example is given below (change as needed):

    import time
    import clr
    import os
    import sys
    clr.AddReference("System.Windows.Forms")
    clr.AddReference("System.Drawing")
    
    from System.Drawing import Bitmap,Graphics,Point,Size
    time.sleep(3)
    bmp = Bitmap(1920, 1200)  # User defined image size
    g = Graphics.FromImage(bmp)
    g.CopyFromScreen(0,0, 0, 0, Size((1920), (1200)))
    bmp.Save('D:/myrep.png')
    
    
This discussion has been closed.