Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
drl2gcode
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
drl2gcode
Commits
c5d9584f
Commit
c5d9584f
authored
May 09, 2018
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First import
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
drl2gcode.py
drl2gcode.py
+84
-0
No files found.
drl2gcode.py
0 → 100755
View file @
c5d9584f
#!/usr/bin/env python
SPINDLE_SPEED
=
32000
XY_MOVE_SPEED
=
3000
Z_MOVE_SPEED
=
300
DRILL_MOVE_SPEED
=
100
DRILL_DEPT
=
2
SAFE_HEIGHT
=
25
RUNNING_HEIGHT
=
10
TOOL_HEIGHT
=
40
import
sys
header
=
"""; Produced by drl2gcode.py
; make sure machine is in CNC mode
M453
; select absolute coordinate system
M82
; metric
G21
; G61 exact path mode was requested but not implemented
; start spindle
M3 S"""
+
str
(
SPINDLE_SPEED
)
+
"""
; wait for 3 seconds
G04 S3
"""
footer
=
"""
; stop spindle
M5
; go to safe height
G0 Z"""
+
str
(
TOOL_HEIGHT
)
+
""" F30000
; unlock all steppers
;M18
; program ends
M2
"""
tools
=
{}
tsel
=
"1"
with
open
(
sys
.
argv
[
1
])
as
fp
:
line
=
fp
.
readline
()
while
line
:
line
=
fp
.
readline
()
if
line
.
startswith
(
"T"
)
and
"C"
in
line
:
tnum
=
line
.
split
(
"C"
)[
0
][
1
:]
diameter
=
"{:.2f}"
.
format
(
float
(
line
.
split
(
"C"
)[
1
]))
tools
[
tnum
]
=
{
"diameter"
:
diameter
,
"file"
:
""
.
join
([
sys
.
argv
[
1
][:
-
4
],
"_T"
,
tnum
.
rjust
(
2
,
"0"
),
"_"
,
diameter
,
"mm"
,
".gcode"
]),
"output"
:
""
.
join
([
header
,
"
\n\n
; T"
,
tnum
,
" Diameter: "
,
diameter
,
"mm"
,
"
\n
"
]),
"first"
:
True
}
elif
line
.
startswith
(
"T"
):
tsel
=
line
[
1
:]
.
rstrip
(
"
\r\n
"
)
elif
line
.
startswith
(
"X"
)
and
tsel
!=
"0"
:
if
tools
[
tsel
][
"first"
]:
newl1
=
""
.
join
([
"G0 F"
,
str
(
Z_MOVE_SPEED
),
" Z"
,
str
(
SAFE_HEIGHT
)])
tools
[
tsel
][
"first"
]
=
False
else
:
newl1
=
""
.
join
([
"G1 F"
,
str
(
Z_MOVE_SPEED
),
" Z"
,
str
(
RUNNING_HEIGHT
)])
if
tools
[
tsel
][
"output"
]
.
endswith
(
newl1
+
"
\n
"
):
newl1
=
''
newl2
=
""
.
join
([
"G1 F"
,
str
(
XY_MOVE_SPEED
),
" "
,
line
.
split
(
"Y"
)[
0
],
" Y"
,
line
.
split
(
"Y"
)[
1
]
.
strip
(
"
\r\n
"
)])
newl3
=
""
.
join
([
"G1 F"
,
str
(
Z_MOVE_SPEED
),
" Z0.2"
])
newl4
=
""
.
join
([
"G1 F"
,
str
(
DRILL_MOVE_SPEED
),
" Z-"
,
str
(
DRILL_DEPT
)])
newl5
=
""
.
join
([
"G1 F"
,
str
(
Z_MOVE_SPEED
),
" Z"
,
str
(
RUNNING_HEIGHT
)])
tools
[
tsel
][
"output"
]
+=
"
\n
"
.
join
([
newl1
,
newl2
,
newl3
,
newl4
,
newl5
,
''
])
for
t
in
tools
:
tools
[
t
][
"output"
]
+=
footer
print
"writing"
,
tools
[
t
][
"file"
]
f
=
open
(
tools
[
t
][
"file"
],
"w"
)
f
.
write
(
tools
[
t
][
"output"
])
f
.
close
()
#print tools[t]["file"]
#print tools[t]["output"]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment