cancel
Showing results for 
Search instead for 
Did you mean: 

API for creating load

Creator
Creator

Hi, I have a lot of surfaces (200-300) that i need to create elemental load definition for convection. 

 

So my idea is to create API to eliminate errors while defining convection parameters (200-300 times) and to speed up the process.

I created API that creates mesh loads. From mesh loads load definition can be made with right click On Mesh and Create Definition. Looking in the API documentation i could not find the way to do this or just Load Definition could be made from the beginning and avoiding this problem.

 

If somebody could direct me in right direction i would be very grateful.

Thank you in advance.

Milan

 

Sub Main
	Dim App As femap.model
    Set App = feFemap()

	Dim surfID As Long
	Dim surfSet As femap.Set
	Set surfSet = App.feSet

	Dim feSurf As femap.Surface
	Set feSurf = App.feSurface

	Dim LdSet As Long

	Dim elLoad As femap.LoadMesh
	Set elLoad = App.feLoadMesh

	LdSet = App.Info_ActiveID( FT_LOAD_DIR )

	surfID = 0

	rc = surfSet.SelectID( FT_SURFACE, "Izaberi povrsinu", surfID )

	If surfID > 0 Then

		rc = feSurf.Get( surfID )

		Dim nFaces As Long
		Dim eID As Variant
		Dim fID As Variant
		rc = feSurf.ElementFaces( False, True, False, nFaces, eID, fID )

		For i=0 To nFaces -1
			'Convection parameters
			pC = 10
			pCF = 1
			pT = 20
			pTF = 2

			elLoad.meshID = eID(i)
			elLoad.dof(0) = fID(i)
			elLoad.type = FLT_ECONVECTION

			elLoad.ConvectionCoeff = pC
			elLoad.LoadFunction = pCF
			elLoad.temp = pT
			elLoad.TempVsTime= pTF

			elLoad.setID = LdSet
			n = elLoad.NextEmptyID
			rc = elLoad.Put( elLoad.NextEmptyID )

		Next i
	End If
End Sub
2 REPLIES

Re: API for creating load

Siemens Phenom Siemens Phenom
Siemens Phenom

I modified your code to create a load definition for each surface that you select. The new code is bolded below. Basically you just declare the definition, setup its types, give it a title and save it. Then, when you create the load you assign the ID of the definition to the load.  

 

I used the surface ID as the ID of the definition. This probably isn't the best programming practice since it could overwrite any existing definitions that you had for other reasons. This would be simple to change by just declaring another variable, getting a nonexisting definition and tracking that thru to assign to the loads ... I'll let that to you if you need it to work that way. 

 

Hope this helps.

 

The HTML Clipboard

Sub Main
    Dim App As femap.model
    Set App = feFemap()

    Dim surfID As Long
    Dim surfSet As femap.Set
    Set surfSet = App.feSet

    Dim feSurf As femap.Surface
    Set feSurf = App.feSurface

    Dim LdSet As Long

    Dim elLoad As femap.LoadMesh
    Set elLoad = App.feLoadMesh

    Dim elLoadDef As femap.LoadDefinition
    Set elLoadDef = App.feLoadDefinition
    elLoadDef.loadType = FLT_ECONVECTION
    elLoadDef.dataType = FT_SURF_LOAD

    LdSet = App.Info_ActiveID( FT_LOAD_DIR )

    surfID = 0

    rc = surfSet.SelectID( FT_SURFACE, "Izaberi povrsinu", surfID )

    If surfID > 0 Then

        elLoadDef.title = "Convection on Surface " + Str$(surfID)
        elLoadDef.Put( surfID )

        rc = feSurf.Get( surfID )

        Dim nFaces As Long
        Dim eID As Variant
        Dim fID As Variant
        rc = feSurf.ElementFaces( False, True, False, nFaces, eID, fID )

        For i=0 To nFaces -1
            'Convection parameters
            pC = 10
            pCF = 1
            pT = 20
            pTF = 2

            elLoad.LoadDefinitionID = surfID
            elLoad.meshID = eID(i)
            elLoad.dof(0) = fID(i)
            elLoad.type = FLT_ECONVECTION

            elLoad.ConvectionCoeff = pC
            elLoad.LoadFunction = pCF
            elLoad.temp = pT
            elLoad.TempVsTime= pTF

            elLoad.setID = LdSet
            n = elLoad.NextEmptyID
            rc = elLoad.Put( elLoad.NextEmptyID )

        Next i
    End If
End Sub

Re: API for creating load

Creator
Creator

That's just what I needed. I'm just starting with API so i miss some of i guess basics. I'll be sure to go through some of already written API to figure out stuff like this.

Thank you a lot grudy, I'm really grateful.