Book a Demo

Author Topic: How can code be generated using an automation script?  (Read 7518 times)

heba

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
How can code be generated using an automation script?
« on: July 28, 2016, 10:09:58 pm »
Hi all,

I want to generate code for classes using an automation script and I'm searching for the respective method.  There should be something like Element.Generate(File, Language) but I cannot find it. And I'm quite sure that I have seen something like this  :-\

Use case is to generate a package resp. some elements of it two times with a different language in each run.

Thanks,
Heiko

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile

heba

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: How can code be generated using an automation script?
« Reply #2 on: July 28, 2016, 11:25:52 pm »
Thank you!

Am I right that I cannot pass my desired language even for the class?

  GenerateClass (string ElementGUID, string ExtraOptions) --> ExtraOptions: [..] currently unused

and GeneratePackage () does not provide such a feature in the ExtraOptions.

I suppose the language is taken from the GenType property and the only solution is to change that before generating?  Which again means I have to lock the package if security is enabled, right?  That could make things more complicated  ???

BR,
Heiko

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How can code be generated using an automation script?
« Reply #3 on: July 28, 2016, 11:41:49 pm »
I suppose the language is taken from the GenType property and the only solution is to change that before generating?  Which again means I have to lock the package if security is enabled, right?  That could make things more complicated  ???

I believe that is correct yes.

Geert

heba

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: How can code be generated using an automation script?
« Reply #4 on: July 29, 2016, 04:41:28 pm »
Ok, thank you!  I managed to get this to work.

Now I'm left with one final question for which my searches did not return any useful result:

To use relative paths our classes normally have a local variable like %TRUNK% in their Filename.  Is it possible to query this variable's value using the API?

Btw, I wonder why GenerateClass() does not use the "ExtraOptions". Some parameters like overwrite, dir or even lang would be useful - at least to me ;-)

BR,
Heiko

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How can code be generated using an automation script?
« Reply #5 on: July 29, 2016, 05:32:42 pm »
They are stored in the file %appdata%\Sparx Systems\EA\paths.txt

q.

heba

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: How can code be generated using an automation script?
« Reply #6 on: July 29, 2016, 07:03:09 pm »
They are stored in the file %appdata%\Sparx Systems\EA\paths.txt

Yes, but should we really use system file access to read these variables? I was hoping to find something more internal...

Passing the variable to the "dir" parameter in the "ExtraOptions", e.g. "Dir=%TRUNK%\\generated\\" does not work. It generates but the files do not seem to appear anywhere :o   Although this is not documented as supported, could it be that it should work but is a bug?  :)

BR,
Heiko

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How can code be generated using an automation script?
« Reply #7 on: July 29, 2016, 07:24:09 pm »
Yes, we should. It's EA ;D

q.