You cannot switch incremental/absolute on the machines? What about just coverting your NC code, keep track of your position line for line and output the diffs?
I thought of doing that. I'm working on a post processor actually. But, for older programs that don't have a cad model for the software.
the only way I have to program the machine is by manually coding it. so, to speed that process up - I want to reverse the program into a 2d sketch that I can then move origins and pull coordinates to program the other machine.
and, in the end - it keeps me using VB so I don't lose what I know by not doing it frequently.
don't you have a drawing? you had to have something to use for creating the path.
I don't know what cnc router is, but if I understand your question, you want to translate list of relative coordinates to absolute?
Imports System.Windows.Media.Media3D ' add reference to PresentationCore.dll
Imports System.Windows ' add reference to WindowsBase.dll
Dim points As New List(Of Point)
points.Add(New Point(0, 0))
points.Add(New Point(1, 0))
points.Add(New Point(0, 1))
points.Add(New Point(1, -1))
points.Add(New Point(0, 1))
Dim vector1 As New Vector(points(0).X, points(0).Y)
For i = 1 To points.Count - 1
Dim pointResult As Point = Vector.Add(vector1, points(i))
vector1 = New Vector(pointResult.X, pointResult.Y)
' or 3D
Dim points3D As New List(Of Point3D)
points3D.Add(New Point3D(0, 0, 0))
points3D.Add(New Point3D(1, 0, 0))
points3D.Add(New Point3D(0, 1, 0))
points3D.Add(New Point3D(1, -1, 0))
points3D.Add(New Point3D(0, 1, 0))
Dim vector3D As New Vector3D(points3D(0).X, points3D(0).Y, points3D(0).Z)
For i = 1 To points3D.Count - 1
Dim pointResult As Point3D = vector3D.Add(vector3D, points3D(i))
vector3D = New Vector3D(pointResult.X, pointResult.Y, pointResult.Z)
CNC router is the same as a CNC millimg machine, just not as much Z hight travel and more spindle RPM, used mostly for wood, plastic and thin aluminum.
here is the code as you might get from the CNC control or a CAM software. G2 and G3 are arcs and the I,J and K have to do with the arc center and end of the arc , X and Y is where the arc is starting from.
(MACHINE: HAASVF W TOOL DESCRIPTIONS.M3 MPOST Library)
G17 G40 G80 G90
(BRAKE ARM COVERAAE.NCC 12/1/2012)
( , , )
T1 M6 (Tool # 1: .5 Endmill )
G0 X-6.4348 Y0.4581
G1 Z-0.6 F30.0000
G3 X-5.9093 Y0.5288 I0.2274 J0.2982
G1 X-5.8416 Y0.6174 F60.0000
G3 X2.5033 Y0.8166 I0.0461 J0.4979
G1 X4.4096 Y1.4173
G2 X5.1264 Y-0.8575 I0.3584 J-1.1374
G1 X3.6023 Y-1.3377
G2 X2.5699 Y-1.4682 I-0.8756 J2.7788
X1.3208 Y-1.2582 I0.303 J5.6223
G3 X-3.4455 Y-0.3204 I-7.8869 J-27.5034
G2 X-3.9628 Y-0.2388 I0.6062 J5.5252
G1 X-5.761 Y0.1323
G2 X-5.9093 Y0.5288 I0.0505 J0.2448
G3 X-5.98 Y1.0544 I-0.2982 J0.2275 F30.0000
G0 G91 G28 Z0
G0 G49 G90 M9
Holy Sh#@! Spot on!!!!
was it using the code you showed above or did you do some mods to it?
Ivana, I will give it a try and mark correct when I get a chance...
I'm not too familiar with loading modules, is there any specifics steps I need to do to do this?
1. create new vb.net console application
2. add references to
C:\Program Files\SolidWorks Corp\SolidWorks\api\redist\SolidWorks.Interop.sldworks.dll and
C:\Program Files\SolidWorks Corp\SolidWorks\api\redist\SolidWorks.Interop.swconst.dll
3. copy and paste text to module1.vb
ok, got the references - created the text file --
ran the debugger from visual studio -
get a console window with a blinking cursor .... nothing is happening.
what next -?
have you changed textFileName to your cnc file?
Const textFileName As String = "C:\temp\cnc.txt"
yes, I think it's the line numbering in the file...possibly?
yes, you are right
can you parse by finding the g, value x and y and z?
and then, also - if it's a g0 move, can that be a construction line as opposed to solid?
so that only the g1, g2, g3 moves are solid?
1 person found this helpful
yes I can modify it, but not now, later in the evening.
awesome - thank you!
the "N" and numbers are just line numbers generated by our post processor...
the "/" for slash is an optional line - that with a parameter on the machine those lines will either process or be ignored.
anything in () is a comment and can be ignored as well.
anything G4with an F value - is a dwell time or a 'pause' which for this project is also ignored.
again- thanks for your help.
Here is the text of my original CNC file.
N0010 (WI 187832-03 .75" BIT & .375" BIT)
N0100 G=0 M90
N0120 G52 G0 Z0
N0130 M3 M64
N0160 (TOOL IDENTIFIER: .75 TL1)
N0170 (Start Region 1)
N0240 T1 M32
N0300 M23 S12000
N0330 G00 X84.7 Y5.45
N0360 Z-1.7 F150
/N0370 (Activates the Floating head)
/N0380 (E82300=2.4773-.015*25400 L19=1)
/N0385 (G77 H9050)
N0395 G1 Y1.5 F300 (CUT OFF END)
N0396 G00 Z1.0
N0397 X59.11 Y5.35 (ROUT OUTSIDE PATH)
N0398 G1 Z-.3875 F150
N0400 G1 Y4.93 F300
N0410 G1 X84.3
N0440 G2X1.25 Y11.65 Z-.92 R93.48
N0560 G00 Z2.0
N0570 O=0 L=0 G=0 T=0 G80
N0580 G52 Z0
N0620 (TOOL IDENTIFIER: .375 TL6)
N0650 T6 M32
N0710 M23 S13200
N0735 G00 X59.11 Y5.15
N0740 G00 Z1.0
N0770 Z-.3875 F150
/N0780 (Activates the Floating head)
/N0790 (E82300=2.5628-.04*25400 L19=1)
/N0800 (G77 H9050)
N0820 Y4.76 F300
N0850 G01 Z-1.7 F100 (FIRST HOLE)
N0860 G02 X45.79 Y4.76 R.93 F150
N0870 G02 X47.66 Y4.76 R.93
N0880 G00 Z1.0 F100
N0890 G00 X45.79 Y4.76
N0900 G01 Z-.3875 F150
N0905 X42.2 F300
N0906 G02 X18.65 7.86 Z-.5675 R89
N0907 G01 Z-1.7 F100 (SECOND HOLE)
N0910 G02 X16.85 Y8.35 R.93 F150
N0920 G02 X18.65 Y7.86 R.93
N0930 G00 Z1.0 F100
/N1080 (G77 H9051)
O=0 L=0 G=0 T=0 G80
N1100 G=0 M90
N1110 G0 G52 Z0
N1140 M80 M29
N1150 G00 X100
/N1160 G79 N0010
N1180 End of part program
Close - I will attempt to attach a jpeg showing what it should look like. The solid lines are the toolpath. The hidden are my references of the part dimensions.
it starts by entering the upper left corner of the short leg on the right... moving to the right, then down, then left following the arc out to the end.
lifts up does a tool change then comes back in at start point, and proceeds left, to first circle, cuts it, then arcs to the next hole, and cuts it.
end of program.
any chance you got to look at modifying the code?
I'm not familiar with the solidworks classes ....I know some of the basic windows functions, can open a text file, etc. but when it comes to "commanding" solidworks -
that's where my experience comes to a screeching halt.
Troy, yes, I can modify it, but in worst case scenario, you will have to wait till weekend.
Thank you - I will take a look at this. I was stepping through the code yesterday - and I'm starting to understand what it does and how -
I am just not that familiar with the solidworks API to know what I need to make the sketches, and the references.
now that I have your example - and this code project example - I think I can come up with something.
I may ask questions along the way - if you don't mind.
thank you for the help -