HPGL Vinyl Cutter/Plotter control via serial port

Hi Guys,

A few years back I was given a Vinyl Cutter without any driver software and was able, with a bit of research and code bashing to get Rhino to send files to it directly in HPGL format using a USB to Serial adaptor and a ‘null modem’ connection - via some pretty simple Python Scripts.

I’ve recently done some updates to the code - in particular I’ve removed the com port number from being hard coded in the scripts to being set in an INI file. With USB to serial adaptors the port number can move around from time to time and this make it much easier to change when needed.

The three scripts are attached if anyone else has the same need/want to drive a cutter direct from Rhino.

210703_DK_Plot_Curves.py (4.3 KB)
210703_DK_Get_Plot_Size.py (1.9 KB)
210703_DK_Set_Com_Port.py (564 Bytes)

You will need to use a ‘Null Modem’ version of a USB to Serial for this to work, or a standard USB to serial + a null modem cable/adaptor:

I’m going to try and use the Rhino Script complier next to see if I can turn this into a set of commands/UI/Installer.

3 Likes

OK - so the Rhino Script Complier process was pretty simple - no UI yet - but the commands work:

DK_Plot_Curves
DK_Get_Plot_Size
DK_Set_Com_Port

DK_Plotter.rhp (17 KB)

Two updates:

1/ Have done some work to make this ‘slightly’ more portable with where it stores the INI file.

2/ Got sick of the plotter roaming all over the place while cutting curves in what ever random order they were served up in, now does a simple curve sort based on the area centroid distance from the origin.

New versions of the .PY files and the .RHI installer attached.

210724_DK_Get_Plot_Size.py (2.0 KB)
210724_DK_Plot_Curves.py (4.5 KB)
210724_DK_Set_Com_Port.py (614 Bytes)
DK_Plotter[1].rhp (17.5 KB)

2 Likes

We recently acquired a vinyl cutter that comes with easy cut software and it works very well. the software send files to it directly in HPGL format using a USB to Serial adaptor.

@martynjhogg what we talked about yesterday

1 Like

Hi All,

A follow on from this thread:

I’ve spent some ‘fun time’ this week looking at re-writing this code to be cross platform.

The upshot from that has been updating to Python3 and using Pyserial rather than the IronPython serial library (which is windows only).

A bit of a issue is I got rid of the Vinyl cutter that I developed this code for last year - so only way to test has been using a terminal and virtual comm ports.

Attached is currently where we are at - ‘working but needs testing’

250301_DK_Plot_Curves.py3.py (4.6 KB)
250301_DK_Get_Plot_Size.py3.py (2.5 KB)
250301_DK_Set_Com_Port.py3.py (1.4 KB)

OK - wind is UP - I’m heading to the beach, more progress later.

Cheers

DK

@Paul_Carbone - update for you!

Cool! So I tried running DK_Set_Com_Port using RunPythonScript, and I get the following error (after Rhino did a bunch of downloading / installing python guts):

Traceback (most recent call last):
  File "file:///Users/paul/Desktop/Rhino%20Plot/250301_DK_Set_Com_Port.py3.py", line 20, in <module>
AttributeError: 'NoneType' object has no attribute 'Assembly'

If I copy/paste into the Python editor in Rhino & run it, I get
“Message: No module named configparser” in a pop-up.

Admittedly, this is on an 8 year old machine running 12.7 - I’ve got an M1 lappy that’s in the middle of an upgade to 14.7 and I’ll try this on that when it’s done.

Thanks, and enjoy the beach!

Hi Paul,

Thank you for the feedback

Firstly:

What version of R8 are you on - this was a known bug until 8.17:

https://mcneel.myjetbrains.com/youtrack/issue/RH-85967

Secondly - in the code I assume that it is being run as a plugin - and I ask rhino to tell me where the plugin is installed and use that as the location to save the com port data as an ini file.

When you just run the .py file the plugin is not loaded and therefore there is no location to report.

I get around this in development by having the plugin installed and running it once to have it loaded in the background.

Thinking about it - I might try a different approach here, I’m in my office this evening - I’ll give this a go PLUS look at compiling the plugin for you.

Cheers

DK

SO - here we go.

I’ve changed the ini save directory to one that doesn’t need the plugin to be loaded - the .py files should run as is.

Also compiled into a YAK using the R8 script editor - that’s a new one for me (Rhino script compiler does not seem to support python 3 files)

All attached - need testing!

Cheers

DK
250305_DK_Plot_Curves.py3.py (4.4 KB)
250305_DK_Get_Plot_Size.py3.py (2.3 KB)
250305_DK_Set_Com_Port.py3.py (1.3 KB)
dk_plotter-25.3.5+9196-rh8-any.yak (41.2 KB)

