Page 1 of 1

Execute 4dScript code from external application

Posted: Friday 26 April, 2019 - 15:44
by chaix
Good morning everyone,

I wanted to ask if it is possible to start a simulation on Enterprise Dynamics through an external application written in Java.

Let me explain better, I would like to create a project in Java that allows me to choose an existing model, open it and execute some 4dScript code automatically.

It's possibile to do it? If so how can I make it happen?

Thanks to all in advance

Re: Execute 4dScript code from external application

Posted: Friday 26 April, 2019 - 19:15
by HarryBunnik
Ha chaix,

Yes, that must be possible. :-)

Perhaps the topic viewtopic.php?f=9&t=433&p=1811&hilit=java#p1811 can give you a start here. Do note that to get access to the examples mentioned there you'll need to install the SDK-kit, which is an additional package. this package can be downloaded from within Enterprise Dynamics, under the Ribbon "Help", "Browse packages"(Updates).

The models are then located under:

...\Documents\Enterprise Dynamics\10.2\SDK\ActiveX\...

I hope this helps you further.

Regards,

Harry

Re: Execute 4dScript code from external application

Posted: Monday 29 April, 2019 - 12:27
by chaix
Hi Harry, thanks for the reply

I installed the add-on package but I only noticed support for C#, VB and Delphi. Is it possible to use Java?

Otherwise, I noticed that for C# it is possible to add an ED library to the references of the project, is there one for Java?

Re: Execute 4dScript code from external application

Posted: Tuesday 30 April, 2019 - 10:31
by evraamsdonk
Hi Chaix,

To be able to control ED using ActiveX from Java, you need the Type Library file. I've attached this file to this post.
You will need an ActiveX library for Java as well.
Here is an article that describes how to use the Jacob library with Java to control Word:
https://www.programcreek.com/java-api-e ... XComponent
The same principles should apply to controlling ED using Java. You should be able to execute any 4DScript.
I don't have any experience with this myself, but let us know if you need more information.

Re: Execute 4dScript code from external application

Posted: Tuesday 30 April, 2019 - 17:19
by chaix
Hi evraamsdonk, thanks for your suggestion.

I downloaded the Jacob library, but when I try to use the ActiveXComponent constructor I have to pass the ED programId as a parameter.
Can you tell me what it is?

Thanks,
chaix

Re: Execute 4dScript code from external application

Posted: Tuesday 30 April, 2019 - 17:47
by evraamsdonk
Hi Chaix,

The person who would know for sure is not in right now. But I checked the Delphi ActiveX example project from the SDK, and there I see some GUIDs that might be what you need.
So I suspect it might be one of the following:
{76846999-95C5-45F3-8969-E7E978E2731B}
or
{25F1FD95-D86C-435C-805A-35C30FA06D0B}
I'm not sure if those curly braces are part of the id.

I'll will check with my colleague tomorrow to make sure it's one of these ids; if not, I'll post the correct ones.

Regards,
Ewoud

Re: Execute 4dScript code from external application

Posted: Tuesday 30 April, 2019 - 19:14
by Fred
Try something like this:

Code: Select all

private void UseED() {
  ActiveXComponent app = new ActiveXComponent("ED.App");
  
  // Use app to invoke 4DScript by using the functions Run4DScript and Invoke4DScript.
}