|
-
May 24th, 2013, 04:01 PM
#1
Thread Starter
Fanatic Member
Programmatically send autocad plot file to printer/plotter?
I've searched the forum and find similar things, but nothing exactly the same. Does anyone know how I would programmatically print an autocad plot file to a printer or plotter? I don't want to have to involve autocad at all. I just want to make a small program that automatically prints out a list of drawings with a button press. Thanks.
-
May 26th, 2013, 08:54 AM
#2
Re: Programmatically send autocad plot file to printer/plotter?
These are .DWG files?
"I just want to make a small program that automatically prints out a list of drawings with a button press."
I take it you mean 'Prints out drawings from a list' ?
If you get no further replies, I might take a look at doing this, I have plenty of .dwg files to play with... Snag, I'm going to be away from home for a few days. At least that'll give someone else time to reply.
I just did a quick check and found that trying to import a .dwg file results in an error (Error Opening File), as you'd expect, so there's no immediate simple answer.
Poppa.
Along with the sunshine there has to be a little rain sometime.
-
May 28th, 2013, 09:09 AM
#3
Thread Starter
Fanatic Member
Re: Programmatically send autocad plot file to printer/plotter?
I don't use autocad. Of course, it does make .dwg files, but I'm wondering if our designer also creates some sort of plot file for each drawing, if I could just send that to the printer. In the old days of dos, I could use a simple line command in a batch file that would print the file to LPT1 or similar. Now, with windows, I would think it's more involved, but I really don't know the first thing about it. I want to make a VB.NET program in place of a batch file that will keep a list of all drawings that go with a particular product, then, at the press of a button, print out all of the drawings automatically. I know how to do all of it, except send the plot file to the printer. Thanks.
-
Jun 3rd, 2013, 07:35 PM
#4
Re: Programmatically send autocad plot file to printer/plotter?
Hi, ok, I've made a start which may give you some idea of how to go about it, it's by no means complete but it's a start...
Start a new project, add 2 buttons, 1 Listbox and a FolderBrowserDialog. I put the buttons at the bottom of the form without changing it's size, and filled the remaining space with the listbox.
In your C: directory add a folder called C:\DWG (hopefully you don't already have one, still even if you do, that's OK so long as you don't have a file called Test.txt in there, else change the name in the code).
vb.net Code:
Public Class Form1 Dim FilePath, DwgPath, Pdata As String Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Button1.Text = "EXIT" Button2.Text = "PRINT" Button2.Enabled = False SelectFolder() End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Application.Exit() End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Pdata = "" FileOpen(1, DwgPath, OpenMode.Input) Do While Not EOF(1) Pdata += LineInput(1) Loop FileClose() FileOpen(1, "C:\DWG\Test.txt", OpenMode.Output) Write(1, Pdata) FileClose() Application.Exit() End Sub Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged DwgPath = FilePath & "\" & ListBox1.SelectedItem.ToString Button2.Enabled = True End Sub Private Sub SelectFolder() Dim a As Integer, z As String FolderBrowserDialog1.ShowNewFolderButton = False If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then FilePath = FolderBrowserDialog1.SelectedPath Else Application.Exit() End If a = 0 z = "" 'This will empty the ListBox before collecting files. Me.ListBox1.Items.Clear() ' Get all files xxx.dwg from folder. For Each i In My.Computer.FileSystem.GetFiles(FilePath, FileIO.SearchOption.SearchTopLevelOnly, "*.dwg") z = My.Computer.FileSystem.GetName(i) ' Add each file to the list box. Me.ListBox1.Items.Add(z) Next End Sub End Class
If you add this code and run the app', first you'll be presented with an option to chose a folder in which to find your drawing... select a folder and click OK.
Next you'll get a list of the '.DWG' files in that folder, click one of those and if all's well, Button2 (Print) will be enabled. Click that and the app' chould close and in your new C:\DWG folder you should have a 'Test.txt' file containing the data for your drawing, byte by byte as the original, now all you need to do is to write code to open this file and send it to your printer or plotter. Of course, once you've done that, you can marry the two app's to cut-out the middle-man Text.txt file.
I suppose I could've listed the subroutines in the order in which they are called, but by habit I put them in alphabetical order by name, except for the Form1_Load which I always put first... sorry.
Poppa.
Last edited by Poppa Mintin; Jun 4th, 2013 at 05:59 PM.
Along with the sunshine there has to be a little rain sometime.
-
Jun 3rd, 2013, 07:49 PM
#5
Re: Programmatically send autocad plot file to printer/plotter?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 3rd, 2013, 08:00 PM
#6
Re: Programmatically send autocad plot file to printer/plotter?
.Net method:
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
IO.File.Copy(DwgPath, "C:\DWG\Test.txt")
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 4th, 2013, 08:01 AM
#7
Re: Programmatically send autocad plot file to printer/plotter?
 Originally Posted by .paul.
.Net method:
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
IO.File.Copy(DwgPath, "C:\DWG\Test.txt")
End Sub
That's neat, I'll keep that in mind...
Actually I was only giving an example of how to select a file...
DWG files are produced by Auto Cad and can't be used straight from the file anyway... It might be that he'll need to try to break up the file into individual graphic lines, I suspect he won't be able to do that with a straight copy.
Poppa.
Last edited by Poppa Mintin; Jun 4th, 2013 at 08:04 AM.
Along with the sunshine there has to be a little rain sometime.
-
Jun 4th, 2013, 08:31 AM
#8
Re: Programmatically send autocad plot file to printer/plotter?
 Originally Posted by Poppa Mintin
It might be that he'll need to try to break up the file into individual graphic lines, I suspect he won't be able to do that with a straight copy.
As an example, one of my .dwg files has 2099 LineInput lines, the last of which is: ËÏÆ,
The first is:AC1009 Í Ï äì à t~ @W €- í ) !ð Æ ¨ò ¿ Jû ™ äÿ ˆ‰@ Ð@ HŠ@ ‚@ ˆy@Î0,hmr@ Î0,hm‚@ ð? ð? $@ $@ ð? @ $@ Ì §ëº‚ +ö? ð? l C:\ACAD\SUPPOR ð? @ @ $@ @ @ @ T\MARKEM ð? ô? Ð ÿ¯e% ²M/¯e% ²M/ Î,
And a typical line from elsewhere (375) is:×£p8@ 9ÜÇ®æÉ?0ù 2 ô(\¢Î€@š™™™™]m@òÂõ(\W$@FT‘áß@7-+·&Ô?{å* ø€@ n@ @ n@¬×* @23333ûm@ @23333ûm@µÐ* @j×7öcÂm@ @j×7öcÂm@¨ƒ* @dffff""l@ @˜™™™™]m@‡ú* @Ì[û<Ïøl@ @Ì[û<Ïøl@˜û* @˜(È œ½k@ @˜(È œ½k@/|* @4¤Ã0‡l@ @4¤Ã0‡l@""Ò 2 ÷(\¢Î€@fffff""l@AÂõ(\W$@?T‘áß@œ-+·&Ô?£}* ø€@ pk@ @ pk@!\* @ÌÌÌÌÌ„k@ @ÌÌÌÌÌ„k@fÕ* ø€@ *j@ èƒ@ÿÿÿÿÿŸj@z* ˆ@ €f@ °…@ €f@çZ* 33333„@üÿÿÿÿ_]@33333„@þÿÿÿÿÏa@¹}* 33333„@üÿÿÿÿ_]@ „@üÿÿÿÿ_]@2y* 33333„@þÿÿÿÿÏa@ „@þÿÿÿÿÏa@:¦* P„@Œiºðria@ P„@à,‹-^@t* ˆƒ@þÿÿÿÿ+a@ ˆƒ@ ¨^@I¦* –ƒ@þÿÿÿÿ?`@ ˜ƒ@dffffÆ]@é* pƒ@ ¨^@œ÷ÀXƒ@¸¥yW1è^@žg* fEG‚{pƒ@øÛT³^@p=9ýAZƒ@Yp¦&ï^@Þ* Dƒ@ ¨^@ dƒ@˜t¨4K_@lX* 33333÷‚@üÿÿÿÿ¿_@33333÷‚@ ¨^@ãA* š™™™™mƒ@üÿÿÿÿ_@ ˆƒ@ ¨^@ýb* „@þÿÿÿÿÏa@ „@üÿÿÿÿ_]@.$* „@þÿÿÿÿÏa@ „@üÿÿÿÿ_]@…ü* ”ƒ@dffffæ]@ ”ƒ@ÊÌÌÌÌŒa@Ã÷* ¼ƒ@ÊÌÌÌÌœa@”%°i?½ƒ@23333Ã`@õ)* ´ƒ@ÊÌÌÌÌœa@”%°i?µƒ@23333Ã`@ * ¬ƒ@ÊÌÌÌÌœa@”%°i?*ƒ@23333Ã`@_F* œƒ@ÊÌÌÌÌœa@ *ƒ@dffffÆ]@ä* ¤ƒ@ÊÌÌÌÌœa@ ¨ƒ@dffffÆ]@Òc* 33333³‚@üÿÿÿÿ¿_@33333³‚@ ¨^@¢÷* 33333›‚@Øÿÿÿÿ§^@33333›‚@ͪù5*`@]D* Dƒ@ ¨^@33333›‚@ ¨^@xˆ* „@üÿÿÿÿ_]@~#ѰJ„@@H*žÔð]@Ü* ”ƒ@ ¨^@ ˆƒ@ ¨^@š’* pƒ@ ¨^@fEG‚{pƒ@øÛT³^@^å* 33333„@üÿÿÿÿ_]@ „@üÿÿÿÿ_]@ÿ 2 H„@à,‹-^@ ð?>Š**¾8@ G* pƒ@ ,a@œ÷ÀXƒ@$-CTça@â´* fEG‚{pƒ@p’U?&a@p=9ýAZƒ@|ÓǬla@ßq* dƒ@ `@ `ƒ@ `@µí* Dƒ@ ,a@ dƒ@²Å«eÚø`@‹* dƒ@ à_@ `ƒ@ à_@¹* 33333÷‚@þÿÿÿÿŸ`@33333›‚@þÿÿÿÿŸ`@=0* 33333÷‚@üÿÿÿÿ¿_@33333›‚@üÿÿÿÿ¿_@¢f* Dƒ@ ,a@33333›‚@ ,a@ͧ* 33333§‚@þÿÿÿÿŸ`@33333§‚@üÿÿÿÿ¿_@l* 33333ë‚@üÿÿÿÿ¿_@23333ë‚@þÿÿÿÿŸ`@§§* ®F<Ç‚@ `_@23333é‚@ `_@†* ®F<Ç‚@033333_@fffffì‚@033333_@* fffffì‚@03333“_@®F<É‚@03333“_@ˆW* ®F<É‚@`fffff_@23333é‚@`fffff_@/v 2 ®F<Ç‚@˜™™™™I_@ffffffÖ?-DTû!ù?Ò!3|Ù@°í 2 ®F<É‚@03333ƒ_@ Ð?-DTû!ù?Ð-DTû! @px* ®F<Ç‚@\ffffv_@®F<Ç‚@03333ƒ_@”8 2 ®F<É‚@`ffffv_@ Ð?4.DTû! @Ò!3|Ù@T* 33333ï‚@˜™™™™I_@33333ï‚@ÈÌÌÌÌ|_@û 2 23333é‚@03333c_@ €™™™™©?Ò!3|Ù@-DTû!ù?lÒ 2 fffffì‚@ÈÌÌÌÌ|_@ffffffÖ? -DTû!ù?£ 2 fffffì‚@˜™™™™I_@ffffffÖ?Ò!3|Ù@ * ®F<·‚@dffff¶`@fffffÚ‚@dffff¶`@‡Í* fffffÜ‚@üÿÿÿÿÏ`@33333Û‚@üÿÿÿÿÏ`@È* fffffÜ‚@dffffæ`@®F<·‚@dffffæ`@ï<* 33333³‚@ ,a@33333³‚@—™™™™á`@. 2 ®F<·‚@˜™™™™Á`@ffffffÖ?-DTû! @Ò!3|Ù@8¸ 2 ®F<·‚@03333Û`@ffffffÖ?-DTû!ù?-DTû! @²¤* àDyGo´‚@03333Û`@àDyGo´‚@þÿÿÿÿ×`@uÃ* 33333÷‚@ ,a@33333÷‚@þÿÿÿÿŸ`@óq 2 fffffÜ‚@03333Û`@ffffffÖ?Ò!3|Ù@-DTû!ù??Ó* fffffÜ‚@ÎÌÌÌÌÄ`@fffffÜ‚@dffff¾`@Xõ 2 fffffÚ‚@dffff¾`@ Ð?Ò!3|Ù@ à6=v¶ 2 fffffÚ‚@ÌÌÌÌÌÄ`@ Ð? ÀA=é\.
It might also be that he'll need to convert each character into it's ASCII code... again I think he'll need more than just a straight copy.
I might also mention that I picked this question to answer because nobody else had offered any sort of answer... I always figure an answer, no matter how 'old hat' it might be, is much better than no answer at all.
Poppa.
Last edited by Poppa Mintin; Jun 4th, 2013 at 08:37 AM.
Along with the sunshine there has to be a little rain sometime.
-
Jun 4th, 2013, 09:55 AM
#9
Hyperactive Member
Re: Programmatically send autocad plot file to printer/plotter?
I do AutoCAD automation on a grand scale here. If I understand your original question, you want to print "plot" files that were produced by AutoCAD. I'm sure that can be done but my question is why would you want to do that? I am assuming you have AutoCAD available to you. And you can involve AutoCAD without having to involve AutoCAD. That is you can launch it, load and print your drawing and then close it without ever seeing it appear on the monitor. I do this all the time. If you could explain a little more in detail what your setup is that might help. For example, are the "plot" files given to you and you do not have access to AutoCAD itself then we would need to approach this from a different angle. But the best tool to print AutoCAD drawings is AutoCAD. If the folks from your design department are presenting you with "plt" files then why don't they just supply you with PDF files...that would make things much simpler. Also, if you have AutoCAD, this is really a task much better suited to LISP which is again, part of the AutoCAD environment. But if you need to stay completely outside of AutoCAD there are methods available to do what you want.
And BTW, I found this which might help you if you want to just send plt files straight to your printer.
Last edited by Vladamir; Jun 4th, 2013 at 10:04 AM.
-
Jun 4th, 2013, 05:54 PM
#10
Re: Programmatically send autocad plot file to printer/plotter?
 Originally Posted by Vladamir
