Book a Demo

Author Topic: Script to sort elements in package by Alias Ref  (Read 8671 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Script to sort elements in package by Alias Ref
« on: March 29, 2014, 03:31:51 am »
Hi,
Is there any script available that sorts elements by the Alias ?
I guess it requires to update the TPos value via a SQL UPDATE

I imported a number of requirements that I'd like to sort by the reference number, contained in the alias field

thanks
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Script to sort elements in package by Alias Re
« Reply #1 on: March 31, 2014, 05:02:43 pm »
You shouldn't go by SQL update, you access the TPos using Element.TreePos

Geert

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Script to sort elements in package by Alias Re
« Reply #2 on: March 31, 2014, 11:02:37 pm »
Hi Geert,

This method only works to get the value. It doesn't work when setting a value e.g. element.TreePos = 2 (an error message is displayed), so I used a SQL UPDATE query.

Have you successfully tried it on your end? Something I might be missing?

thanks
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Script to sort elements in package by Alias Re
« Reply #3 on: March 31, 2014, 11:18:57 pm »
What is the error message?

Look closely at the documentation. For some reason they decided to use a Long for the Treepos and not an int, so you might get a datatype error when assigning value "2"

Geert

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Script to sort elements in package by Alias Re
« Reply #4 on: April 02, 2014, 01:33:41 am »
Thanks for the advice ; casting to a long worked  :)
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Script to sort elements in package by Alias Re
« Reply #5 on: April 09, 2014, 04:35:09 pm »
FYI I published an article on Sparx Community site with 2 project browser scripts: sort by Alias, and sort by a dedicated tagged value (SortingOrder).

url : http://community.sparxsystems.com/community-resources/798-project-browser-script-sort-by-alias-sort-by-tagged-value
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com