PLCControler.py
changeset 1337 204ef2daa33c
parent 1331 38c5de794e62
child 1338 c1e6c712cc35
--- a/PLCControler.py	Sun Sep 29 21:37:13 2013 +0200
+++ b/PLCControler.py	Tue Oct 01 09:24:02 2013 +0200
@@ -2220,9 +2220,10 @@
                 element.addinstance(instance)
                 instance_type = instance.getLocalTag()
                 if instance_type == "block":
+                    blocktype = instance.gettypeName()
+                    blocktype_infos = self.GetBlockType(blocktype)
                     blockname = instance.getinstanceName()
-                    if blockname is not None:
-                        blocktype = instance.gettypeName()
+                    if blocktype_infos["type"] != "function" and blockname is not None:
                         if element_type == "function":
                             return _("FunctionBlock \"%s\" can't be pasted in a Function!!!")%blocktype
                         blockname = self.GenerateNewName(tagname, 
@@ -2448,7 +2449,10 @@
                 self.ChangeEditedElementPouVar(tagname, old_type, old_name, new_type, new_name)
             for param, value in infos.items():
                 if param == "name":
-                    block.setinstanceName(value)
+                    if value != "":
+                        block.setinstanceName(value)
+                    else:
+                        block.attrib.pop("instanceName", None)
                 elif param == "type":
                     block.settypeName(value)
                 elif param == "executionOrder" and block.getexecutionOrderId() != value: