Execute 4dScript code from external application

All topics specific to modeling questions in Enterprise Dynamics
Post Reply
chaix
Posts: 8
Joined: Friday 26 April, 2019 - 15:06

Execute 4dScript code from external application

Post by chaix » Friday 26 April, 2019 - 15:44

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

User avatar
HarryBunnik
Posts: 302
Joined: Monday 07 February, 2011 - 11:22

Re: Execute 4dScript code from external application

Post by HarryBunnik » Friday 26 April, 2019 - 19:15

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

chaix
Posts: 8
Joined: Friday 26 April, 2019 - 15:06

Re: Execute 4dScript code from external application

Post by chaix » Monday 29 April, 2019 - 12:27

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?

User avatar
evraamsdonk
Posts: 2
Joined: Monday 29 April, 2019 - 17:26

Re: Execute 4dScript code from external application

Post by evraamsdonk » Tuesday 30 April, 2019 - 10:31

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.
Attachments
ED.tlb.zip
ActiveX Type Library
(1.07 KiB) Downloaded 8 times

chaix
Posts: 8
Joined: Friday 26 April, 2019 - 15:06

Re: Execute 4dScript code from external application

Post by chaix » Tuesday 30 April, 2019 - 17:19

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

User avatar
evraamsdonk
Posts: 2
Joined: Monday 29 April, 2019 - 17:26

Re: Execute 4dScript code from external application

Post by evraamsdonk » Tuesday 30 April, 2019 - 17:47

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

User avatar
Fred
Posts: 20
Joined: Wednesday 17 November, 2010 - 12:06

Re: Execute 4dScript code from external application

Post by Fred » Tuesday 30 April, 2019 - 19:14

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.
}

Post Reply