Commit 487c9304 authored by Lars Kruse's avatar Lars Kruse

add two more simple toolpath filters (Copy, MovesOnly)

* MovesOnly: useful for determining if a toolpath is empty/useless
* Copy: just hide the interal structure of a toolpath (tuple/list)
parent 84693f98
...@@ -56,6 +56,9 @@ class BaseFilter(object): ...@@ -56,6 +56,9 @@ class BaseFilter(object):
return self.__class__(**self.settings) return self.__class__(**self.settings)
def __ror__(self, toolpath): def __ror__(self, toolpath):
# allow to use pycam.Toolpath.Toolpath instances (instead of a list)
if hasattr(toolpath, "path") and hasattr(toolpath, "get_params"):
toolpath = toolpath.path
return self.filter_toolpath(toolpath) return self.filter_toolpath(toolpath)
def filter_toolpath(self, toolpath): def filter_toolpath(self, toolpath):
...@@ -236,3 +239,17 @@ class TimeLimit(BaseFilter): ...@@ -236,3 +239,17 @@ class TimeLimit(BaseFilter):
break break
return new_path return new_path
class MovesOnly(BaseFilter):
""" Use this filter for checking if a given toolpath is empty/useless
(only machine settings, safety moves, ...).
"""
def filter_toolpath(self, toolpath):
return [item for item in toolpath
if item[0] in (MOVE_STRAIGHT, MOVE_STRAIGHT_RAPID)]
class Copy(BaseFilter):
def filter_toolpath(self, toolpath):
return list(toolpath)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment