.NET

Reply
Distinguished Contributor
GeeHaa
Posts: 150
Registered: ‎04-14-2005
Message 11 of 20 (904 Views)

Re: Copy .plt files to a plotter

04-09-2012 07:08 AM in reply to: GeeHaa

When I use the open IP address command it opens the right plotter. Ping also works. The telnet command is unrecognized. I tried the code from the link and I still get the 550 file not found error. It says its logged in and everything in the response section of the error status. According to the OCe users manual FTP should work.

 

Sub TEST()
        Dim clsRequest As System.Net.FtpWebRequest = _
        DirectCast(System.Net.WebRequest.Create("ftp://serv/oce tds750/X.plt"), System.Net.FtpWebRequest)
        clsRequest.Credentials = New System.Net.NetworkCredential("anonymous", "Password")
        clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile

        ' read in file...
        Dim bFile() As Byte = System.IO.File.ReadAllBytes("C:\Lisp\X.plt")

        ' upload file...
          Dim clsStream As System.IO.Stream = _
                        clsRequest.GetRequestStream()
            clsStream.Write(bFile, 0, bFile.Length)
            clsStream.Close()
            clsStream.Dispose()
             
    End Sub

 

Thanks

 

Mentor
SENL1362
Posts: 150
Registered: ‎07-20-2011
Message 12 of 20 (900 Views)

Re: Copy .plt files to a plotter

04-09-2012 07:37 AM in reply to: GeeHaa

Ok, it's a OCE 750, probably HPGL2  contents to upload.

This requires binary mode because of the non ASCII data.

 

That's why i mentioned copy /b 

see this VB .net 2 sample 

http://www.codeproject.com/Articles/17202/Simple-FTP-demo-application-using-C-Net-2-0

 

Distinguished Contributor
GeeHaa
Posts: 150
Registered: ‎04-14-2005
Message 13 of 20 (894 Views)

Re: Copy .plt files to a plotter

04-09-2012 01:49 PM in reply to: GeeHaa

I sort of figured out half of it. On the Oce after logging in and typing binary you have to change directories to the jobs folder on the plotter server. Once I did this the Put "x.plt" command worked now I just have to figure out how to change to this directory  in .Net.

 

Thanks for all your help.

Distinguished Contributor
GeeHaa
Posts: 150
Registered: ‎04-14-2005
Message 14 of 20 (883 Views)

Re: Copy .plt files to a plotter

04-10-2012 02:20 PM in reply to: GeeHaa

Here Is what I'm trying. It pops up a command window and it sits open for about 30 seconds as if it was logging in but it does not print and it doesn't throw an exception maybe one of you can see what is wrong.

Dim pr As Process
        Dim args As New ProcessStartInfo("cmd.exe")
        With args
            .RedirectStandardInput = True
            .RedirectStandardOutput = True
            .UseShellExecute = False
            .WindowStyle = ProcessWindowStyle.Normal
        End With
        pr = Process.Start(args)
        pr.StandardInput.WriteLine("echo on" & Convert.ToChar(13)) 'chr(13) Enter key.
        pr.StandardInput.WriteLine("CD C:\LISP" & Convert.ToChar(13)) 'chr(13) Enter key.
        pr.StandardInput.WriteLine("FTP" & Convert.ToChar(13))
        pr.StandardInput.WriteLine("OPEN 192.1.1.164" & Convert.ToChar(13))
        pr.StandardInput.WriteLine("anonymous" & Convert.ToChar(13))
        pr.StandardInput.WriteLine(Password  & Convert.ToChar(13))
        pr.StandardInput.WriteLine("binary" & Convert.ToChar(13))
        pr.StandardInput.WriteLine("cd jobs" & Convert.ToChar(13))
        pr.StandardInput.WriteLine("put " + Chr(34) + "x x.plt" + Chr(34) & Convert.ToChar(13))
        pr.StandardInput.WriteLine("bye")
        pr.CloseMainWindow()

If I try this manually it works fine. 

Again thanks very much for your help.

Mentor
SENL1362
Posts: 150
Registered: ‎07-20-2011
Message 15 of 20 (877 Views)

Re: Copy .plt files to a plotter

04-10-2012 11:30 PM in reply to: GeeHaa

Isn't writeline already terminating the input with CR+LF

 

The enter key is CR+LF, so maybe you have to terminate each line with chr(13)+chr(10)

