Book a Demo

Author Topic: Enumerations in VBScript and Auto-Layout Diagrams  (Read 4631 times)

Reggie

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Enumerations in VBScript and Auto-Layout Diagrams
« on: May 07, 2010, 10:44:12 am »
I am writing a script in VBScript to import Sparx objects from Excel and lay them out in a diagram automatically using the LayoutDiagramEx function. I was hoping to customize how the layout worked, but in order to do so I need to use the ConstLayoutStyles Enumeration as documented in the online reference.

Unfortunately, it seems that none of the enumerations work in VBScript at all for me. I have tried several different types, including the ObjectType enumeration to distinguish selected objects, but none of them work. I had to figure out the Object types by printing types of existing objects. Why is this? Do the enumerated values not work in EA's VBScript? Otherwise, how do you access the enumerated values? I can't find any example code on the website.

Once I know how to get the enumerated values, how do the ConstLayoutStyles enumerations work? Do you add them together to identify the different options? Also, some of the parameters (such as the layer and column spacing and saveDiagram) don't seem to work on this function.

Help would be greatly appreciated

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Enumerations in VBScript and Auto-Layout Diagr
« Reply #1 on: May 07, 2010, 05:47:24 pm »
Reggie,

I remember a similar question about the enumerations in script a while ago. (with an answer from Sparx)
Use the top left search button to search for it.

Geert

Reggie

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Enumerations in VBScript and Auto-Layout Diagr
« Reply #2 on: May 16, 2010, 11:44:52 am »
I believe I found the topic you were referring to, but it didn't really provide any answers. Are there any lists of the constant values available, so that I could at least declare them as variables? I found by trial and error that at least the value 1 works for constlayoutstyle, and fixes the issue of not saving, but I even went to the extreme of writing a script to loop through numbers and layout the diagram over and over, but could not find any other ones that worked. I would like to at least be able to control the direction that the connectors point as I would by manually changing the diagram settings. Any help would be greatly appreciated.

mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: Enumerations in VBScript and Auto-Layout Diagr
« Reply #3 on: May 17, 2010, 09:13:59 am »
The short version of the answer is that they aren't recognised by the script engine at the moment. Check out our examples for a way around it, we usually just define them as consts at the top of the script.

Also if you feel inclined, please submit a bug report to let the support team know that it needs to be addressed.
Best Regards,

Michael

[email protected]
"It is more complicated than you think." - RFC 1925, Section 2.8

Reggie

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Enumerations in VBScript and Auto-Layout Diagr
« Reply #4 on: May 17, 2010, 11:24:07 pm »
Maybe I just haven't found the examples that define the constants, but I've been looking for them. Could you provide a URL?

Thanks

Andrew Warner

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Enumerations in VBScript and Auto-Layout Diagr
« Reply #5 on: May 31, 2010, 11:15:13 am »
Hi Reggie,
I asked the same question a while back. Have a look at this post; it talks about the !INC statement to include a script in one you're running.

Quote
You can use !INC to include other scripts within your current script.

The syntax is
Code: [Select]
!INC [Script Group Name].[Script Name]
This has the same effect as a #include where the code from the included script is injected into the current script when it is loaded into the script engine. You should then be able to call functions belonging to the included script from the base script.

Example
Code: [Select]
!INC Some Group.My Script To Include
var result = FunctionFromOtherScript();

Note that you can only include scripts that are written in the same language as your base script.
« Last Edit: May 31, 2010, 11:16:12 am by adwarner »
Regards,
Andrew Warner.