LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-30-2010, 05:44 PM   #1
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Rep: Reputation: 21
need to calculate the blade offset in python


I'm using pyqt3 for my app and am lost on even how to attempt this task...
On a vinyl cutter to have the blade pivot it must be offset from the center of the shaft it's on so say for example a .25mm offset would leave a .25mm unwanted vinyl attachment when the cutting is done. I somehow have to average or extrapolate that .25mm xy coordinate and add it to the hpgl plot file as a PUx,y; command? I have enclosed a simple sample file that has three images in it. In the corresponding hpgl file everything between the PU commands that are starting with PD are the code for that image (star for eg the pu to move to next image and then all PD for the next image and so on, so once the formula or procedure is figured out it can be applied to as many images there are in the file. Placing the new command at the head of each image PD group. Since there are absolute and relative cutters I enclosed the same exact plot for both types as the coordinates on relative can be negative numbers. Only PU and PD commands and a ";" as a command delimiter as sometimes many commands are on one line.

The offset variable will come from a spinbox but .25 is good for an example.

This has been bugging me for months now and any advice or help free or paid would be welcome!

Thanks in advance
Attached Files
File Type: txt hpgl-absolute.plt.txt (1.9 KB, 25 views)
File Type: txt hpgl-relative.plt.txt (1.8 KB, 21 views)
File Type: txt drawing.svg.txt (2.8 KB, 20 views)
 
Old 12-30-2010, 06:17 PM   #2
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
forgot

Forgot to mention that 40 plotter units = 1 mm and the input file will be a known filename "temp.plot".
 
Old 01-01-2011, 02:31 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
While this is a very interesting and challenging problem, it sounds to me as if it is more of an exercise in plane geometry. Once the general solution has been achieved in terms of the geometry, putting the solution into code will probably be relatively simple. Do you have knowledge of the geometry-specific solution already? If not, then you may be able to find another forum/website specific to the field of math and geometry. I once had a similar requirement, and was able to get help from some very helpful and apparently knowledgeable people. I'm sorry that I cannot recall the name of the site, but I do recall that it seemed easy enough to find.

If I have understood your question correctly, you will have to provide more information about the nature of your cutter. I have a basic understanding of HPGL code, but most people probably do not (background: it was the language used by HP pen plotters, back in the day). You will need to provide more detail about how the knife on your cutter differs from the pen on a plotter. On a pen plotter, the pen nib will draw on the paper at exactly the X-Y coordinates of the expression in the HPGL code. How will this be different from the position of the knife, given the same coordinates? I sense that the matter becomes more complicated, and that there will be some offset that varies, depending on the direction of the vector that the knife is following. If this is true, then this is where I see the basic problem as more of a geometry exercise.

--- rod.
 
Old 01-01-2011, 05:07 PM   #4
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
tool offset

If you do remember that web site I sure would like to take a look! I have been trying to get this solved via exhastive googling for months. HPGL mechanics I do know quite well for most machines that are pure hpgl and company specific hpgl such as roland, graphtec etc. It's implementing it via math/geometry that I'm sadly lacking in skills.

The offset is derived from a variable provided say .25mm for eg. since the blade pivots it's always parallel to the vector it's cutting.

It doesn't have to really exact as I was hoping to get an extrapolation that would be around 80% accurate??
What do you think?

Also the relative (0,0 center) plotter example is to be ignored as that is converted to relative coordinates anyway. So after adding the offset calcs it will be also converted to relative.

Thanks for the reply

Last edited by gary_in_springhill; 01-01-2011 at 05:18 PM. Reason: wrong post
 
Old 01-01-2011, 05:33 PM   #5
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hi, I'm trying to understand the problem. Unfortunately my English is not good enough and furthermore there seem to be several words in the technical language for that subject. I've googled for "pictures" of the technical words, so I seem to understand what machine/plotter you are talking about.

Otherwise I've a relatively good understanding of mathmatics and geometry as well and I would be pleased to help you.

Could you try to explain the problem in a far more less subjectspecific language? I don't know the exact meaning of e.g. shaft, pivot, blade and so on in this context.

Maybe you have a link to Wikipedia or a similar site. Or could you provide a drawing as an example, including the offset you want to calculate?

Markus
 
Old 01-01-2011, 05:48 PM   #6
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
thanks markush

well when cutting vinyl with a knife/blade on a vinyl cutter the blade has to turn/pivot so it is at an angle I need to calculate and add that calculation to my hpgl code so the vinyl object is totally cut out and not leave a little .25mm piece of uncut vinyl at the end of the cut job.

here is a link to a blade http://cgi.ebay.com/New-Set-3-Roland...item4155903ff5
as you can see the tip of the blade is off center from the center of the shaft resulting in a small section of uncut vinyl.

I have attached some open source code that kind of solves it but have no way to adapt it. Look for "def offset"
Attached Files
File Type: txt cam.py.txt (115.9 KB, 28 views)
 
Old 01-01-2011, 06:12 PM   #7
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Well, I got it (i suppose). Let me explain in my words: because the tip of the blade is not exactly under the center of the shaft, there is a different sector of a circle when cutting round and angle. This difference may become major or lesser depending on if the angle goes to the right hand or the left hand side.

This would mean that the blade is always adjusted into the cutting-direction. Which means the offset you're looking for depends on the cutting-direction or the change of the cutting-direction respectively.

I think I'll sleep a night on this, it's 1 o'clock in the morning here in Germany.

Please give me a hint if I understood the challenge correctly (or not ).

Markus
 
Old 01-01-2011, 06:23 PM   #8
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
thats it

