Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1] 2
Author Topic: Polargraph Optimiser
stereoeric
Newbie
Posts: 22
Permalink
stereoeric
Post Polargraph Optimiser
on: December 19, 2014, 23:31
Quote

I have an SVG queue with 190,000 lines, and would like to use the optimizer, but am not sure how to run my queue through the optimizer. Any help would be appreciated.

sandy
Administrator
Posts: 1427
Permalink
sandy
Post Re: Polargraph Optimiser
on: December 21, 2014, 00:53
Quote

Hello, I wrote up this page - see if it helps.

https://github.com/euphy/polargraph/wiki/Vector-Optimizer

stereoeric
Newbie
Posts: 22
Permalink
stereoeric
Post Re: Polargraph Optimiser
on: December 21, 2014, 19:25
Quote

Hi, Sandy - thank you for posting instructions on how to use the Optimizer. However, as usual, I have to be led by the hand. As you can see from the attached screenshot, I did what you said (I think), but the word "python" appeared to cause a problem. Then I tried again, leaving out the word "python". This seemed to help, as the optimizer apparently did some optimizing, as evidenced by the subsequent result. However, it apparently ran into a problem somewhere, and although it produced a file named cat3_2.txt, there is nothing on it. Any idea what the problem is? https://www.flickr.com/photos/stereoeric/16072690072/

william_b
Newbie
Posts: 10
Permalink
Post Re: Polargraph Optimiser
on: December 21, 2014, 19:48
Quote

I also tried it. I ran "python process.py queue.txt > queue_2.txt", from within the python folder. (No idea if you need to work from within the python folder.)
It gave the same error as the above. I think it is an error in the code, since dividing by 15 is not always an integer.

sandy
Administrator
Posts: 1427
Permalink
sandy
Post Re: Polargraph Optimiser
on: December 21, 2014, 21:20
Quote

Hey thanks for giving it a shot, I wonder if it's a python 3 vs python 2 thing? I've got python 2.7 installed and there are sometimes some odd differences between 2 and 3.

I'm not sure from looking at the code whether the float is the result of the the division or not, but I'd guess that it would get coerced into being an int anyway. You could try modifying line 44 in process.py so it casts the result to int:

for i in range(0, len(glyphs), int(len(glyphs) / 15)):

Does anyone want to send me their command queue and let me try here on my machine?

You could also try processing the sample map.txt that is included with the optimizer - see if that makes the same error.

sn

william_b
Newbie
Posts: 10
Permalink
Post Re: Polargraph Optimiser
on: December 22, 2014, 07:20
Quote

Hello Sandy,
I used the motorcycle.txt, that came with the program.

sandy
Administrator
Posts: 1427
Permalink
sandy
Post Re: Polargraph Optimiser
on: December 22, 2014, 10:40
Quote

I tried running stereoeric's queue through on my install (Python 2.7), and it optimised successfully, so I think it is a Python2 vs Python3 issue. There's some subtle differences between the two versions, and I don't have the experience to see the issue immediately. In the immediate, the solution is to install Python2 instead of 3, and I'll try to have a look at porting this to 3.x.

sn

william_b
Newbie
Posts: 10
Permalink
Post Re: Polargraph Optimiser
on: December 22, 2014, 15:21
Quote

I just tried to optimise it with python 2.7, and it works.

Thanks

David
Newbie
Posts: 2
Permalink
Post Re: Polargraph Optimiser
on: July 11, 2015, 14:01
Quote

Hi,
Came across this older thread trying to get the optimizer to work but I must be missing something and have some basic questions.

Okay so I have Python 2.7.10 downloaded and installed in my programmes and also the optimizer files downloaded and extracted into their own folder. Firstly do I need to copy the optimizer files into the Python programme folders and if so where do they need to be copied across to please?

To produce the command queue I've setup the Polargraph with the SVG imported and hit draw vector to produce the queue before quickly pausing the machine. Then save as from the queue menu as a text file (export queue doesn't seem to be giving me a txt file). Is there a way of exporting the queue without having to start and pause the drawing or is this the right approach?

Where then does this text file need to be placed for Python to see it and do the optimising? Does it need to be placed into the Python folder directly or how can I steer it in the direction of another folder location?

Thanks for any help.

sandy
Administrator
Posts: 1427
Permalink
sandy
Post Re: Polargraph Optimiser
on: July 12, 2015, 00:12
Quote

Hi David, there's a page about this on the wiki: https://github.com/euphy/polargraph/wiki/Vector-Optimizer see if that gives you any pushes in the right direction.

You don't need to have the queue running to be able to draw vectors, or do anything, so just make sure it's paused before you generate any commands - they won't go anywhere. Alternatively, don't connect your machine, and it won't matter if the queue is running or not.

