Jump to content

Export multiple symbols as a single image

Recommended Posts


I wrote the following Python script that finds the first symbol in the active layer, creates an image from the symbol, and then exports the image to a file. This works very well. However, if I try to do something similar with a group containing multiple symbols, the call to vs.CreateImgFromSymbol returns None. This makes sense to me as the name, vs.CreateImgFromSymbol, would seem to imply a symbol rather than a group containing multiple symbols is required as a parameter. My question is whether it's possible to write a python script to export multiple symbols, either grouped or individually, as a single image file. Based on what others on this forum have suggested, I had started to investigate creating a viewport on the active layer and exporting the viewport as an image, so far to no avail. Before I spend more time on the viewport route, I wanted to get some input on whether a viewport is even a viable solution or if there is some other method of exporting multiple symbols as a image.


Many thanks in advance,


import os

hObj = vs.FInLayer(vs.ActLayer())
if hObj == None:
    vs.AlrtDialog("hObj is null")
    inSymName = vs.GetSymName(hObj)
    symWidth = vs.HWidth(hObj)
    symHeight = vs.HHeight(hObj)
    vs.AlrtDialog("hObj: " + inSymName + ", Width: " + str(symWidth) + ", Height: " + str(symHeight))
    imgObj = vs.CreateImgFromSymbol(inSymName, symHeight * 300.0, symWidth * 300.0, 0, 3, 0)
    if imgObj == None:
        vs.AlrtDialog("imgObj is null")
        filePath = os.path.expanduser("~") + os.path.sep + "Downloads" + os.path.sep + inSymName + ".png"
        vs.ExportImageFile(imgObj, filePath)


Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...