I do AutoCAD automation on a grand scale here. If I understand your original question, you want to print "plot" files that were produced by AutoCAD. I'm sure that can be done but my question is why would you want to do that? I am assuming you have AutoCAD available to you.
Vladamir did you miss the 3rd post ?
 Originally Posted by rickford66
I don't use autocad. Of course, it does make .dwg files, but I'm wondering if our designer also creates some sort of plot file for each drawing, if I could just send that to the printer. In the old days of dos, I could use a simple line command in a batch file that would print the file to LPT1 or similar. Now, with windows, I would think it's more involved, but I really don't know the first thing about it. I want to make a VB.NET program in place of a batch file that will keep a list of all drawings that go with a particular product, then, at the press of a button, print out all of the drawings automatically. I know how to do all of it, except send the plot file to the printer. Thanks.
Hmmm... I've just noticed that I missed: -
I know how to do all of it, except send the plot file to the printer.
in the 3rd post myself... (Oh bother!)
Sorry Rickford, I've been wasting your time. However Vladamir's suggested URL should be exactly what you're after.
(http://www.lingpartnership.com/plotfiles.htm)
Poppa.
Last edited by Poppa Mintin; Jun 4th, 2013 at 06:07 PM.
Along with the sunshine there has to be a little rain sometime.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|