--- a/IDEFrame.py Thu Jun 06 14:03:16 2019 +0200
+++ b/IDEFrame.py Thu Jun 13 15:49:48 2019 +0200
@@ -1997,7 +1997,7 @@
AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Program"))
self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "program"), id=new_id)
- menu.AppendMenu(wx.NewId(), _("Change POU Type To"), change_menu)
+ menu.AppendMenu(wx.NewId(), _("Duplicate as..."), change_menu) AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Rename"))
self.Bind(wx.EVT_MENU, self.OnRenamePouMenu, id=new_id)
--- a/PLCControler.py Thu Jun 06 14:03:16 2019 +0200
+++ b/PLCControler.py Thu Jun 13 15:49:48 2019 +0200
@@ -532,7 +532,26 @@
if self.Project is not None:
pou = self.Project.getpou(name)
- pou.setpouType(pou_type)
+ new_pou = self.Copy(pou) + new_name = name + "_" + pou_type + while self.Project.getpou(new_name) is not None: + new_name = "%s%d" % (name, idx) + new_pou.setname(new_name) + orig_type = pou.getpouType() + if orig_type == 'function' and pou_type in ['functionBlock', 'program']: + return_type_obj = new_pou.interface.getreturnType() + new_pou.interface.remove(return_type_obj) + # To be ultimately correct we could re-create an + # output variable with same name+_out or so + # but in any case user will have to connect/assign + # this output, so better leave it as-is + new_pou.setpouType(pou_type) + self.Project.insertpou(0, new_pou) def GetPouXml(self, pou_name):