Book a Demo

Author Topic: script implementing cut-and-paste functionality  (Read 5893 times)

mrblack12

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
script implementing cut-and-paste functionality
« on: November 03, 2016, 01:34:33 am »
Hi,

I'm working on a project in which a rather large number of business rules have been imported to a general package in EA, using a CSV import. But now we have to get each BR placed in the right functional package. We are still using EA version 10 which does not support (bulk) cut and paste, so each BR is manually copied to the clipboard and then manually pasted from the clipboard in the right package. To prevent double instances of the same BR we then have to get back to the general package and remove the original BR.

This is mind-numbingly boring work, especially when you have over hundreds of BR's to process. I was wondering if there's someone out there who has come up with a script of sorts to simulate the "Cut and paste" function.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: script implementing cut-and-paste functionality
« Reply #1 on: November 03, 2016, 01:39:07 am »
Hello,

In order to move an element between the packages, all you have to do is set Element.PackageID to the ID of the target package. No need to go through the clipboard.

/Uffe
My theories are always correct, just apply them to the right reality.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: script implementing cut-and-paste functionality
« Reply #2 on: November 03, 2016, 01:42:13 am »
... For that matter, there's no need to use the clipboard when going through the GUI either. Just drag-and-drop the elements from one package to the other.

/U
My theories are always correct, just apply them to the right reality.

mrblack12

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: script implementing cut-and-paste functionality
« Reply #3 on: November 03, 2016, 02:10:02 am »
Hi Uffe,

cheers for your speedy reply: I will definitely try out the first option. The second option is something we already tried but if you have a very long list of objects you need to scroll through, then drag-and-drop can become a bit difficult. Apart from the risk of letting your finger of the mouse button and EA dropping the object somewhere you don't want it.... ;)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: script implementing cut-and-paste functionality
« Reply #4 on: November 03, 2016, 04:09:32 am »
Any time. :)

If you haven't done a lot of scripting before, be aware that just moving things in the structure in the way described does not automatically update the project browser. For that, use Repository.RefreshModelView(packageID), on both the source and target packages, when you've moved the elements between them.

Or in the GUI, right-click the package in the project browser and select Contents -- Reload Current Package.

/Uffe
My theories are always correct, just apply them to the right reality.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: script implementing cut-and-paste functionality
« Reply #5 on: November 03, 2016, 09:06:53 am »
One trick for moving between packages with a very long list is to open the source package in the package browser. You can then scroll the project browser wherever you need and drag from the package browser to the target package. I think you can do it the other way, it's just not my normal procedure.

mrblack12

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: script implementing cut-and-paste functionality
« Reply #6 on: November 18, 2016, 12:26:00 am »
Thanx to Simon,

your idea did the trick. Seeing I'm not that big of a scripter.... ;)

Rick