OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   New product ideas (http://forum.oberonplace.com/forumdisplay.php?f=15)
-   -   CAD/CAM cutter tool paths in Corel Draw (http://forum.oberonplace.com/showthread.php?t=7057)

cncrouter 10-07-2010 23:35

CAD/CAM cutter tool paths in Corel Draw
 
I'm not a sign maker, but I carve out text and silhouettes in metal using a cnc milling machine. Same concept as routing out a wood sign on a cnc router table, just a much smaller scale.

I create the tool cutter paths for my cnc milling machine with the Corel Draw inside Offset Contour function. So, if I’m milling out a rectangle pocket, I create a series of inside contours which the rotary cutter will follow.

The problem with this approach to creating tool paths is that each inside contour is an "island" not connected to the others, and so the tool must rise when finished with one contour, move to the next contour, drop back down to cutting height, and continue cutting the new contour.

These unwanted up-down moves take up 20% of the total run time. More importantly, each time the cutter moves down (plunge cutting) the probability of the cutter breaking goes way up (my engraving cutter is only 0.012” in diameter, equivalent to about four human hairs).

CAD/CAM programs designed for this type of application can generate a spiral tool path within a closed polygon and the tool cuts out the pocket in one continuous path. I would save a lot of time if Corel Draw could generate this type of path. This would be ideal, but not something I would expect a macro to be able to perform.

Another idea is to have a macro that draws connector lines between the inside contours (islands) and the outer path. If a macro could produce those kinds of lines and make the entire group a single polygon, the cutter could remain engaged in the work and save time while also reducing broken cutters. The connector lines would cause a very small amount of redundant cutting, but that’s a minor disadvantage.

Does anyone have any ideas for producing continuous cutter paths using Corel Draw?

shelbym 11-07-2010 00:33

Cutting Path
 
If you could include an example .cdr file of the cutting paths you wish to generate I am sure we could take a look and let you know if it is possible or not.

-Shelby

cncrouter 11-07-2010 01:37

1 Attachment(s)
Thanks - I have attached a CDR file with examples.

There are probably several possible solutions, but the attached examples should explain the desired outcome.

runflacruiser 11-07-2010 07:47

1 Attachment(s)
Hi Ed.

Here's what I have so far. I'm not sure if it's what you're looking for.
It takes 2 combines items and connects the inner path to the outer.

Code:

Option Explicit

Sub connectSegments()
    Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
    Dim sh1 As Shape, sh2 As Shape
    Dim n1 As Node
    Dim connLine As Shape
    Dim sr As ShapeRange
    Dim sp As SubPath, shTemp As Shape
    Dim lineLen As Double, marker As Double
   
    Dim xt As Double
   
    Dim closeX As Double, closeY As Double
   
    Set sr = ActiveSelectionRange
   
    If (sr(1).SizeHeight * sr(1).SizeWidth) > (sr(2).SizeHeight * sr(2).SizeWidth) Then
        Set sh1 = sr(1)
        Set sh2 = sr(2)
    Else
        Set sh1 = sr(2)
        Set sh2 = sr(1)
    End If
   
    sh1.Fill.ApplyUniformFill CreateCMYKColor(0, 0, 100, 0)
    sh2.Fill.ApplyNoFill
    sh1.Outline.Width = 0.003
    sh2.Outline.Width = 0.003
    'sh1 is large shape
    'sh2 is inside shape
   
    Dim sr1 As ShapeRange
    Set sr1 = sh1.BreakApartEx
   
    For Each sp In sh2.Curve.SubPaths
        sp.Nodes(1).GetPosition x1, y1
        Set shTemp = ActivePage.SelectShapesAtPoint(x1, y1, False)

        'get closest x value
        marker = 1000 'marker starting point for less and less distance value
        For Each n1 In shTemp.Shapes(1).Curve.Nodes
            lineLen = n1.GetDistanceFrom(sp.Nodes(1))
            If lineLen < marker Then
                n1.GetPosition x2, y2
                marker = lineLen
            End If

        Next n1

        Set connLine = ActiveLayer.CreateLineSegment(x1, y1, x2, y2)
    Next sp

    sr1.CreateSelection
    ActiveSelection.Fill.ApplyNoFill
    ActiveSelection.Combine
           
End Sub

Select all and run.
Use this attached cdr to do initial test.

-John

cncrouter 11-07-2010 14:10

John - Thanks for providing the macro!

Visually, it works great :)

However, to see the path and direction the cutter will take, double-click to reveal the nodes, then tab though the nodes.

The path to the inside contours is not via the connection line added by the macro. Instead, the cutter still "hops" across the gap.

It looks like some intelligent re-ordering of the lines & nodes are needed so that the inside contour is cut, then exits via the connection line, and continues to cut the outside contour.

Is this possible? If so, this would be a great solution!

Ed

runflacruiser 12-07-2010 21:35

Hi.
After trying a straight forward approach it proved really difficult.
Try this workaround method and see if it works for you.

-John

Code:

Option Explicit

Sub connectSegments()
    Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
    Dim sh1 As Shape, sh2 As Shape
    Dim n1 As Node
    Dim connLine As Shape
    Dim sr As ShapeRange
    Dim sp As SubPath, shTemp As Shape
    Dim lineLen As Double, marker As Double
    Dim mainSh As Shape
    Dim e As Effect, connLines As Shape
    Dim contSh As Shape, contShSr As ShapeRange
    Dim sr1 As ShapeRange, targSh As Shape
   
    On Error Resume Next
   
   
    Set sr = ActiveSelectionRange
   
    If (sr(1).SizeHeight * sr(1).SizeWidth) > (sr(2).SizeHeight * sr(2).SizeWidth) Then
        Set sh1 = sr(1)
        Set sh2 = sr(2)
    Else
        Set sh1 = sr(2)
        Set sh2 = sr(1)
    End If
   
    sh1.Fill.ApplyUniformFill CreateCMYKColor(0, 0, 100, 0)
    sh2.Fill.ApplyNoFill
    sh1.Outline.Width = 0.003
    sh2.Outline.Width = 0.003
    'sh1 is large shape 'sh2 is inside shape
   
    Set sr1 = sh1.BreakApartEx

    For Each sp In sh2.Curve.SubPaths
        If sp Is Nothing Then GoTo 1001
        Dim origNode As Node
        Set origNode = sp.Nodes(1)
        origNode.GetPosition x1, y1
        Set shTemp = ActivePage.SelectShapesAtPoint(x1, y1, False)

        'get closest x value
        marker = 1000 'marker starting point for less and less distance value
        For Each n1 In shTemp.Shapes(1).Curve.Nodes
            lineLen = n1.GetDistanceFrom(sp.Nodes(1))
            If lineLen < marker Then
                n1.GetPosition x2, y2
                marker = lineLen
            End If

        Next n1
       
       
        Set targSh = shTemp.Shapes(1)

        Set connLine = ActiveLayer.CreateLineSegment(x1, y1, x2, y2)
        connLine.Name = "connLine"
       
1001:
    Next sp

    sr1.CreateSelection
    sh2.AddToSelection
    ActiveSelection.Fill.ApplyNoFill
    ActiveSelection.Combine
   
    Set mainSh = ActiveShape
    Set connLines = ActivePage.FindShapes("connLine").Combine
    Set e = connLines.CreateContour(cdrContourOutside, 0.001, 1)
    Set contShSr = e.Separate()
    Set contSh = contShSr(1)
    contSh.Trim mainSh, True, True
    mainSh.Delete: contSh.Delete: connLines.Delete
   
           
End Sub


cncrouter 13-07-2010 12:23

1 Attachment(s)
Hi John - That's pretty close! I'm amazed at what you've done in a short macro.

It works well on simple objects (see attached cdr).

The top object with straight lines works great.

The middle drawing was a combination of two closed polygons (this is how it appears after I trace the bitmap original). The node sequence jumps from one to the other where I have the red arrows.

For the bottom drawing, I broke apart the two closed polygons, performed an inside contour on each, and ran the macro on each one individually. This works except for the area in the red circle.

I test the node (cutting) sequence by double-clicking to show the nodes, then tab through them to visualize how the cutter will travel.

Ed

runflacruiser 13-07-2010 12:49

Hi.
I think this little node reorder sub will fix any jumping nodes in all selected subpaths but I'm not sure about the problem with the bottom drawing. Can you explain what's wrong with it?


Code:

Sub nodeOrder()

Dim n As Node, s As Shape, sp As SubPath
Dim sr As ShapeRange

Set sr = ActiveSelectionRange

For Each s In sr
    If s.Type = cdrCurveShape Then
        For Each sp In s.Curve.SubPaths
            For Each n In sp.Nodes
                n.CreateSelection
            Next n
        Next sp
    End If
Next s

End Sub

-John

jemmyell 13-07-2010 16:05

DragonCNC
 
Hi,

I have been working on a CorelDRAW hosted CAD / CAM application for some time. It is currently a free beta. My latest product, the Artwork Optimizer is actually a DragonCNC wizard. Have at look at:

http://www.DragonCNC.com

Then let me know what you think. It is a licensed product, but beta licenses are free. BTW, it has the only fully automatic multi-tool pocketing toolpath generator in a product that costs less than $10,000.

-James Leonard

cncrouter 13-07-2010 17:13

John - On the bottom drawing, one of the nodes in the red circle jumps to a node on the upper left of the drawing.

However, after breaking the curves apart and running your nodeOrder macro, it works perfectly.

I'll perform more testing and if all works well I'll integrate this into my artwork preparation workflow for cutting.

Thanks again!

Ed


All times are GMT -5. The time now is 22:19.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com