OK, attempting on Intel Mac, OS 12.7.4, Rhino 8.17.25063.13002
Running the plugin:

  • I can run DK_sel_com_port (it’s asking for cu, not tty, right?)
  • DK_get_plot_size returns ‘plotter not ready’, but I do briefly see traffic on my serial adapter.
  • DK_plot_curves yields an error in the command history:
  File "file:///Users/paul/.rhinocode/stage/3dvt2pkl.b5z", line 67, in <module>
  File "/Users/paul/.rhinocode/py39-rh8/lib/python3.9/_sitebuiltins.py", line 26, in __call__
    raise SystemExit(code)
SystemExit: SystemExit exception
Error occured running command "e535cfc8-d2c5-429c-ab92-ff74aaf23117" | Traceback (most recent call last):
  File "file:///Users/paul/.rhinocode/stage/3dvt2pkl.b5z", line 67, in <module>
  File "/Users/paul/.rhinocode/py39-rh8/lib/python3.9/_sitebuiltins.py", line 26, in __call__
    raise SystemExit(code)
SystemExit: SystemExit exception

Running the python scripts, I get a different error for DK_plot_curves in a pop-up:

Message: No module named Ports

Traceback:
line 8, in <module>, "/Users/paul/Downloads/210724_DK_Plot_Curves.py"

let me know if there’s anything else I should try? I’ve got M1 mac as well, but all the serial adapters I have only seem to have intel drivers. Happy to grab a new adapter if that might help.
thanks!

Hi Paul,

Just found some time to look into this for you.

First off, I have updated the .yak file as it appears it built using some older code. I’ve tested on my Mac Mini test bed and it should now tell you which serial ports are available - you need to type in the full path ie:

/dev/cu.usbserial-AH067PF

Is what comes up on my Mac with a usb serial port adaptor attached.

DK_get_plot_size sends the string “OH;” to the serial port, waits 5 secs then checks to see if any message has returned from the serial port.

With my original vinyl cutter the OH command would ask for the full cutting area available and return a sting in the format “0,0,20000,20000” where the returned units are 0.025mm - ie 0,0,20000,20000 = a square 500mmx500mm.

OH is a standard HPGL command for ‘hard limits’ ie the full size of the machine.

If nothing is returned the code will print “Plotter not ready” and exit.

Could you install a serial terminal program on your Mac, point it to the serial port with your plotter on it and Type ‘OH;’ - it would be interesting to see if anything is returned.

Also - my vinyl cutter could not take a usb-serial adaptor directly, I needed a ‘null modem’ connection in between - do you have that setup?

On the error messages using DK_plot_curves - I had commented out a try/except block - I’ve now fixed that.

Code and .yak attached, .yak is also on the package manager as DK_Plotter if you’d like to try to install that way.

250305_DK_Get_Plot_Size.py3.py (2.3 KB)
250305_DK_Plot_Curves.py3.py (4.4 KB)
250305_DK_Set_Com_Port.py3.py (1.3 KB)
dk_plotter-25.3.16.2-rh8-any.yak (43.4 KB)
HPGL reference.pdf (114.1 KB)

Beating on this some more on my end; I think I’m seeing a combination of mac related serial port shenanigans and some plotter quirks:

  • Inkscape on Windows works fine, Inkscape on Mac chokes after a few lines. I’m using the ‘Plot’ extension, with HPGL selected.
  • Control from the terminal not working from either. I swear I could do an IN;PD;PU; and at least get some life out of it a few weeks ago. It reports ‘Cutting’ whenever it receives characters. None of the Output Instructions report anything.
  • I have been using a null modem adapter. When working w/ Inkscape in Win10, it seems to be pretty tolerant of various flow control settings. When it doesn’t work in Mac or via the terminal, changing the flow control has no effect. I assumed RTS/CTS was a safe bet, and It’s always set to 9600 8N1.
  • The plotter has both serial & USB inputs - the USB is just an FTDI adapter. They both behave the same.

So this is seeming like an issue not related to Rhino. I wish I could see what Inkscape is sending; I’m tempted to lug my VT-100 terminal up here watch the output.

Sorry for the tail chasing, but I’m gonna keep banging on this.
thanks!

@brian thanks for your comment on my LinkedIn article. This thread might help move your own project forward.

Happy to help if your have any questions.

Cheers

DK

1 Like

Hey @kiteboardshaper i just got into plotting as my flatmate has a vevor Ki-870a plotter for cutting vinyl.

the software signmaster 3.5 which got shipped with it is Rather clunky, as grasshopper/rhino is my Main driver I was researching if I can sent ho/gl Format Directly to the plotter!

and sure it seems like it can! I Will try out your little Handy tool!

One Nice thing tho: the signmaster software has a native calibration tool builtin so its plotting a Matrix of different letters with different offsets. Rather simple and i think easy to recreate. But I wanted to see if you have a recommendation or even proved functionality to it in your script ?

Im also into Kitesurfen since Many years also built my own board :smiley: so I’m also super stoned to check out your kite scripts aswell!!! I love rabbit holes hahaha