Wow you explained that far better than I could
 
Old 01-01-2011, 06:49 PM   #9
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by gary_in_springhill View Post
If you do remember that web site I sure would like to take a look! I have been trying to get this solved via exhastive googling for months.
Okay, I did manage to find it: Math Help Forum. I hope you have as much success there as I did.

As I think about your problem, it seems to me that there will have to be some serious analysis of the image file. If I understand the problem correctly, your blade, and therefore the line it cuts, is always offset from the 'true' line by some fixed amount. Depending on the direction of the cut, the offset will be on either the interior side, or the exterior side of the line (assuming you are cutting 'shapes'). To make the correct adjustment to the file, it will be necessary to determine which side. Just to make things slightly more exciting, the length of some/most/all lines will need to be adjusted, so that the new endpoints are correctly aligned.

Since you seem to be creating your images with an SVG editor, I wonder whether there might be some trickery that you can employ in that tool to get the desired image. Just spitballing, but perhaps some kind of shadow/offset effect can get you what you need.

--- rod.
 
Old 01-02-2011, 03:28 AM   #10
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Mathmatically it reduces to the addition of two vectors. One vector represents the dot in the svg-file and the other vector represents the offset in a way that the offset is the length of the vector and (here the difficult part) the direction depends on the cutting-direction.

In the attachement of post #6 in function "offset" they take three dots p0, p1 and p2, represented by the vectors (x0,y0),(x1,y1),(x2,y2). Then they calculate the offsetvector. I think this is a good startingpoint.

The function can be taken in order to adapt the hpgl-files or the svg-files. Since SVG (Scalable Vector Graphics) deals with vectors anyway, I think that theNnbomr's idea is worth be followed.

Markus
 
1 members found this post helpful.
Old 01-02-2011, 07:41 AM   #11
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
more useful attachment

I have attached a sample hpgl no svg the file will already be converted to hpgl.
Also a very good but complex def that does what I want but mine will read from a complete file as in the attached one. The python def is commented.. It relies on inkscape mods and I'd rather not if possible??

Payment for your services is fine...
Just let me know approx. how much it will cost so I can post my porsche on kijiji
Attached Files
File Type: txt path.py.txt (3.8 KB, 17 views)
File Type: txt temp.plot.txt (25.5 KB, 25 views)
 
Old 01-05-2011, 02:45 PM   #12
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello,

after some time of thinking about your problem it seems that the functions "offset" from the python-program (cam.py) of the attachment in your post #6 is the best solution.

It seems to achieve exactly what you want. The question remains, how one can apply this function to your hpgl-files.

Unfortunately I don't have as much experience with Python, I'm more a Ruby and Perl programmer

My idea is to take the coordinates of your hpgl-files as the arguments for the offset-function. It is to be calculated, how the parameter "r" is to be handled. What I mean is, the parameter r (which is the amount of the offset) has to be calculated in terms of the coordinates of the hpgl-files (coordinates=the points the cutter deals with).

You have mentioned above, that you tried the program cam.py and it was successful, what exactly is the problem which has to be solved additionally.

Markus
 
Old 01-05-2011, 04:38 PM   #13
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
it sort of worked

It worked accurately to about 80% if I can get the basics down I can play around with it a bit. I have a question though if a plot job is being sent through this offset script and it has say 5 separate objects eg" ABCDE" as each letter being an object do the objects have to be processed as a unit or the whole file with all 5 objects get processed?

Would you like to tackle this for a fee?
I need it done asap......

The hpgl file will be always the same name same location.
The variables will come from sliders and spinboxes.

Sample hpgl file enclosed..
each line starting with a PUx,x; is an object as in the letters ABCDE explained above (circles and squares in this case I think).
Attached Files
File Type: txt temp.plot.txt (25.5 KB, 12 views)
 
Old 01-05-2011, 04:41 PM   #14
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
another example

here is another example but uses inkscape python modules which I'd like to avoid if possible.
Attached Files
File Type: txt path.py.txt (3.8 KB, 23 views)
 
Old 01-05-2011, 05:20 PM   #15
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Quote:
Originally Posted by gary_in_springhill View Post
and it has say 5 separate objects eg" ABCDE" as each letter being an object do the objects have to be processed as a unit or the whole file with all 5 objects get processed?
mh, the function offset deals with only three points which are plotted one after an other. And then when the first point is plotted, it adds the following point and the function is used again.

So if I understand your question correctly: the function offset handles just three subsequently plotted points regardless of the objects in the whole plotting-job. The objects are handled as a unit in the sense that the function doesn't see the objects.

The point is: if you have three subsequently plotted points, we look at the direction from p0 to p1 and at the direction from p1 to p2. if they are different (the directions), we have to calculate a new offset since the knife has to cut in a curve.
Quote:
Would you like to tackle this for a fee?
I need it done asap......
so far we don't have a better solution and I cannot promise that this trials will succeed. I'll have to work at it for some hours very intensely, but without any guarantee that it will meet your requirements when it's ready. Question: until when has it to be ready? and what would it be worth to you.

What I can do is to write a function/program, which translates the hpgl-files into new files in a way that every point is substituted with the point plus it's offset.

That was what I read from your first post in this thread. If there are other parameters for the function (from "sliders and spinboxes") as you wrote, I don't yet know how to handle this.

Markus
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
Blade Server?? your_shadow03 Linux - Newbie 2 02-25-2009 05:51 AM
Blade Servers kromberg Linux - Server 1 09-18-2007 01:07 PM
Trident Blade acid_kewpie Linux - General 0 11-08-2001 03:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration