Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
607c4c04
Commit
607c4c04
authored
Jul 25, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly handle G28 and G92 in gcoder (oof!)
parent
9fd7a9e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
8 deletions
+28
-8
gcoder.py
printrun/gcoder.py
+28
-8
No files found.
printrun/gcoder.py
View file @
607c4c04
...
@@ -86,7 +86,8 @@ class Layer(list):
...
@@ -86,7 +86,8 @@ class Layer(list):
super
(
Layer
,
self
)
.
__init__
(
lines
)
super
(
Layer
,
self
)
.
__init__
(
lines
)
self
.
z
=
z
self
.
z
=
z
def
_preprocess
(
self
,
current_x
,
current_y
,
current_z
):
def
_preprocess
(
self
,
current_x
,
current_y
,
current_z
,
offset_x
,
offset_y
,
offset_z
):
xmin
=
float
(
"inf"
)
xmin
=
float
(
"inf"
)
ymin
=
float
(
"inf"
)
ymin
=
float
(
"inf"
)
zmin
=
0
zmin
=
0
...
@@ -95,7 +96,7 @@ class Layer(list):
...
@@ -95,7 +96,7 @@ class Layer(list):
zmax
=
float
(
"-inf"
)
zmax
=
float
(
"-inf"
)
for
line
in
self
:
for
line
in
self
:
if
not
line
.
is_move
and
line
.
command
!=
"G92"
:
if
not
line
.
is_move
and
line
.
command
!=
"G92"
and
line
.
command
!=
"G28"
:
continue
continue
if
line
.
is_move
:
if
line
.
is_move
:
x
=
line
.
x
x
=
line
.
x
...
@@ -106,6 +107,10 @@ class Layer(list):
...
@@ -106,6 +107,10 @@ class Layer(list):
x
=
current_x
+
(
x
or
0
)
x
=
current_x
+
(
x
or
0
)
y
=
current_y
+
(
y
or
0
)
y
=
current_y
+
(
y
or
0
)
z
=
current_z
+
(
z
or
0
)
z
=
current_z
+
(
z
or
0
)
else
:
if
line
.
x
:
x
=
line
.
x
+
offset_x
if
line
.
y
:
y
=
line
.
y
+
offset_y
if
line
.
z
:
z
=
line
.
z
+
offset_z
current_x
=
x
or
current_x
current_x
=
x
or
current_x
current_y
=
y
or
current_y
current_y
=
y
or
current_y
...
@@ -122,15 +127,24 @@ class Layer(list):
...
@@ -122,15 +127,24 @@ class Layer(list):
zmin
=
min
(
zmin
,
current_z
)
zmin
=
min
(
zmin
,
current_z
)
zmax
=
max
(
zmax
,
current_z
)
zmax
=
max
(
zmax
,
current_z
)
else
:
elif
line
.
command
==
"G28"
:
current_x
=
line
.
x
or
current_x
if
not
any
([
line
.
x
,
line
.
y
,
line
.
z
]):
current_y
=
line
.
y
or
current_y
current_x
=
current_y
=
current_z
=
0
current_z
=
line
.
z
or
current_z
else
:
if
line
.
x
:
current_x
=
0
if
line
.
y
:
current_y
=
0
if
line
.
z
:
current_z
=
0
elif
line
.
command
==
"G92"
:
if
line
.
x
:
offset_x
+=
current_x
-
line
.
x
if
line
.
y
:
offset_y
+=
current_y
-
line
.
y
if
line
.
z
:
offset_z
+=
current_z
-
line
.
z
line
.
current_x
=
current_x
line
.
current_x
=
current_x
line
.
current_y
=
current_y
line
.
current_y
=
current_y
line
.
current_z
=
current_z
line
.
current_z
=
current_z
return
((
current_x
,
current_y
,
current_z
),
return
((
current_x
,
current_y
,
current_z
),
(
offset_x
,
offset_y
,
offset_z
),
(
xmin
,
xmax
),
(
ymin
,
ymax
),
(
zmin
,
zmax
))
(
xmin
,
xmax
),
(
ymin
,
ymax
),
(
zmin
,
zmax
))
class
GCode
(
object
):
class
GCode
(
object
):
...
@@ -356,10 +370,16 @@ class GCode(object):
...
@@ -356,10 +370,16 @@ class GCode(object):
current_x
=
0
current_x
=
0
current_y
=
0
current_y
=
0
current_z
=
0
current_z
=
0
offset_x
=
0
offset_y
=
0
offset_z
=
0
for
l
in
self
.
all_layers
:
for
l
in
self
.
all_layers
:
(
current_x
,
current_y
,
current_z
),
(
xm
,
xM
),
(
ym
,
yM
),
(
zm
,
zM
)
=
\
meta
=
l
.
_preprocess
(
current_x
,
current_y
,
current_z
,
l
.
_preprocess
(
current_x
,
current_y
,
current_z
)
offset_x
,
offset_y
,
offset_z
)
current_x
,
current_y
,
current_z
=
meta
[
0
]
offset_x
,
offset_y
,
offset_z
=
meta
[
1
]
(
xm
,
xM
),
(
ym
,
yM
),
(
zm
,
zM
)
=
meta
[
2
:]
xmin
=
min
(
xm
,
xmin
)
xmin
=
min
(
xm
,
xmin
)
xmax
=
max
(
xM
,
xmax
)
xmax
=
max
(
xM
,
xmax
)
ymin
=
min
(
ym
,
ymin
)
ymin
=
min
(
ym
,
ymin
)
...
...
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