You did not terminate BYE

Distinguished Contributor
GeeHaa
Posts: 150
Registered: ‎04-14-2005
Message 16 of 20 (868 Views)

Re: Copy .plt files to a plotter

04-11-2012 10:55 AM in reply to: GeeHaa

Adding the Line Feed after enter works. The only problem is it leaves the Dos window open and does not send the plots until you click inside the window and hit enter. I tried sending an enter and Line feed after bye but it still stays open without sending the files.

 

Thanks

Valued Mentor
fieldguy
Posts: 367
Registered: ‎03-31-2005
Message 17 of 20 (855 Views)

Re: Copy .plt files to a plotter

04-12-2012 03:33 PM in reply to: fieldguy

I got the code to work for my hp laser.  GeeHaa's comment about the "jobs" folder on the printer got me thinking.

 

I used the same script as before but used "pwd" (print working directory).  The printer replied "/" is the current directory.  I added an extra slash to the URI in the code and it worked.

 

Test script from CMD:

ftp

open 192.168.1.1

<login> user

<pword> guest

pwd <enter>

quit

 

<CommandMethod("ftp4")> _
    Public Shared Sub ftp4()
        Dim request As FtpWebRequest = _
            DirectCast(FtpWebRequest.Create("ftp://192.168.1.1//" & Path.GetFileName("c:\Temp\TEST.TXT")), FtpWebRequest)
        request.Method = WebRequestMethods.Ftp.UploadFile
        request.Credentials = New NetworkCredential("user", "guest")
        request.UsePassive = False
        request.UseBinary = True
        request.KeepAlive = False
        request.Proxy = Nothing
        'request.r
        'Load the file
        Dim stream As FileStream = File.OpenRead("c:\Temp\test.txt")
        Dim buffer As Byte() = New Byte(CInt(stream.Length - 1)) {}
        stream.Read(buffer, 0, buffer.Length)
        stream.Close()
        'Upload file
        Dim reqStream As Stream = request.GetRequestStream()
        reqStream.Write(buffer, 0, buffer.Length)
        reqStream.Close()
        MsgBox("Uploaded Successfully", MsgBoxStyle.Information)
    End Sub

 

The code above can be used to upload plt files to hp printers. 

 

Mentor
SENL1362
Posts: 150
Registered: ‎07-20-2011
Message 18 of 20 (849 Views)

Re: Copy .plt files to a plotter

04-13-2012 12:32 AM in reply to: GeeHaa

Unfortunately currently i cannot do tests on any OCE device, but did some tests earlier.

One of tests had to do with the OCE JobTicket, the header info in a OCE PRN file.

Have a look at the the OCE JobTicket 2.6 specifications. One of the setings is JobStore:

JobStore boxname <dbname>
This specifies the name of the Smart Inbox in which the job shall be stored.

 

 

BeginTicket 2.6
  username JohnSmith
  jobname "TestJob 1"
  jobStore boxname myqueue
  BeginBlock 1
    hpgl2 plottertype HP650C origin lowerright  sp_eof off merge off
    Segment 1
    emulation hpgl2
  EndBlock

  BeginOutput
    includeBlock 1
  EndOutput
EndTicket
*OceJobData
      ESC%0BINBP5,1CO"Océ WPD - version 1.19 build 10.12.07.1"PS37200,11880IP0...
*OceJobEnd

 This type of PRN files can be submited to the OCE printer either

- using a simple copy command:copy /b C:\temp\oce.prn LPT1

- using youre ftp way of printing probably without the need to change the directory

 

 

Distinguished Contributor
GeeHaa
Posts: 150
Registered: ‎04-14-2005
Message 19 of 20 (845 Views)

Re: Copy .plt files to a plotter

04-13-2012 06:56 AM in reply to: GeeHaa
DirectCast(FtpWebRequest.Create("ftp://192.168.1.1/jobs/" & Path.GetFileName("c:\Temp\TEST.TXT")), 

 Thank You both so much. All I did was add Jobs  in the URI and it Worked!!!

Distinguished Contributor
GeeHaa
Posts: 150
Registered: ‎04-14-2005
Message 20 of 20 (836 Views)

Re: Copy .plt files to a plotter

04-13-2012 11:02 AM in reply to: GeeHaa

In order to send more than one file at a time (without logging in for each file) using this method do I need to use asynchronous operations?

 

Thanks

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community