<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Export all Blocks as PNGs with transparent background in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13420175#M1131</link>
    <description>&lt;P&gt;You can do this with python.&lt;/P&gt;&lt;P&gt;1, you have to compute the aspect ratio, I just used 380x380 since yours is close to that.&lt;/P&gt;&lt;P&gt;2, Transparency is a bit of a hack, set a background color and mask it out&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyrx import Rx, Ge, Gi, Gs, Db, Ap, Ed, Ax
import traceback
import wx #wxPython 

@Ap.Command()
def doit():
    try:
        
        db = Db.curDb()
        bt = Db.BlockTable(db.blockTableId())
        
        for name, id in bt.toDict().items():
            btr = Db.BlockTableRecord(id)
            if btr.isLayout():
                continue
            if btr.isAnonymous():
                continue
            if name.startswith('A$'):
                continue
            
            #id imageX imageY zoom background color 
            img: wx.Image = Gs.Core.getBlockImage(id, 380, 380, 1.0, [0, 0, 0])
            img.SetMaskColour(0,0,0)
            img.SetMask(True)
            img.SaveFile("E:\\temp\\Icons\\{}.png".format(name), wx.BITMAP_TYPE_PNG)
        
    except Exception as err:
        traceback.print_exception(err)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tp.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1488174i4AB9D41D42BE4093/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tp.png" alt="tp.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
    <pubDate>Fri, 11 Apr 2025 00:44:26 GMT</pubDate>
    <dc:creator>daniel_cadext</dc:creator>
    <dc:date>2025-04-11T00:44:26Z</dc:date>
    <item>
      <title>Export all Blocks as PNGs with transparent background</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13419217#M1128</link>
      <description>&lt;P&gt;I have a series of blocks that I have created (approx 50) I would like to export them all separately as PNG files so I can use them in other software.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way that I can automate this? or do it acutely and efficiently?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the file I have created&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2025 14:00:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13419217#M1128</guid>
      <dc:creator>bradley.wherry</dc:creator>
      <dc:date>2025-04-10T14:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Export all Blocks as PNGs with transparent background</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13419321#M1129</link>
      <description>&lt;P&gt;Like this.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2025 14:42:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13419321#M1129</guid>
      <dc:creator>baksconstructor</dc:creator>
      <dc:date>2025-04-10T14:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Export all Blocks as PNGs with transparent background</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13420145#M1130</link>
      <description>&lt;P&gt;Easy make a layout say images. Get all blocks currently in model space. insert the block into your layout, zoom&lt;/P&gt;&lt;P&gt;extents, then plot, erase last and keep going till all blocks are done. Erase image layout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefully later today.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 00:13:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13420145#M1130</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2025-04-11T00:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Export all Blocks as PNGs with transparent background</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13420175#M1131</link>
      <description>&lt;P&gt;You can do this with python.&lt;/P&gt;&lt;P&gt;1, you have to compute the aspect ratio, I just used 380x380 since yours is close to that.&lt;/P&gt;&lt;P&gt;2, Transparency is a bit of a hack, set a background color and mask it out&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyrx import Rx, Ge, Gi, Gs, Db, Ap, Ed, Ax
import traceback
import wx #wxPython 

@Ap.Command()
def doit():
    try:
        
        db = Db.curDb()
        bt = Db.BlockTable(db.blockTableId())
        
        for name, id in bt.toDict().items():
            btr = Db.BlockTableRecord(id)
            if btr.isLayout():
                continue
            if btr.isAnonymous():
                continue
            if name.startswith('A$'):
                continue
            
            #id imageX imageY zoom background color 
            img: wx.Image = Gs.Core.getBlockImage(id, 380, 380, 1.0, [0, 0, 0])
            img.SetMaskColour(0,0,0)
            img.SetMask(True)
            img.SaveFile("E:\\temp\\Icons\\{}.png".format(name), wx.BITMAP_TYPE_PNG)
        
    except Exception as err:
        traceback.print_exception(err)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tp.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1488174i4AB9D41D42BE4093/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tp.png" alt="tp.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 00:44:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13420175#M1131</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2025-04-11T00:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Export all Blocks as PNGs with transparent background</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13420190#M1132</link>
      <description>&lt;P&gt;Good &lt;A href="mailto:idea@daniel" target="_blank"&gt;idea &lt;/A&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8575899"&gt;@daniel_cadext&lt;/a&gt;, one question to&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7914045"&gt;@bradley.wherry&lt;/a&gt;&lt;SPAN&gt;&amp;nbsp;do you want all blocks in block table or just those that are used in the current dwg.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 00:53:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13420190#M1132</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2025-04-11T00:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Export all Blocks as PNGs with transparent background</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13420691#M1133</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8575899"&gt;@daniel_cadext&lt;/a&gt;&amp;nbsp;thats a great solution. I was attempting something similar, but my coding needs some work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 08:27:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-all-blocks-as-pngs-with-transparent-background/m-p/13420691#M1133</guid>
      <dc:creator>bradley.wherry</dc:creator>
      <dc:date>2025-04-11T08:27:19Z</dc:date>
    </item>
  </channel>
</rss>

