Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
pyMKcam
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
pyMKcam
Commits
a5e7a4a8
Commit
a5e7a4a8
authored
Jul 19, 2012
by
Lars Kruse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conversion to new pycam.Toolpath.Toolpath interface (moves + filters)
parent
d97a82d9
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
45 deletions
+47
-45
TaskTypes.py
pycam/Plugins/TaskTypes.py
+1
-5
ToolpathCrop.py
pycam/Plugins/ToolpathCrop.py
+2
-2
ToolpathExport.py
pycam/Plugins/ToolpathExport.py
+20
-18
ToolpathGrid.py
pycam/Plugins/ToolpathGrid.py
+1
-2
ToolpathProcessors.py
pycam/Plugins/ToolpathProcessors.py
+19
-14
Toolpaths.py
pycam/Plugins/Toolpaths.py
+4
-4
No files found.
pycam/Plugins/TaskTypes.py
View file @
a5e7a4a8
...
@@ -79,9 +79,5 @@ class TaskTypeMilling(pycam.Plugins.PluginBase):
...
@@ -79,9 +79,5 @@ class TaskTypeMilling(pycam.Plugins.PluginBase):
if
not
moves
:
if
not
moves
:
self
.
log
.
info
(
"No valid moves found"
)
self
.
log
.
info
(
"No valid moves found"
)
return
None
return
None
data
=
{}
return
moves
,
tool_filters
for
item_name
in
(
"process"
,
"bounds"
):
self
.
core
.
call_chain
(
"get_toolpath_information"
,
environment
[
item_name
],
data
)
return
moves
,
data
pycam/Plugins/ToolpathCrop.py
View file @
a5e7a4a8
...
@@ -169,8 +169,8 @@ class ToolpathCrop(pycam.Plugins.PluginBase):
...
@@ -169,8 +169,8 @@ class ToolpathCrop(pycam.Plugins.PluginBase):
new_path
=
toolpath
|
Filters
.
Crop
(
polygons
)
new_path
=
toolpath
|
Filters
.
Crop
(
polygons
)
if
new_path
|
Filters
.
MovesOnly
():
if
new_path
|
Filters
.
MovesOnly
():
if
keep_original
:
if
keep_original
:
self
.
core
.
get
(
"toolpaths"
)
.
add_new
(
(
new_path
,
self
.
core
.
get
(
"toolpaths"
)
.
add_new
(
toolpath
.
get_params
()
))
(
new_path
,
toolpath
.
filters
))
else
:
else
:
toolpath
.
path
=
new_path
toolpath
.
path
=
new_path
self
.
core
.
emit_event
(
"toolpath-changed"
)
self
.
core
.
emit_event
(
"toolpath-changed"
)
...
...
pycam/Plugins/ToolpathExport.py
View file @
a5e7a4a8
...
@@ -23,8 +23,8 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
...
@@ -23,8 +23,8 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
import
os
import
os
import
pycam.Plugins
import
pycam.Plugins
from
pycam.Exporters.GCodeExporter
import
PATH_MODES
from
pycam.Geometry.PointUtils
import
*
from
pycam.Geometry.PointUtils
import
*
import
pycam.Exporters.GCode.LinuxCNC
FILTER_GCODE
=
((
"GCode files"
,
(
"*.ngc"
,
"*.nc"
,
"*.gc"
,
"*.gcode"
)),)
FILTER_GCODE
=
((
"GCode files"
,
(
"*.ngc"
,
"*.nc"
,
"*.gc"
,
"*.gcode"
)),)
...
@@ -33,7 +33,7 @@ FILTER_GCODE = (("GCode files", ("*.ngc", "*.nc", "*.gc", "*.gcode")),)
...
@@ -33,7 +33,7 @@ FILTER_GCODE = (("GCode files", ("*.ngc", "*.nc", "*.gc", "*.gcode")),)
class
ToolpathExport
(
pycam
.
Plugins
.
PluginBase
):
class
ToolpathExport
(
pycam
.
Plugins
.
PluginBase
):
UI_FILE
=
"toolpath_export.ui"
UI_FILE
=
"toolpath_export.ui"
DEPENDS
=
[
"Toolpaths"
,
"FilenameDialog"
]
DEPENDS
=
[
"Toolpaths"
,
"FilenameDialog"
,
"ToolpathProcessors"
]
CATEGORIES
=
[
"Toolpath"
,
"Export"
]
CATEGORIES
=
[
"Toolpath"
,
"Export"
]
def
setup
(
self
):
def
setup
(
self
):
...
@@ -82,12 +82,16 @@ class ToolpathExport(pycam.Plugins.PluginBase):
...
@@ -82,12 +82,16 @@ class ToolpathExport(pycam.Plugins.PluginBase):
self
.
_export_toolpaths
(
self
.
core
.
get
(
"toolpaths"
)
.
get_selected
())
self
.
_export_toolpaths
(
self
.
core
.
get
(
"toolpaths"
)
.
get_selected
())
def
_export_toolpaths
(
self
,
toolpaths
):
def
_export_toolpaths
(
self
,
toolpaths
):
proc_name
=
self
.
get_selected
()
processor
=
self
.
core
.
get
(
"toolpath_processors"
)
.
get_selected
()
processor
=
self
.
_postprocessors
[
proc_name
]
if
not
processor
:
if
not
processor
:
self
.
log
.
warn
(
"
Unknown postprocessor:
%
s"
%
str
(
name
)
)
self
.
log
.
warn
(
"
No toolpath processor selected"
)
return
return
generator_func
=
processor
[
"func"
]
filter_func
=
processor
[
"func"
]
filter_params
=
self
.
core
.
get
(
"get_parameter_values"
)(
"toolpath_processor"
)
settings_filters
=
filter_func
(
filter_params
)
# TODO: get "public" filters (metric, ...)
common_filters
=
[]
# we open a dialog
# we open a dialog
if
self
.
core
.
get
(
"gcode_filename_extension"
):
if
self
.
core
.
get
(
"gcode_filename_extension"
):
filename_extension
=
self
.
core
.
get
(
"gcode_filename_extension"
)
filename_extension
=
self
.
core
.
get
(
"gcode_filename_extension"
)
...
@@ -106,7 +110,6 @@ class ToolpathExport(pycam.Plugins.PluginBase):
...
@@ -106,7 +110,6 @@ class ToolpathExport(pycam.Plugins.PluginBase):
return
return
try
:
try
:
destination
=
open
(
filename
,
"w"
)
destination
=
open
(
filename
,
"w"
)
safety_height
=
self
.
core
.
get
(
"gcode_safety_height"
)
# TODO: implement "get_meta_data()"
# TODO: implement "get_meta_data()"
#meta_data = self.get_meta_data()
#meta_data = self.get_meta_data()
meta_data
=
""
meta_data
=
""
...
@@ -116,6 +119,10 @@ class ToolpathExport(pycam.Plugins.PluginBase):
...
@@ -116,6 +119,10 @@ class ToolpathExport(pycam.Plugins.PluginBase):
machine_time
+=
toolpath
.
get_machine_time
()
machine_time
+=
toolpath
.
get_machine_time
()
all_info
=
meta_data
+
os
.
linesep
\
all_info
=
meta_data
+
os
.
linesep
\
+
"Estimated machine time:
%.0
f minutes"
%
machine_time
+
"Estimated machine time:
%.0
f minutes"
%
machine_time
generator
=
pycam
.
Exporters
.
GCode
.
LinuxCNC
.
LinuxCNC
(
destination
)
generator
.
add_filters
(
settings_filters
)
generator
.
add_filters
(
common_filters
)
"""
minimum_steps = [self.core.get("gcode_minimum_step_x"),
minimum_steps = [self.core.get("gcode_minimum_step_x"),
self.core.get("gcode_minimum_step_y"),
self.core.get("gcode_minimum_step_y"),
self.core.get("gcode_minimum_step_z")]
self.core.get("gcode_minimum_step_z")]
...
@@ -142,27 +149,22 @@ class ToolpathExport(pycam.Plugins.PluginBase):
...
@@ -142,27 +149,22 @@ class ToolpathExport(pycam.Plugins.PluginBase):
touch_off_pause_execution=self.core.get("touch_off_pause_execution"))
touch_off_pause_execution=self.core.get("touch_off_pause_execution"))
path_mode = self.core.get("gcode_path_mode")
path_mode = self.core.get("gcode_path_mode")
if path_mode == 0:
if path_mode == 0:
generator
.
set_path_mode
(
PATH_MODES
[
"exact_path"
]
)
generator.set_path_mode(
CORNER_STYLE_EXACT_PATH
)
elif path_mode == 1:
elif path_mode == 1:
generator
.
set_path_mode
(
PATH_MODES
[
"exact_stop"
]
)
generator.set_path_mode(
CORNER_STYLE_EXACT_STOP
)
elif path_mode == 2:
elif path_mode == 2:
generator
.
set_path_mode
(
PATH_MODES
[
"continuous"
]
)
generator.set_path_mode(
CORNER_STYLE_OPTIMIZE_SPEED
)
else:
else:
naive_tolerance = self.core.get("gcode_naive_tolerance")
naive_tolerance = self.core.get("gcode_naive_tolerance")
if naive_tolerance == 0:
if naive_tolerance == 0:
naive_tolerance = None
naive_tolerance = None
generator
.
set_path_mode
(
PATH_MODES
[
"continuous"
]
,
generator.set_path_mode(
CORNER_STYLE_OPTIMIZE_TOLERANCE
,
self.core.get("gcode_motion_tolerance"),
self.core.get("gcode_motion_tolerance"),
naive_tolerance)
naive_tolerance)
"""
for
toolpath
in
toolpaths
:
for
toolpath
in
toolpaths
:
params
=
toolpath
.
get_params
()
tool_id
=
params
.
get
(
"tool_id"
,
1
)
feedrate
=
params
.
get
(
"tool_feedrate"
,
300
)
spindle_speed
=
params
.
get
(
"spindle_speed"
,
1000
)
generator
.
set_speed
(
feedrate
,
spindle_speed
)
# TODO: implement toolpath.get_meta_data()
# TODO: implement toolpath.get_meta_data()
generator
.
add_moves
(
toolpath
.
get_basic_moves
(),
generator
.
add_moves
(
toolpath
.
path
,
toolpath
.
filters
)
tool_id
=
tool_id
,
comment
=
""
)
generator
.
finish
()
generator
.
finish
()
destination
.
close
()
destination
.
close
()
self
.
log
.
info
(
"GCode file successfully written:
%
s"
%
str
(
filename
))
self
.
log
.
info
(
"GCode file successfully written:
%
s"
%
str
(
filename
))
...
...
pycam/Plugins/ToolpathGrid.py
View file @
a5e7a4a8
...
@@ -109,7 +109,6 @@ class ToolpathGrid(pycam.Plugins.PluginBase):
...
@@ -109,7 +109,6 @@ class ToolpathGrid(pycam.Plugins.PluginBase):
toolpath
.
path
=
new_path
toolpath
.
path
=
new_path
self
.
core
.
emit_event
(
"toolpath-changed"
)
self
.
core
.
emit_event
(
"toolpath-changed"
)
else
:
else
:
self
.
core
.
get
(
"toolpaths"
)
.
add_new
((
new_path
,
self
.
core
.
get
(
"toolpaths"
)
.
add_new
((
new_path
,
toolpath
.
filters
))
toolpath
.
get_params
()))
self
.
core
.
get
(
"toolpaths"
)
.
select
(
toolpaths
)
self
.
core
.
get
(
"toolpaths"
)
.
select
(
toolpaths
)
pycam/Plugins/ToolpathProcessors.py
View file @
a5e7a4a8
...
@@ -24,7 +24,8 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
...
@@ -24,7 +24,8 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
import
pycam.Plugins
import
pycam.Plugins
import
pycam.Gui.ControlsGTK
import
pycam.Gui.ControlsGTK
import
pycam.Utils.log
import
pycam.Utils.log
import
pycam.Toolpath.Filters
as
Filters
from
pycam.Toolpath
import
CORNER_STYLE_EXACT_PATH
_log
=
pycam
.
Utils
.
log
.
get_logger
()
_log
=
pycam
.
Utils
.
log
.
get_logger
()
...
@@ -137,20 +138,22 @@ class ToolpathProcessors(pycam.Plugins.ListPluginBase):
...
@@ -137,20 +138,22 @@ class ToolpathProcessors(pycam.Plugins.ListPluginBase):
(
"toolpath-processor-list-changed"
,
self
.
_update_processors
),
(
"toolpath-processor-list-changed"
,
self
.
_update_processors
),
(
"toolpath-selection-changed"
,
self
.
_update_visibility
),
(
"toolpath-selection-changed"
,
self
.
_update_visibility
),
(
"notify-initialization-finished"
,
(
"notify-initialization-finished"
,
self
.
_
activate
_first_processor
),
self
.
_
select
_first_processor
),
)
)
self
.
register_event_handlers
(
self
.
_event_handlers
)
self
.
register_event_handlers
(
self
.
_event_handlers
)
self
.
_update_processors
()
self
.
_update_processors
()
self
.
_update_visibility
()
self
.
_update_visibility
()
self
.
core
.
set
(
"toolpath_processors"
,
self
)
return
True
return
True
def
teardown
(
self
):
def
teardown
(
self
):
if
self
.
gui
:
if
self
.
gui
:
self
.
_toggle_window
(
False
)
self
.
_toggle_window
(
False
)
self
.
core
.
set
(
"toolpath_processors"
,
None
)
self
.
unregister_event_handlers
(
self
.
_event_handlers
)
self
.
unregister_event_handlers
(
self
.
_event_handlers
)
self
.
core
.
get
(
"unregister_parameter_group"
)(
"toolpath_processor"
)
self
.
core
.
get
(
"unregister_parameter_group"
)(
"toolpath_processor"
)
def
_
activate
_first_processor
(
self
):
def
_
select
_first_processor
(
self
):
# run this action as soon as all processors are registered
# run this action as soon as all processors are registered
processors
=
self
.
core
.
get
(
"get_parameter_sets"
)(
"toolpath_processor"
)
.
values
()
processors
=
self
.
core
.
get
(
"get_parameter_sets"
)(
"toolpath_processor"
)
.
values
()
processors
.
sort
(
key
=
lambda
item
:
item
[
"weight"
])
processors
.
sort
(
key
=
lambda
item
:
item
[
"weight"
])
...
@@ -198,6 +201,12 @@ class ToolpathProcessors(pycam.Plugins.ListPluginBase):
...
@@ -198,6 +201,12 @@ class ToolpathProcessors(pycam.Plugins.ListPluginBase):
return
True
return
True
def
_get_processor_filters
(
core
,
parameters
):
filters
=
[]
core
.
call_chain
(
"toolpath_filters"
,
"settings"
,
parameters
,
filters
)
return
filters
class
ToolpathProcessorMilling
(
pycam
.
Plugins
.
PluginBase
):
class
ToolpathProcessorMilling
(
pycam
.
Plugins
.
PluginBase
):
DEPENDS
=
[
"Toolpaths"
,
"GCodeSafetyHeight"
,
"GCodeFilenameExtension"
,
DEPENDS
=
[
"Toolpaths"
,
"GCodeSafetyHeight"
,
"GCodeFilenameExtension"
,
...
@@ -210,7 +219,7 @@ class ToolpathProcessorMilling(pycam.Plugins.PluginBase):
...
@@ -210,7 +219,7 @@ class ToolpathProcessorMilling(pycam.Plugins.PluginBase):
"step_width_x"
:
0.0001
,
"step_width_x"
:
0.0001
,
"step_width_y"
:
0.0001
,
"step_width_y"
:
0.0001
,
"step_width_z"
:
0.0001
,
"step_width_z"
:
0.0001
,
"path_mode"
:
"exact_path"
,
"path_mode"
:
CORNER_STYLE_EXACT_PATH
,
"motion_tolerance"
:
0.0
,
"motion_tolerance"
:
0.0
,
"naive_tolerance"
:
0.0
,
"naive_tolerance"
:
0.0
,
"spindle_enable"
:
True
,
"spindle_enable"
:
True
,
...
@@ -218,17 +227,15 @@ class ToolpathProcessorMilling(pycam.Plugins.PluginBase):
...
@@ -218,17 +227,15 @@ class ToolpathProcessorMilling(pycam.Plugins.PluginBase):
"touch_off"
:
None
,
"touch_off"
:
None
,
}
}
self
.
core
.
get
(
"register_parameter_set"
)(
"toolpath_processor"
,
self
.
core
.
get
(
"register_parameter_set"
)(
"toolpath_processor"
,
"milling"
,
"Milling"
,
self
.
get_filters
,
parameters
=
parameters
,
"milling"
,
"Milling"
,
weight
=
10
)
lambda
params
:
_get_processor_filters
(
self
.
core
,
params
),
parameters
=
parameters
,
weight
=
10
)
return
True
return
True
def
teardown
(
self
):
def
teardown
(
self
):
self
.
core
.
get
(
"unregister_parameter_set"
)(
"toolpath_processor"
,
self
.
core
.
get
(
"unregister_parameter_set"
)(
"toolpath_processor"
,
"milling"
)
"milling"
)
def
get_filters
(
self
):
return
[]
class
ToolpathProcessorLaser
(
pycam
.
Plugins
.
PluginBase
):
class
ToolpathProcessorLaser
(
pycam
.
Plugins
.
PluginBase
):
...
@@ -246,14 +253,12 @@ class ToolpathProcessorLaser(pycam.Plugins.PluginBase):
...
@@ -246,14 +253,12 @@ class ToolpathProcessorLaser(pycam.Plugins.PluginBase):
"naive_tolerance"
:
0.0
,
"naive_tolerance"
:
0.0
,
}
}
self
.
core
.
get
(
"register_parameter_set"
)(
"toolpath_processor"
,
self
.
core
.
get
(
"register_parameter_set"
)(
"toolpath_processor"
,
"laser"
,
"Laser"
,
self
.
get_filters
,
parameters
=
parameters
,
"laser"
,
"Laser"
,
weight
=
50
)
lambda
params
:
_get_processor_filters
(
self
.
core
,
params
),
parameters
=
parameters
,
weight
=
50
)
return
True
return
True
def
teardown
(
self
):
def
teardown
(
self
):
self
.
core
.
get
(
"unregister_parameter_set"
)(
"toolpath_processor"
,
self
.
core
.
get
(
"unregister_parameter_set"
)(
"toolpath_processor"
,
"laser"
)
"laser"
)
def
get_filters
(
self
):
return
[]
pycam/Plugins/Toolpaths.py
View file @
a5e7a4a8
...
@@ -154,14 +154,14 @@ class Toolpaths(pycam.Plugins.ListPluginBase):
...
@@ -154,14 +154,14 @@ class Toolpaths(pycam.Plugins.ListPluginBase):
def
add_new
(
self
,
new_tp
):
def
add_new
(
self
,
new_tp
):
if
isinstance
(
new_tp
,
pycam
.
Toolpath
.
Toolpath
):
if
isinstance
(
new_tp
,
pycam
.
Toolpath
.
Toolpath
):
moves
=
new_tp
.
path
moves
=
new_tp
.
path
parameters
=
new_tp
.
get_params
()
filters
=
new_tp
.
filters
else
:
else
:
moves
,
parame
ters
=
new_tp
moves
,
fil
ters
=
new_tp
name
=
get_non_conflicting_name
(
"Toolpath #
%
d"
,
name
=
get_non_conflicting_name
(
"Toolpath #
%
d"
,
[
tp
[
"name"
]
for
tp
in
self
])
[
tp
[
"name"
]
for
tp
in
self
])
attributes
=
{
"visible"
:
True
,
"name"
:
name
}
attributes
=
{
"visible"
:
True
,
"name"
:
name
}
new_tp
=
ToolpathEntity
(
toolpath_path
=
moves
,
new_tp
=
ToolpathEntity
(
toolpath_path
=
moves
,
attributes
=
attributes
,
toolpath_
parameters
=
parameters
,
attributes
=
attribute
s
)
toolpath_
filters
=
filter
s
)
self
.
append
(
new_tp
)
self
.
append
(
new_tp
)
...
...
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