|
@@ -123,8 +123,12 @@ class FlatCAMObj(QtCore.QObject):
|
|
|
|
|
|
|
|
:return: None
|
|
:return: None
|
|
|
"""
|
|
"""
|
|
|
|
|
+ FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + "--> FlatCAMObj.to_form()")
|
|
|
for option in self.options:
|
|
for option in self.options:
|
|
|
- self.set_form_item(option)
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ self.set_form_item(option)
|
|
|
|
|
+ except:
|
|
|
|
|
+ self.app.log.warning("Unexpected error:", sys.exc_info())
|
|
|
|
|
|
|
|
def read_form(self):
|
|
def read_form(self):
|
|
|
"""
|
|
"""
|
|
@@ -135,7 +139,11 @@ class FlatCAMObj(QtCore.QObject):
|
|
|
"""
|
|
"""
|
|
|
FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + "--> FlatCAMObj.read_form()")
|
|
FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + "--> FlatCAMObj.read_form()")
|
|
|
for option in self.options:
|
|
for option in self.options:
|
|
|
- self.read_form_item(option)
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ self.read_form_item(option)
|
|
|
|
|
+ except:
|
|
|
|
|
+ self.app.log.warning("Unexpected error:", sys.exc_info())
|
|
|
|
|
+
|
|
|
|
|
|
|
|
def build_ui(self):
|
|
def build_ui(self):
|
|
|
"""
|
|
"""
|
|
@@ -191,11 +199,16 @@ class FlatCAMObj(QtCore.QObject):
|
|
|
:type option: str
|
|
:type option: str
|
|
|
:return: None
|
|
:return: None
|
|
|
"""
|
|
"""
|
|
|
-
|
|
|
|
|
- try:
|
|
|
|
|
- self.options[option] = self.form_fields[option].get_value()
|
|
|
|
|
- except KeyError:
|
|
|
|
|
- self.app.log.warning("Failed to read option from field: %s" % option)
|
|
|
|
|
|
|
+ #try read field only when option have equivalent in form_fields
|
|
|
|
|
+ if option in self.form_fields:
|
|
|
|
|
+ option_type=type(self.options[option])
|
|
|
|
|
+ try:
|
|
|
|
|
+ value=self.form_fields[option].get_value()
|
|
|
|
|
+ #catch per option as it was ignored anyway, also when syntax error (probably uninitialized field),don't read either.
|
|
|
|
|
+ except (KeyError,SyntaxError):
|
|
|
|
|
+ self.app.log.warning("Failed to read option from field: %s" % option)
|
|
|
|
|
+ else:
|
|
|
|
|
+ self.app.log.warning("Form fied does not exists: %s" % option)
|
|
|
|
|
|
|
|
def plot(self):
|
|
def plot(self):
|
|
|
"""
|
|
"""
|
|
@@ -631,13 +644,16 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
|
|
|
self.ser_attrs += ['options', 'kind']
|
|
self.ser_attrs += ['options', 'kind']
|
|
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
|
- def merge(exc_list, exc_final, copy_options):
|
|
|
|
|
|
|
+ def merge(exc_list, exc_final):
|
|
|
"""
|
|
"""
|
|
|
- Merges(copy if used on one) the excellon of objects in exc_list into
|
|
|
|
|
- options have same like exc_final
|
|
|
|
|
- the geometry of geo_final.
|
|
|
|
|
|
|
+ Merge excellons in exc_list into exc_final.
|
|
|
|
|
+ Options are allways copied from source .
|
|
|
|
|
+
|
|
|
|
|
+ Tools are also merged, if name for tool is same and size differs, then as name is used next available number from both lists
|
|
|
|
|
|
|
|
- :param exc_list: List of FlatCAMExcellon Objects to join.
|
|
|
|
|
|
|
+ if only one object is specified in exc_list then this acts as copy only
|
|
|
|
|
+
|
|
|
|
|
+ :param exc_list: List or one object of FlatCAMExcellon Objects to join.
|
|
|
:param exc_final: Destination FlatCAMExcellon object.
|
|
:param exc_final: Destination FlatCAMExcellon object.
|
|
|
:return: None
|
|
:return: None
|
|
|
"""
|
|
"""
|
|
@@ -648,26 +664,27 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
|
|
|
else:
|
|
else:
|
|
|
exc_list_real=exc_list
|
|
exc_list_real=exc_list
|
|
|
|
|
|
|
|
-
|
|
|
|
|
for exc in exc_list_real:
|
|
for exc in exc_list_real:
|
|
|
# Expand lists
|
|
# Expand lists
|
|
|
if type(exc) is list:
|
|
if type(exc) is list:
|
|
|
- FlatCAMExcellon.merge(exc, exc_final, copy_options)
|
|
|
|
|
-
|
|
|
|
|
- # If not list, just append
|
|
|
|
|
|
|
+ FlatCAMExcellon.merge(exc, exc_final)
|
|
|
|
|
+ # If not list, merge excellons
|
|
|
else:
|
|
else:
|
|
|
- if copy_options is True:
|
|
|
|
|
- exc_final.options["plot"]=exc.options["plot"]
|
|
|
|
|
- exc_final.options["solid"]=exc.options["solid"]
|
|
|
|
|
- exc_final.options["drillz"]=exc.options["drillz"]
|
|
|
|
|
- exc_final.options["travelz"]=exc.options["travelz"]
|
|
|
|
|
- exc_final.options["feedrate"]=exc.options["feedrate"]
|
|
|
|
|
- exc_final.options["tooldia"]=exc.options["tooldia"]
|
|
|
|
|
- exc_final.options["toolchange"]=exc.options["toolchange"]
|
|
|
|
|
- exc_final.options["toolchangez"]=exc.options["toolchangez"]
|
|
|
|
|
- exc_final.options["spindlespeed"]=exc.options["spindlespeed"]
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
+ # TODO: I realize forms does not save values into options , when object is deselected
|
|
|
|
|
+ # leave this here for future use
|
|
|
|
|
+ # this reinitialize options based on forms, all steps may not be necessary
|
|
|
|
|
+ # exc.app.collection.set_active(exc.options['name'])
|
|
|
|
|
+ # exc.to_form()
|
|
|
|
|
+ # exc.read_form()
|
|
|
|
|
+ for option in exc.options:
|
|
|
|
|
+ if option is not 'name':
|
|
|
|
|
+ try:
|
|
|
|
|
+ exc_final.options[option] = exc.options[option]
|
|
|
|
|
+ except:
|
|
|
|
|
+ exc.app.log.warning("Failed to copy option.",option)
|
|
|
|
|
+
|
|
|
|
|
+ #deep copy of all drills,to avoid any references
|
|
|
for drill in exc.drills:
|
|
for drill in exc.drills:
|
|
|
point = Point(drill['point'].x,drill['point'].y)
|
|
point = Point(drill['point'].x,drill['point'].y)
|
|
|
exc_final.drills.append({"point": point, "tool": drill['tool']})
|
|
exc_final.drills.append({"point": point, "tool": drill['tool']})
|
|
@@ -679,7 +696,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
|
|
|
max_numeric_tool=numeric_tool
|
|
max_numeric_tool=numeric_tool
|
|
|
toolsrework[exc.tools[toolname]['C']]=toolname
|
|
toolsrework[exc.tools[toolname]['C']]=toolname
|
|
|
|
|
|
|
|
- #final as last becouse names from final tools will be used
|
|
|
|
|
|
|
+ #exc_final as last because names from final tools will be used
|
|
|
for toolname in exc_final.tools.iterkeys():
|
|
for toolname in exc_final.tools.iterkeys():
|
|
|
numeric_tool=int(toolname)
|
|
numeric_tool=int(toolname)
|
|
|
if numeric_tool>max_numeric_tool:
|
|
if numeric_tool>max_numeric_tool:
|
|
@@ -692,9 +709,10 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
|
|
|
exc_final.tools[str(max_numeric_tool+1)]={"C": toolvalues}
|
|
exc_final.tools[str(max_numeric_tool+1)]={"C": toolvalues}
|
|
|
else:
|
|
else:
|
|
|
exc_final.tools[toolsrework[toolvalues]]={"C": toolvalues}
|
|
exc_final.tools[toolsrework[toolvalues]]={"C": toolvalues}
|
|
|
|
|
+ #this value was not co
|
|
|
|
|
+ exc_final.zeros=exc.zeros
|
|
|
exc_final.create_geometry()
|
|
exc_final.create_geometry()
|
|
|
|
|
|
|
|
-
|
|
|
|
|
def build_ui(self):
|
|
def build_ui(self):
|
|
|
FlatCAMObj.build_ui(self)
|
|
FlatCAMObj.build_ui(self)
|
|
|
|
|
|