Book a Demo

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - janos_murai

Pages: [1]
1
Thank you for all the helpful replies!

You are right, the problem was with the thread handling.

My solution was to remove the background worker, and I called my link-deleting function with the Thread class. Although, I don’t understand why it works now, because as far as I know the background worker creates a new thread the same way as the Thread class does.
It is also strange that I could create connectors with the original method.

Thanks again,
Janos

2
Automation Interface, Add-Ins and Tools / Delete connector with c#
« on: July 22, 2016, 10:19:15 pm »
I would like to delete a connector in my add-in. I know that there are a few topic about this, but I'm facing a new problem. I know the exact index of the connector I’d like to delete in the Connectors collection. I don’t try to delete this link in a loop. I use all the possible updating functions.
My code is the following:
Code: [Select]
try
{
       short connectorNum = 0;
       string last error = “”;
       requirementElementTarget.Connectors.Delete(connectorNum);
       requirementElementTarget.Connectors.Refresh();
       requirementElementTarget.Update();
       requirementElementSource.Connectors.Refresh();
       requirementElementSource.Update();
       lastError = requirementElementTarget.Connectors.GetLastError();
}
catch
{
//No exception here
}

The type of the variable requirementElementTarget and requirementElementSource are EA.Element. This code works, so it deletes the appropriate link. It doesn’t throw any exception and the lastError string is empty.
The bad part:
I have a Windows Form, where I implemented a BackgroundWorker, and I would like to call the link deleting code from there. I call other functions from this BackgroundWorker, they work fine. I can also call the link deleting function, it returns without any problem or exception. Finally I call the Windows Form’s ShowDialog() function, and this throws a System.Runtime.InteropServices.SEHException. Well I’m not a .NET genius so I don’t really know what does this exception mean, but I could figure out that this exception was coming from an other thread.
The StackTrace is the following:
Code: [Select]
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.RunDialog(Form form)
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at System.Windows.Forms.Form.ShowDialog()
   at EADOORSLinkSync.EADOORSLinkSyncAddinClass.callSnycScript(String updateMode) in C:\murajade\EA_scripts\EADOORSLinkSyncAddIn\trunk\EADOORSLinkSync\EADOORSLinkSync_Solution\EADOORSLinkSync\EADOORSLinkSyncAddinClass.cs:line 189

I can catch this exception, but it will kill EA anyway. After restarting EA, the connector doesn’t exist anymore. If I remove the “requirementElementTarget.Connectors.Delete(connectorNum);”  line everything works without any problem.

I hope my problem is more or less clear.  :'(

Thank you in advance!

3
Automation Interface, Add-Ins and Tools / Re: Run script from add-in
« on: June 29, 2016, 05:06:21 pm »
I have a new problem, which is relevant to the original topic.

I could create an add-in using the Enterprise Architect Add-in Framework. The script calling works the same way as in EA-matic.
The problem is with the EA object. If I create a new variable in the script like
Code: [Select]
dim selectedPackage as EA.Package and I run it from EA, it runs without error, but if I run the same script via my add-in (so the interpreter is called by the add-in), it throws the following error:
"Anweisungsende erwartet ERROR : Anweisungsende erwartet | Line of error: 398 | Code error: \tdim selectedPackage as EA.Package"
I tried it with EA-matic's source in debug mode, and I experienced the same behavior.
Any idea what could cause this problem?

Thank you!

4
Automation Interface, Add-Ins and Tools / Re: Run script from add-in
« on: June 23, 2016, 09:03:29 pm »
Thank you Jon and Geert!

Geert, your website is really nice and helpful!

5
Automation Interface, Add-Ins and Tools / Run script from add-in
« on: June 23, 2016, 05:52:05 pm »
Dear all,

I have a C# add-in and a VBScript. Is it possible to include and start the script from the add-in?
I know that with the
Code: [Select]
!INC Local directive I can include scripts into each other, but how does it work with external sources?

Thank you!

Janos Murai

Pages: [1]