When building your queue, remember you always need to have a "set home" as the first command in it. That command is pre-loaded automatically when you start the controller too, but if you clear your queue, just bear in mind to make sure you "set home" before you "draw vector".

You can save the queue txt file (export queue) wherever you like, doesn't matter. I always put it in the same folder that I have the polargraph-optimiser unzipped into, so it's easy to refer to when I'm running the optimiser. You don't need to copy the optimiser files anywhere. If python is properly installed, you should be able to open a command line in your optimiser folder, and python will be available from there, so you can run as specified in the wiki.

good luck!
sn

kongorilla
Pro
Posts: 386
Permalink
kongorilla
Post Re: Polargraph Optimiser
on: July 12, 2015, 09:05
Quote

IIRC, installing Python 2.7 for Windows doesn't automatically create the environment variable necessary to run scripts from everywhere (at least it didn't back when I installed it).
For help with that, see:
http://www.pythoncentral.io/add-python-to-path-python-is-not-recognized-as-an-internal-or-external-command/

yasirhawk
Newbie
Posts: 19
Permalink
Post Re: Polargraph Optimiser
on: March 12, 2020, 15:14
Quote

i have issue with vector optimizer technique using python....
how to resolve it or enter it correctly?

C:\Python27>python process.py map.text > map1.text
Traceback (most recent call last):
File "process.py", line 11, in <module>
for line in fileinput.input():
File "C:\Python27\lib\fileinput.py", line 254, in next
line = self.readline()
File "C:\Python27\lib\fileinput.py", line 348, in readline
self._file = open(self._filename, self._mode)
IOError: [Errno 2] No such file or directory: 'map.text'

sandy
Administrator
Posts: 1427
Permalink
sandy
Post Re: Polargraph Optimiser
on: March 12, 2020, 18:41
Quote

This just means that it can't find a file there called "map.text". Perhaps it's called something else, like "map.txt"?

sn

yasirhawk
Newbie
Posts: 19
Permalink
Post Re: Polargraph Optimiser
on: March 20, 2020, 14:47
Quote

thanks

yasirhawk
Newbie
Posts: 19
Permalink
Post Re: Polargraph Optimiser
on: March 20, 2020, 15:46
Quote

polargrapgh controller

sandy
Administrator
Posts: 1427
Permalink
sandy
Post Re: Polargraph Optimiser
on: March 21, 2020, 12:57
Quote

Hello there, in the Polargraph controller, g-code is considered to be a format of Vector graphic. You import gcode files the same way as you'd import an SVG, that is, you click on "load vector" and browse to the file that has a .g or .gcode file extension.

I tried loading the fragment of g-code that you included and it did indeed load up ("Imported 14 points from 16 lines of code in the file.") and was visible, once I did "move vector" to shift it into the centre of the page.

Remember that vector lines show up inside the cropping "frame" so pull a selection box ("select area") around where you want to have your drawing on the page, then "set frame to area".

I'm puzzled though - how did you generate the polargraph commands in the first place?

Sandy Noble

yasirhawk
Newbie
Posts: 19
Permalink
Post Re: Polargraph Optimiser
on: March 21, 2020, 14:18
Quote

.

yasirhawk
Newbie
Posts: 19
Permalink
Post Re: Polargraph Optimiser
on: March 21, 2020, 14:20
Quote

..
[code]

sandy
Administrator
Posts: 1427
Permalink
sandy
Post Re: Polargraph Optimiser
on: March 21, 2020, 15:32
Quote

I snipped the g-code a little so the page was not too long 🙂 Thanks for the other pictures too - helpful.

I loaded that g-code fine into polargraphcontroller ("Imported 48240 points from 48364 lines of code in the file.").

Image

I did
1. click "Load vector", and choose the gcode file I'd saved from your post (that imported the gcode)
2. click "Move vector" and move the mouse into my page. This shows a kind of outline, or sparse version of the artwork.
3. click in the place where I want the artwork. This drops the artwork, and a big red spot which indicates where the "handle" is for this piece of vector art. That's a bit random!
4. click and drag "resize vector" to get the size right for the page.

You can see it here https://youtu.be/7Xw_Zo5fmNk

You cannot load G-Code directly into the queue, it always must be loaded as a vector file first.

I am using the polargraph controller code that is current in github. Note this is not the same as any code that is supplied in a bundle, but _don't believe_ there are any significant changes since the version you have.

sn

yasirhawk
Newbie
Posts: 19
Permalink
Post Re: Polargraph Optimiser
on: March 21, 2020, 15:45
Quote

thanks,,, perfect..... 🙂

Pages: [1] 2
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.055 seconds.