Code:
Sub import_Click()
CommonDialog1.Filter = "EPS (Lines Only)|*.EPS"
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
If FileName = "" Then Exit Sub
Open CommonDialog1.FileName For Input As #1
temp = ""
startsave = 0
While Not EOF(1)
Line Input #1, lot
lot = Trim(lot)
If lot = "%%EOF" Then startsave = 3
If startsave = 2 Then
linetype = Right(lot, 1)
If Len(lot) > 2 Then lot = Left(lot, Len(lot) - 2)
'******* move
If LCase(linetype) = "m" Then
epstype(x) = "m"
cutcur(numcuts, 0) = x
If x > 0 Then cutcur(numcuts - 1, 1) = x - 1
epsname(numcuts) = "Task #" + Str(numcuts)
numcuts = numcuts + 1
eps(x, 0) = Left(lot, InStr(lot, " ") - 1)
eps(x, 1) = Right(lot, Len(lot) - InStr(lot, " "))
mainx = eps(x, 0)
mainy = eps(x, 1)
x = x + 1
End If
'******* line
If LCase(linetype) = "l" Then
epstype(x) = "l"
eps(x, 0) = mainx + Val(Left(lot, InStr(lot, " ") - 1))
eps(x, 1) = mainy + Val(Right(lot, Len(lot) - InStr(lot, " ")))
mainx = eps(x, 0)
mainy = eps(x, 1)
x = x + 1
End If
'******* Curve
If LCase(linetype) = "c" Then
x1 = mainx
y1 = mainy
x2 = mainx + Val(Left(lot, InStr(lot, " ") - 1))
lot = Right(lot, Len(lot) - InStr(lot, " "))
y2 = mainy + Val(Left(lot, InStr(lot, " ") - 1))
lot = Right(lot, Len(lot) - InStr(lot, " "))
x3 = mainx + Val(Left(lot, InStr(lot, " ") - 1))
lot = Right(lot, Len(lot) - InStr(lot, " "))
y3 = mainy + Val(Left(lot, InStr(lot, " ") - 1))
lot = Right(lot, Len(lot) - InStr(lot, " "))
x4 = mainx + Val(Left(lot, InStr(lot, " ") - 1))
lot = Right(lot, Len(lot) - InStr(lot, " "))
y4 = mainy + Val(lot)
For per = 0.2 To 1 Step 0.2:'This will break the curve down into steps of .2 - or 5 segments. This was done for speed and should probably be more like .02 for a smoother curve.
epstype(x) = "l"
eps(x, 0) = xsp(xsp(xsp(x1, x2, per), xsp(x2, x3, per), per), xsp(xsp(x2, x3, per), xsp(x3, x4, per), per), per)
eps(x, 1) = ysp(ysp(ysp(y1, y2, per), ysp(y2, y3, per), per), ysp(ysp(y2, y3, per), ysp(y3, y4, per), per), per)
mainx = eps(x, 0)
mainy = eps(x, 1)
x = x + 1
Next
epstype(x) = "l"
eps(x, 0) = x4
eps(x, 1) = y4
mainx = eps(x, 0)
mainy = eps(x, 1)
x = x + 1
End If
End If
If lot = "%%EndSetup" Then startsave = 1
If lot = "IP" And startsave = 1 Then startsave = 2
Wend
If x > 0 Then cutcur(numcuts - 1, 1) = x - 1
x = x - 1
Close #1
End Sub