Cancel
Showing results for 
Search instead for 
Did you mean: 

Femap Class Module

Experimenter
Experimenter

Hello,

 

I am having trouble with the class modules in Femap.

 

In Excel, when I define a class module "CM_Nodes", and i then want to use it in my main sub, i put :

    Dim oNodes          As New CM_Nodes

Afterwards, when i writte "oNodes" in my sub, i get access to all the propreties.

 

However, in Femap, I define my class modules and save them (as .cls), i cannot use them :

 

class module.png

Play (F5)

API Error (Line 3): ActiveX Automation: server cannot create object.

Dim oNodes As New -->CM_Nodes

 

 

Am i missing a step to reference the class module in Femap? And if so, any tips on how to do it?

 

Thank you,

 

Regards,

Dor

4 REPLIES

Re: Femap Class Module

Legend
Legend

Hello Dor,

 

you should add your class to reference:

 

 

AddToReference_1.jpg

I think, unfortunatelly you can't choose CLS file to add to reference (but try it):

 

AddToReference_2.jpg

 

In this case you can make a class library with the free Visual Studio Express programm.

 

Best regards,

 

Peter Kaderasz

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Re: Femap Class Module

Experimenter
Experimenter

Thank you for your answer Peter.

 

If there is no way to link the class module (*.cls) to the main sub (*.bas), the whole class module on Femap seems pointless/useless. There must be a hidden way, or the dev would not have added it.

 

I can not add a class module (*.cls) file as a reference. I'll try to use the free Visual Studio Express programm to create and import the reference.

 

Thanks again,

 

Regards

Re: Femap Class Module

Siemens Genius Siemens Genius
Siemens Genius

Hi Dor,

 

In order to add a class module, you need to reference it using a "uses" statement. Consider the following class that I've created and saved in "class1.cls":

 

Public Class Class1
    Public Sub PrintMessage()
        MsgBox( "Hello World" )
    End Sub

End Class

In a separate file, you can reference said class using the "uses" statement:

 

'#uses "class1.cls"

Sub Main

    Dim myClass As New Class1

    myClass.PrintMessage()

End Sub

If you don't specify a path (relative or absolute) the class module just needs to be in the same directory as your basic program.

 

Run the program and....

 

 api_wnd.png

 

 Patrick

Re: Femap Class Module

Experimenter
Experimenter

Hello Patrick,

 

Many thanks for the solution. Works like a charm.

 

Have a nice day,

 

Regards