Book a Demo

Author Topic: Unable to set boundary IsSelectable (vbScript)  (Read 6596 times)

Mr Stuff

  • EA User
  • **
  • Posts: 64
  • Karma: +0/-0
    • View Profile
Unable to set boundary IsSelectable (vbScript)
« on: June 09, 2017, 04:37:07 pm »
(EA 12.1, Win 7)

Using Geert Bellekens' getDiagramObjects function https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Projects/Project%20Bellekens/Bellekens%20Docgen/Util.vbs to get the boundaries on a diagram, I am trying to set and unset the selectability of all boundaries according to the code below.

The (2x) boundaries are found and iterated over, but checking the set state after setting it and doing boundary.update (and even on a 2nd call after a diagram update has been done) shows selectability does not change (or on the diagram itself).

Code: [Select]
sub setAllBoundariesSelectability(selectableState)
dim curDiag as EA.Diagram
dim boundaries ' as EA.Collection
dim boundary as EA.DiagramObject
   
set curDiag = Repository.GetCurrentDiagram()
set boundaries = getDiagramObjects(curDiag,"Boundary")

for each boundary in boundaries
Session.Output("Boundary found!" & " Current selectability state:" & boundary.IsSelectable & ", Target State:" & selectableState ) ' & " " & boundary.ElementDisplayMode)
boundary.IsSelectable = selectableState
boundary.Update
if boundary.IsSelectable <> selectableState then
Session.Output("Boundary selectability set failed!")
end if
next
curDiag.Update
end sub

Things tried:

Whether boundaries is declared as EA.collection or not (because it's an ArrayList) makes no difference, nor does changing the call from the OnDiagtram script from "setAllBoundariesSelectability(False)"  (which EA usually objects to in a sub call, but doesn't in this case) to "setAllBoundariesSelectability False"

Tried adding an update to the element (obtained by Repository.GetElementByID(boundary.ElementID)) behind the boundary both before and after boundary.update - no effect.

I am new to EA scripting so may have overlooked something important... how do I fix this?

Many thanks,

Julian


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Unable to set boundary IsSelectable (vbScript)
« Reply #1 on: June 09, 2017, 07:20:12 pm »
It appears that the according DiagramObject has ObjectStyle added NSL=1; if the element is locked.

q.

Mr Stuff

  • EA User
  • **
  • Posts: 64
  • Karma: +0/-0
    • View Profile
Re: Unable to set boundary IsSelectable (vbScript)
« Reply #2 on: June 09, 2017, 10:16:23 pm »
Qwerty - can you expand on that? I don't follow.

NB the element is not locked (at least according to the UI context menu after manually making it selectable again)

Thanks

Julian

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Unable to set boundary IsSelectable (vbScript)
« Reply #3 on: June 09, 2017, 10:32:08 pm »
If you run a query
Code: [Select]
SELECT ObjectStyle FROM t_DiagramObjectsin the SQL scratchpad you will find that a non-selectable (aka locked) element has an addition of NSL=1; in this attribute. The field t_diagram.ObjectStyle corresponds to EaDiagramObject.Style. So without having tested you can add the text NSL=1; to this or you remove it to make it selectable again.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Unable to set boundary IsSelectable (vbScript)
« Reply #4 on: June 16, 2017, 10:18:01 pm »
According tot the help
Quote
IsSelectable
Boolean
Notes: Indicates whether this object on the diagram can be selected.
Setting IsSelectable to false, and then updating the diagramObject should work.
It doesn't say this is a read-only property (doesn't say read/write either)

So if setting this property doesn't have the expected result I would log it as a bug.

Geert

Benny

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Unable to set boundary IsSelectable (vbScript)
« Reply #5 on: June 19, 2017, 06:54:56 pm »
Quote
According tot the help
Quote
IsSelectable
Boolean
Notes: Indicates whether this object on the diagram can be selected.
Setting IsSelectable to false, and then updating the diagramObject should work.
It doesn't say this is a read-only property (doesn't say read/write either)

So if setting this property doesn't have the expected result I would log it as a bug.

Geert

Hi,

According to Page 89 in qwertys book ab IsSelectable: "In my tests this neither returned the correct setting nor did it change the property."

Yes it doesn´t  work. Like serveral other Methods that don´t effect the "Value" of an Element.
Like making Text in a Boundary Bold or altering the font etc.
It is a real pain to get those thinks work in a script properly Imho.

regards
Benny


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Unable to set boundary IsSelectable (vbScript)
« Reply #6 on: June 19, 2017, 07:13:56 pm »
There's something rotten on planet Sparx (free after Shakespeare). I once reported bugs. But after so many bugs not getting fixed I gave up. I even had a bug tracker set up on a public server which still might exist. And I'd bet it still lists a couple of bugs which are not fixed yet. See also skiwi's "Not in Vx" lists he's continuously updating.

q.

P.S. The bug tracker still exists: https://app.assembla.com/spaces/enterprise-architect/tickets Note that this is not an Sparx official tracker, but one I once set up for my own records. However, I did not touch it for many, many years.