Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: phdare on August 29, 2014, 04:39:25 pm
-
I tried to lock/unlock element via AddIn. In EA_OnContextItemDoubleClicked (before properties dialog is opened). I add some code to lock element
EA.Element element = Repository.GetElementByGuid(GUID);
element.Locked = true;
but it didn't work, properties dialog open and element isn't locked.
-
Your code misses the Update, but I guess you just did not post that. So most likely this will not work. There are already quite some work arounds in the area of these OnPre/Post methods since they do not exactly behave as you expect (some would call it inconsistency, but I just call it poor design). So I recommend to send a bug report and look for an alternative solution :(
q.
-
If I add the Update method, I will get System.Runtime.InteropServices.COMException with message "Element Lock".
If I remove the Update, I need to close and reopen diagram afterward, the Element is locked. It seems element is updated without calling the Update. To walk around, I I add Repository.ReloadDiagram but it didn't work well, sometimes Sparx is crashed.
:(
-
Locking and unlocking with the API functions doesn't work.
I've posted my workaround on the forum a while ago.
(use top left search button to search)
Geert
-
Locking and unlocking with the API functions doesn't work.
I've posted my workaround on the forum a while ago.
(use top left search button to search)
Geert
Could somebody tell me the link, please? I cannot find the workaround. V.
-
Element.ApplyUserLock() works if the element was not locked yet
And Element.ReleaseUserLock() works if the current user was locking the element.
For other stuff you'll have to manipulate the database directly.
Geert
-
Element.ApplyUserLock() works if the element was not locked yet
And Element.ReleaseUserLock() works if the current user was locking the element.
For other stuff you'll have to manipulate the database directly.
Geert
Many thanks, Geert. I am using these methods by still getting "System.Runtime.InteropServices.COMException" with message "Element Lock". Are there also other reasons for this Exception, e.g. a write lock on the database for any reason?
-
In which circumstances do you get that message?
If you share your code we can maybe spot where it goes wrong.
Geert