Cancel
Showing results for 
Search instead for 
Did you mean: 

How to correctly connect created load (loadgeom) to load definition through API

Creator
Creator

I am trying to add a load to a given load definition in my model. The new load definition appears in the model tree, but when I right click -> Edit Load, the edit definition event is triggered, but no dialog box appears. I am guessing I am incorrectly putting the data back into the model, or forgetting to put a certain entity.

 

My code:

 

Femap.loadGeom lg;
load = femap.feLoadGeom;
Femap.LoadDefinition ld;
loadDef = femap.feLoadDefinition;

load.ID = load.CountSet() + 1;

load.x = ##; // repeat for Y and Z

load.type = femap.zLoadType.FLT_SNFORCE;
load.geomTYPE = femap.zDataType.FT_SURFACE;
loadDef.title = 'titleA';
loadDef.loadType = load.type;
loadDef.dataType = load.geomTYPE;
loadDef.ID = loadDef.CountSet() + 1;

load.geomID = 23;

// Puts load into Other Loads -> On Geometry
load.Put(load.ID);

// Adds load definition under Load Definitions
loadDef.Put(loadDef.ID);


femap.feAppUpdatePanes(true);

How do I get the load data to be put into the model under load definitions and not Other Loads?

6 REPLIES

Re: How to correctly connect created load (loadgeom) to load definition through API

Siemens Phenom Siemens Phenom
Siemens Phenom

I would create the Load Definition first, and then create loads that reference that Load Definition -

 

The HTML Clipboard

Sub Main
    Dim App As femap.model
    Set App = feFemap()
    Dim load As femap.LoadGeom
    Set load = App.feLoadGeom
    Dim loadDef As femap.LoadDefinition
    Set loadDef = App.feLoadDefinition

    'Create the Load Definition First
    loadDef.title = "API Title"
    loadDef.loadType = FLT_SNFORCE
    loadDef.dataType = FT_SURF_LOAD
    loadDef.setID = App.Info_ActiveID(FT_LOAD_DIR )
    ' Save it
    loadDef.Put( loadDef.NextEmptyID )

    'Create the load
    load.x = 1.0
    load.y = 2.0
    load.z = 3.0

    load.type = FLT_SNFORCE
    load.geomTYPE = FT_SURFACE
    load.geomID = 2
    load.setID = App.Info_ActiveID( FT_LOAD_DIR )
    ' Now hook it to the Load Definition
    load.LoadDefinitionID = loadDef.ID
    'Save It
    load.Put( load.NextEmptyID )

    App.feAppUpdatePanes( True )

    
End Sub

 

Re: How to correctly connect created load (loadgeom) to load definition through API

Creator
Creator
I thought that might be the issue, but switching the order does not solve the problem.

Re: How to correctly connect created load (loadgeom) to load definition through API

Siemens Phenom Siemens Phenom
Siemens Phenom

The total code piece that I sent does work, create a block, so that you have Surface 2, then create an empty load set and run it, it creates a single definition containing the single load.  Your code has several issues that might be the problem -

 

load.ID = load.CountSet() + 1; - I would not set the ID of anything to a fixed number, there could be something there already, .CountSet returns the number of these items in the database, not necessarily the highest one, this ID could be an existing entity, use -

 

load.ID = load.NextEmptyID();

 

The same for 

 

loadDef.ID = loadDef.CountSet() + 1;

loadDef.ID = loadDef.GetNextEmptyID();

 

Both your feLoadGeom and feLoadDefinition must reference a Load Set, you will need to create one in your API, or in FEMAP, and then hook it up, in my VB Code -

 

loadDef.setID = App.Info_ActiveID(FT_LOAD_DIR )

and

load.setID = App.Info_ActiveID( FT_LOAD_DIR )

 

You also never set up a connection from the Load Defintion from the Load - you will need -


load.LoadDefinitionID = loadDef.ID 'VB

 

 

 

 

 

 

Re: How to correctly connect created load (loadgeom) to load definition through API

Creator
Creator

Sorry, when I set it didn't work I meant it didn't work after applying the load definition ID. Attached is a shot of my model tree prior to doing anything. It has a load set defined (ID = 1).

 

 

Here is my code:
Femap.LoadGeom load;
load = femap.feLoadGeom;
Femap.LoadDefinition loadDef;
loadDeg = femap.feLoadDefinition;

loadDef.title = "Test";
loadDef.loadType = Femap.zLoadType.FLT_SNFORCE;
loadDef.dataType = Femap.zDataType.FT_SURF_LOAD;
loadDef.setID = 1;
loadDef.Put(loadDef.NextEmptyID());

load.ID = load.NextEmptyID();
load.setID = 1;
load.x = 1000;
load.y = 500;
load.z = 0;
load.type = Femap.zLoadType.FLT_SNFORCE;
load.geomTYPE = Femap.zDataType.FT_SURFACE;
load.geomID = 23;
load.LoadDefinitionID = loadDef.ID;

load.Put(load.ID);

femap.feAppUpdatePanes(true);

 

 

So it is the same as yours as far as I can tell, other than the load set ID. I am setting it to 1 because the load set is already created and known. geomID = 23 is a known surface, one of the sides of my box. If I assign setID through getInfo_ActiveID as you did the issue still exists.

 

 

A second attachment shows the model tree after running the above. The load definition is there in LoadSet 1, but if I right click > edit load, no dialog box appears. Although the edit load dialog box doesn't appear, the main viewer panel DOES update with the visualization of the load vectors on the surface). I need to be able to edit the load and edit it after creating it.

Re: How to correctly connect created load (loadgeom) to load definition through API

Siemens Phenom Siemens Phenom
Siemens Phenom

Sorry, I missed this one too -

 

loadDef.dataType = Femap.zDataType.FT_GEOM_LOAD;

Re: How to correctly connect created load (loadgeom) to load definition through API

Creator
Creator

Hi All,

 

I was trying the same from inside excel, and found I had to make a few changes to the above.

 

Please see my code below:

 

Sub Button3_Click()

'create an object called App and set this object equal to the current femap session
Dim App As Object
Set App = GetObject(, "femap.model")

Dim Load As Object
Set Load = App.feLoadGeom

Dim LoadDef As Object
Set LoadDef = App.feLoadDefinition

LoadDef.Title = "Test"
LoadDef.loadtype = FLT_SNFORCE
LoadDef.DataType = FT_GEOM_LOAD
LoadDef.setID = 1
LoadDef.ID = LoadDef.NextEmptyID

LoadDef.Put (LoadDef.ID) ' Load Put Definition into FEMAP Session

Dim Fx As Double
Dim Fy As Double
Dim Fz As Double

Fx = 100
Fy = 200
Fz = 300

Load.Type = FLT_SNFORCE
Load.geomID = 1
Load.csys = 0
Load.geomtype = FT_SURFACE
Load.setID = 1
Load.Load(0) = Fx
Load.Load(1) = Fy
Load.Load(2) = Fz
Load.LoadDefinitionID = LoadDef.ID
Load.XOn = True
Load.YOn = True
Load.ZOn = True

Load.Put (Load.NextEmptyID)

App.feViewRegenerate (0)
App.feAppUpdatePanes (True)

End Sub

 

Also import to reference the FEMAP type library (see FEMAP API Reference section 3.1.3).