<?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: create a bitmap file from the current dwg in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3721208#M52188</link>
    <description>&lt;P&gt;Thank you Gaston,&lt;/P&gt;&lt;P&gt;I didn't explain clearly in my original post, but the bmp will be created from a selection set. I'm not sure how I can use that code with a selection set.&lt;/P&gt;&lt;P&gt;Here's my code. I commented where I need to create the bmp. This can be done with COM, however, I would prefer to figure out how to do it with .net code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; Public Sub Main()

            Dim doc As Document = Application.DocumentManager.MdiActiveDocument()
            Dim ed As Editor = doc.Editor
            Dim docWindow As Window = doc.Window

            docWindow.WindowState = Window.State.Normal

            Dim size As System.Drawing.Size = docWindow.GetSize

            ed.WriteMessage(vbCrLf + "Document Size:" + vbCrLf + size.ToString() + vbCrLf)

            Dim newSize As System.Drawing.Size = New System.Drawing.Size(950, 573) 'was 608

            docWindow.SetSize(newSize)

            ZoomExtents()

            '' Select objects in the drawing area
            Dim ssPrompt As PromptSelectionResult = ed.GetSelection()

            '' If the prompt status is OK, objects were selected
            If ssPrompt.Status = PromptStatus.OK Then
                Dim acSSet As SelectionSet = ssPrompt.Value

                

                'This is where I want to export the selection set to a bmp file

            End If&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Dec 2012 04:12:53 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-12-04T04:12:53Z</dc:date>
    <item>
      <title>create a bitmap file from the current dwg</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3720650#M52185</link>
      <description>&lt;P&gt;I'm working on a VB.NET program that resizes the current drawing window and creates a bitmap file.&lt;/P&gt;&lt;P&gt;Currently, I can get the window to resize to the correct length and width. However, I'm lost as far as creating a bitmap. I found some code in C# on the Through the Interface site:&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://through-the-interface.typepad.com/through_the_interface/2009/09/taking-screenshots-of-autocads-main-and-drawing-windows-using-net.html"&gt;http://through-the-interface.typepad.com/through_the_interface/2009/09/taking-screenshots-of-autocads-main-and-drawing-windows-using-net.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, I'm not that familiar with C# and can't get the code to work if I try to convert to VB.net.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimately, I want to then convert the bmp file to a gif with a transparent background. I know how to convert a bmp to gif, but is it possible to programmatically convert it to a transparent background?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;btm&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2012 19:10:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3720650#M52185</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-03T19:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: create a bitmap file from the current dwg</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3720966#M52186</link>
      <description>&lt;P&gt;You can use the BMPOUT command. (Or PNGOUT).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;ow&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2012 22:10:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3720966#M52186</guid>
      <dc:creator>ow</dc:creator>
      <dc:date>2012-12-03T22:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: create a bitmap file from the current dwg</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3721174#M52187</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use an online service to translate from C# to VB, like this&amp;nbsp;&lt;A target="_blank" title="Translate Service" href="http://www.developerfusion.com/tools/convert/csharp-to-vb/"&gt;DevFusion&lt;/A&gt;, using that, the code from Kean blog translate to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Imports acApp = Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports System.Drawing.Imaging
Imports System.Drawing

Namespace ScreenshotTest
	Public Class Commands
		&amp;lt;CommandMethod("CSS")&amp;gt; _
		Public Shared Sub CaptureScreenShot()
			ScreenShotToFile(acApp.Application.MainWindow, "c:\main-window.png", 0, 0, 0, 0)
			ScreenShotToFile(acApp.Application.DocumentManager.MdiActiveDocument.Window, "c:\doc-window.png", 30, 26, 10, 10)
		End Sub

		Private Shared Sub ScreenShotToFile(wd As Autodesk.AutoCAD.Windows.Window, filename As String, top As Integer, bottom As Integer, left As Integer, right As Integer)
			Dim pt As Point = wd.Location
			Dim sz As Size = wd.Size

			pt.X += left
			pt.Y += top
			sz.Height -= top + bottom
			sz.Width -= left + right

			' Set the bitmap object to the size of the screen

			Dim bmp As New Bitmap(sz.Width, sz.Height, PixelFormat.Format32bppArgb)
			Using bmp
				' Create a graphics object from the bitmap

				Using gfx As Graphics = Graphics.FromImage(bmp)
					' Take a screenshot of our window

					gfx.CopyFromScreen(pt.X, pt.Y, 0, 0, sz, CopyPixelOperation.SourceCopy)

					' Save the screenshot to the specified location

					bmp.Save(filename, ImageFormat.Png)
				End Using
			End Using
		End Sub
	End Class
End Namespace&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for a GIF file with a transparency color, you can do it using GDI+ and setting the Alfa of the selected color to 0 in the palette of the GIF, remember that GIF file have a palette with the colors (max 256) to display.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2012 02:43:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3721174#M52187</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-12-04T02:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: create a bitmap file from the current dwg</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3721208#M52188</link>
      <description>&lt;P&gt;Thank you Gaston,&lt;/P&gt;&lt;P&gt;I didn't explain clearly in my original post, but the bmp will be created from a selection set. I'm not sure how I can use that code with a selection set.&lt;/P&gt;&lt;P&gt;Here's my code. I commented where I need to create the bmp. This can be done with COM, however, I would prefer to figure out how to do it with .net code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; Public Sub Main()

            Dim doc As Document = Application.DocumentManager.MdiActiveDocument()
            Dim ed As Editor = doc.Editor
            Dim docWindow As Window = doc.Window

            docWindow.WindowState = Window.State.Normal

            Dim size As System.Drawing.Size = docWindow.GetSize

            ed.WriteMessage(vbCrLf + "Document Size:" + vbCrLf + size.ToString() + vbCrLf)

            Dim newSize As System.Drawing.Size = New System.Drawing.Size(950, 573) 'was 608

            docWindow.SetSize(newSize)

            ZoomExtents()

            '' Select objects in the drawing area
            Dim ssPrompt As PromptSelectionResult = ed.GetSelection()

            '' If the prompt status is OK, objects were selected
            If ssPrompt.Status = PromptStatus.OK Then
                Dim acSSet As SelectionSet = ssPrompt.Value

                

                'This is where I want to export the selection set to a bmp file

            End If&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2012 04:12:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3721208#M52188</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-04T04:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: create a bitmap file from the current dwg</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3721286#M52189</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What about of using the plotting API to export the zoomed area to a bitmap file?, you have to use the appropriate pc3 configuration file (Publish to Web JPG/PNG.pc3 &amp;nbsp;or create a new one in the plotter manager).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2012 05:52:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3721286#M52189</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-12-04T05:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: create a bitmap file from the current dwg</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3721318#M52190</link>
      <description>&lt;P&gt;The BMPOUT command does accept a selection set, but you would probably need to pInvoke acedCommand from objectArx c++ in order initialize it properly. (I'm using it from C++).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise, Keans' code should work just fine, just set visibility false&amp;nbsp;or turn off unwanted layers&amp;nbsp;on whatever you don't want to display in the image, and restore it afterwards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ow&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2012 06:56:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-bitmap-file-from-the-current-dwg/m-p/3721318#M52190</guid>
      <dc:creator>ow</dc:creator>
      <dc:date>2012-12-04T06:56:13Z</dc:date>
    </item>
  </channel>
</rss>

