question

Charlie avatar image
0 Likes"
Charlie asked Charlie edited

Access Current Active Flexsim Document From Excel

I was wondering if it is possible to get the current active flexsim object through an excel VBA interface. The idea is to retrieve the current active flexsim document and access the elements in it and write certain properties to excel or write back to model from excel.

An example would be say to get the names of all elements in the model to excel, then say i change the names of elements in excel and write it back to the model.

Usually one can use the GetObject() method to get an application

Example: This code retrieves the current CATIA active document and then from the top node, one can move down to access the sub nodes as shown.

Sub CATMain()

Dim CATIA As Object

Set CATIA = GetObject(, "CATIA.Application")

Set openDocument = CATIA.ActiveDocument

Set currentPart = openDocument.Part

Set currentBody = currentPart.Bodies.item(1)

Set currentPad = currentBody.pad

'And so on and so forth working all the way down to the sub-nodes

End Sub

I tried to achieve the same with flexsim, but it doesn't seem to work. The error is written beside each line.

Sub Main()

Dim flexsim As Object

Set flexsim = GetObject(,"FlexSim.Application") ' ActiveX component cannot create object

Set flexsim = GetObject("D:\Flexsim_learning\ExcelFlexsimInterface.fsm") 'File name or class name not found during automation operation

End Sub

FlexSim 19.1.0
getobject
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
0 Likes"
Phil BoBo answered Charlie commented

The code in your question is accessing Catia via its COM interface using .NET.

FlexSim is a Win32 C++ desktop application. It isn't a .NET application. FlexSim does not natively support accessing it via COM.

In 2009, Anthony Johnson created a demo in FlexSim 4.32 that used custom DLLs to demonstrate an example of how COM could be used to control FlexSim.

See COM Object for Controlling Flexsim

That code was a proof-of-concept that never went anywhere. It doesn't work with newer versions of FlexSim, and we have no intention of updating it or supporting it.

If you want to communicate with FlexSim, I suggest using the FlexSim Web Server.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Charlie avatar image Charlie commented ·

Thank you so much for the clarification..... :)

Although i was low key hoping there was a way to get it done because in my personal experience being able to exploit the vast features of excel through CATIA and vice versa was pretty neat.

0 Likes 0 ·