CODESYS - the IEC 61131-3 automation software
https://forum.codesys.com/

Deleting devices
https://forum.codesys.com/viewtopic.php?f=18&t=4975
Page 1 of 1

Author:  daniel_REC [ Fri Jul 20, 2012 10:27 am ]
Post subject:  Deleting devices

Hello all,

Does someone know how to delete particular device from project list using script?

Author:  M.Schaber [ Fri Jul 20, 2012 10:37 am ]
Post subject:  Re: Deleting devices

Hi, Daniel,

daniel_REC wrote:
Does someone know how to delete particular device from project list using script?


Code:
proj = projects.primary

dev = proj.find("Device", "EtherCAT_Master", "EK1100")[0]

dev.remove()


This only works if the device descriptions permit removing of that particular device - on other words, if you can delete it using the UI in the same situation.

For Slots, you can call the unplug() method.

Author:  daniel_REC [ Mon Jul 23, 2012 6:23 am ]
Post subject:  Re: Deleting devices

Thank You,

Also, is there a way to move module in device tree up or down, using script?
My devices tree looks like this:
- CIFX_PB
- UR20_FBC_PB_DP
- UR20_8DO_P
- UR20_4DO_P

I was trying to run script:

proj = projects.primary
app = proj.active_application
onlineapp = online.create_online_application(app)

dev = proj.find("UR20_FBC_PB_DP", True)
obj = proj.find("UR20_4DO_P", True)
obj[0].move(dev[0],0)

but in response I have error: "This device cannot be added or inserted here"

Author:  M.Schaber [ Fri Aug 17, 2012 11:48 am ]
Post subject:  Re: Deleting devices

Hi, Daniel,

daniel_REC wrote:
Also, is there a way to move module in device tree up or down, using script?
My devices tree looks like this:
- CIFX_PB
- UR20_FBC_PB_DP
- UR20_8DO_P
- UR20_4DO_P

I was trying to run script:

proj = projects.primary
app = proj.active_application
onlineapp = online.create_online_application(app)

dev = proj.find("UR20_FBC_PB_DP", True)
obj = proj.find("UR20_4DO_P", True)
obj[0].move(dev[0],0)

but in response I have error: "This device cannot be added or inserted here"


If the device descriptions allow that movement, and the indices are set correctly, it should work that way. Actually, I did experiment a little bit, and it worked on my side.

Page 1 of 1 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/