Jump to content
sstanelle

Export multiple symbols as a single image

Recommended Posts

Hi,

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,

Scott
 

import os

hObj = vs.FInLayer(vs.ActLayer())
if hObj == None:
    vs.AlrtDialog("hObj is null")
else:
    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")
    else:
        filePath = os.path.expanduser("~") + os.path.sep + "Downloads" + os.path.sep + inSymName + ".png"
        vs.ExportImageFile(imgObj, filePath)

 

Share this post


Link to post

Maybe create a temporary symbol > add all other symbols in there > place on drawing > export as image > delete temporary symbol

  • Like 1

Share this post


Link to post

twk,

 

Thank you very much for your response and for your solution. This worked great! I can't believe that I didn't think of this obvious and simple solution. 😄

 

Regards,

Scott

Share this post


Link to post

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.

Guest
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.


 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...