Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laser-gcode-exporter-inkscape-plugin
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
laser-gcode-exporter-inkscape-plugin
Commits
05205f05
Commit
05205f05
authored
May 19, 2016
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add options to set DPI and color swapping
parent
5b05452e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
turnkeylaser.inx
turnkeylaser.inx
+2
-1
turnkeylaser.py
turnkeylaser.py
+9
-4
No files found.
turnkeylaser.inx
View file @
05205f05
...
@@ -54,7 +54,7 @@ For the latest revision please visit https://github.com/TurnkeyTyranny/laser-gco
...
@@ -54,7 +54,7 @@ For the latest revision please visit https://github.com/TurnkeyTyranny/laser-gco
<param
name=
"logging"
type=
"boolean"
_gui-text=
"Log debug output from plugin:"
>
true
</param>
<param
name=
"logging"
type=
"boolean"
_gui-text=
"Log debug output from plugin:"
>
true
</param>
<param
name=
"optimiseraster"
type=
"boolean"
_gui-text=
"Optimise raster horizontal scanning speed:"
>
true
</param>
<param
name=
"optimiseraster"
type=
"boolean"
_gui-text=
"Optimise raster horizontal scanning speed:"
>
true
</param>
<_param
name=
"help"
type=
"description"
>
Will optimise raster paths, may cause slight overburn at the edges of the raster.
</_param>
<_param
name=
"help"
type=
"description"
>
Will optimise raster paths, may cause slight overburn at the edges of the raster.
</_param>
<param
name=
"dpi"
type=
"int"
_gui-text=
"Set exported image DPI"
>
270
</param>
</page>
</page>
<page
name=
'tab'
_gui-text=
'Preferences'
>
<page
name=
'tab'
_gui-text=
'Preferences'
>
...
@@ -81,6 +81,7 @@ For the latest revision please visit https://github.com/TurnkeyTyranny/laser-gco
...
@@ -81,6 +81,7 @@ For the latest revision please visit https://github.com/TurnkeyTyranny/laser-gco
<item
value=
"mm"
>
mm
</item>
<item
value=
"mm"
>
mm
</item>
<item
value=
"in"
>
in
</item>
<item
value=
"in"
>
in
</item>
</param>
</param>
<param
name=
"invert"
type=
"boolean"
_gui-text=
"Swap colors"
>
true
</param>
<param
name=
"dither"
type=
"boolean"
_gui-text=
"Apply dithering"
>
false
</param>
<param
name=
"dither"
type=
"boolean"
_gui-text=
"Apply dithering"
>
false
</param>
<param
name=
"colorspace"
type=
"int"
_gui-text=
"color space. 0 to reduce derived from power"
>
256
</param>
<param
name=
"colorspace"
type=
"int"
_gui-text=
"color space. 0 to reduce derived from power"
>
256
</param>
<param
name=
"showimg"
type=
"boolean"
_gui-text=
"Show generated raster images"
>
false
</param>
<param
name=
"showimg"
type=
"boolean"
_gui-text=
"Show generated raster images"
>
false
</param>
...
...
turnkeylaser.py
View file @
05205f05
...
@@ -493,6 +493,8 @@ class Gcode_tools(inkex.Effect):
...
@@ -493,6 +493,8 @@ class Gcode_tools(inkex.Effect):
self
.
OptionParser
.
add_option
(
""
,
"--dither"
,
action
=
"store"
,
type
=
"inkbool"
,
dest
=
"dither"
,
default
=
False
,
help
=
"Enable Dithering"
)
self
.
OptionParser
.
add_option
(
""
,
"--dither"
,
action
=
"store"
,
type
=
"inkbool"
,
dest
=
"dither"
,
default
=
False
,
help
=
"Enable Dithering"
)
self
.
OptionParser
.
add_option
(
""
,
"--showimg"
,
action
=
"store"
,
type
=
"inkbool"
,
dest
=
"showimg"
,
default
=
False
,
help
=
"Show rastered images"
)
self
.
OptionParser
.
add_option
(
""
,
"--showimg"
,
action
=
"store"
,
type
=
"inkbool"
,
dest
=
"showimg"
,
default
=
False
,
help
=
"Show rastered images"
)
self
.
OptionParser
.
add_option
(
""
,
"--colorspace"
,
action
=
"store"
,
type
=
"int"
,
dest
=
"colorspace"
,
default
=
"256"
,
help
=
"reduce colorspace"
)
self
.
OptionParser
.
add_option
(
""
,
"--colorspace"
,
action
=
"store"
,
type
=
"int"
,
dest
=
"colorspace"
,
default
=
"256"
,
help
=
"reduce colorspace"
)
self
.
OptionParser
.
add_option
(
""
,
"--dpi"
,
action
=
"store"
,
type
=
"int"
,
dest
=
"dpi"
,
default
=
"270"
,
help
=
"set DPI for inkscape export"
)
self
.
OptionParser
.
add_option
(
""
,
"--invert"
,
action
=
"store"
,
type
=
"inkbool"
,
dest
=
"invert"
,
default
=
True
,
help
=
"swap to negative colors"
)
def
parse_curve
(
self
,
path
):
def
parse_curve
(
self
,
path
):
# if self.options.Xscale!=self.options.Yscale:
# if self.options.Xscale!=self.options.Yscale:
...
@@ -657,8 +659,9 @@ class Gcode_tools(inkex.Effect):
...
@@ -657,8 +659,9 @@ class Gcode_tools(inkex.Effect):
#Rasters are exported internally at 270dpi.
#Rasters are exported internally at 270dpi.
#So R = 1 / (270 / 25.4)
#So R = 1 / (270 / 25.4)
# = 0.09406
# = 0.09406
mmperpix
=
round
(
1
/
(
self
.
option
.
dpi
/
25.4
),
5
)
gcode
+=
'
\n\n
;Beginning of Raster Image '
+
str
(
curve
[
'id'
])
+
' pixel size: '
+
str
(
curve
[
'width'
])
+
'x'
+
str
(
curve
[
'height'
])
+
'
\n
'
gcode
+=
'
\n\n
;Beginning of Raster Image '
+
str
(
curve
[
'id'
])
+
' pixel size: '
+
str
(
curve
[
'width'
])
+
'x'
+
str
(
curve
[
'height'
])
+
'
\n
'
gcode
+=
'M649 S'
+
str
(
laserPower
)
+
' B2 D0 R
0.09406
\n
'
gcode
+=
'M649 S'
+
str
(
laserPower
)
+
' B2 D0 R
'
+
str
(
mmperpix
)
+
'
\n
'
#Do not remove these two lines, they're important. Will not raster correctly if feedrate is not set prior.
#Do not remove these two lines, they're important. Will not raster correctly if feedrate is not set prior.
#Move fast to point, cut at correct speed.
#Move fast to point, cut at correct speed.
...
@@ -1007,7 +1010,7 @@ class Gcode_tools(inkex.Effect):
...
@@ -1007,7 +1010,7 @@ class Gcode_tools(inkex.Effect):
tmp
=
self
.
getTmpPath
()
#OS tmp directory
tmp
=
self
.
getTmpPath
()
#OS tmp directory
bgcol
=
"#ffffff"
#White
bgcol
=
"#ffffff"
#White
curfile
=
curfile
=
self
.
args
[
-
1
]
#The current inkscape project we're exporting from.
curfile
=
curfile
=
self
.
args
[
-
1
]
#The current inkscape project we're exporting from.
command
=
"inkscape --export-dpi
270 -i
%
s --export-id-only -e
\"
%
stmpinkscapeexport.png
\"
-b
\"
%
s
\"
%
s"
%
(
node
.
get
(
"id"
),
tmp
,
bgcol
,
curfile
)
command
=
"inkscape --export-dpi
%
s -i
%
s --export-id-only -e
\"
%
stmpinkscapeexport.png
\"
-b
\"
%
s
\"
%
s"
%
(
self
.
options
.
dpi
,
node
.
get
(
"id"
),
tmp
,
bgcol
,
curfile
)
p
=
subprocess
.
Popen
(
command
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
p
=
subprocess
.
Popen
(
command
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
return_code
=
p
.
wait
()
return_code
=
p
.
wait
()
...
@@ -1022,6 +1025,7 @@ class Gcode_tools(inkex.Effect):
...
@@ -1022,6 +1025,7 @@ class Gcode_tools(inkex.Effect):
else
:
else
:
img
=
Image
.
open
(
filename
)
.
convert
(
'L'
)
img
=
Image
.
open
(
filename
)
.
convert
(
'L'
)
if
self
.
options
.
invert
:
img
=
ImageOps
.
invert
(
img
)
img
=
ImageOps
.
invert
(
img
)
#Get the image size
#Get the image size
...
@@ -1061,6 +1065,7 @@ class Gcode_tools(inkex.Effect):
...
@@ -1061,6 +1065,7 @@ class Gcode_tools(inkex.Effect):
showim
=
img
.
copy
()
showim
=
img
.
copy
()
if
(
self
.
options
.
origin
==
'topleft'
):
if
(
self
.
options
.
origin
==
'topleft'
):
showim
=
showim
.
transpose
(
Image
.
FLIP_TOP_BOTTOM
)
showim
=
showim
.
transpose
(
Image
.
FLIP_TOP_BOTTOM
)
if
self
.
options
.
invert
:
ImageOps
.
invert
(
showim
)
.
show
()
ImageOps
.
invert
(
showim
)
.
show
()
showim
.
show
()
showim
.
show
()
...
...
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