Cancel
Showing results for 
Search instead for 
Did you mean: 

setting mesh attributes on surfaces using an API

Pioneer
Pioneer

Good Day

 

I require some assistance, I would like yto create an API to mesh attributes to surfaces below I have a very simple code using surface IDs and Prop IDs. Is it possible to to use a group ID and Prop ID instead of a surface ID, reason being with models that have a large number of surfaces it would be easier to use group ID as these surfaces would be allocated into groups. If so can someone please provide me with an example code ?

 

Thanks in advance.

 

The HTML Clipboard

Sub Main

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

    App.feMeshAttrSurface(-8, 1, 0)
    App.feMeshAttrSurface(-5, 2, 0)
    App.feMeshAttrSurface(-4, 3, 0)
    App.feMeshAttrSurface(-6, 3, 0)
    App.feMeshAttrSurface(-7, 4, 0)
    App.feMeshAttrSurface(-1, 5, 0)
    App.feMeshAttrSurface(-2, 6, 0)
    App.feMeshAttrSurface(-3, 6, 0)

End Sub

2 REPLIES

Re: setting mesh attributes on surfaces using an API

Siemens Phenom Siemens Phenom
Siemens Phenom

You can populate the surfaces in a group into a set, and then assign the mesh attibutes as below in the sample API script that prompts for both a Group ID and Property ID (and also checks for validity).  You can populate a set using the app.feset.addgroup method.

 


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

    Dim rc As femap.zReturnCode

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

    Dim meshProp As femap.Prop
    Set meshProp = App.feProp
    Dim propID As Long
    Dim offset As Double
    offset = 0.0

    Dim grID As Long

    SelectGroupWithSurfaces:
    rc = App.feSet.SelectID ( FT_GROUP, "Select Group to Assign Mesh Attributes", grID )
    If rc = FE_CANCEL Then
        End
    End If

    surfSet.AddGroup ( FT_SURFACE, grID )
    If surfSet.Count = 0 Then
        App.feAppMessage ( FCM_ERROR, "No Surfaces in the Selected Group" )
        GoTo SelectGroupWithSurfaces
    End If

    SelectMeshAttributeProperty:
    rc = App.feSet.SelectID ( FT_PROP, "Select Property to Assign as the Mesh Attribute", propID )
    If rc = FE_CANCEL Then
        End
    End If
    'Check to see if the Property is a 2D (Surface) Element Property
    meshProp.Get ( propID )
    If meshProp.type < 11 Or meshProp.type > 22 Then
        meshProp.Put ( propID )
        App.feAppMessageBox ( 1, "Mesh Property Must Be a 2D (Surface) Element Property" )
        If rc = FE_CANCEL Then
            End
        End If
    Else
        meshProp.Put ( propID )
    End If

    'Assign the Mesh Property to the Surfaces
    rc = App.feMeshAttrSurface ( surfSet.ID, propID, offset )
    App.feAppMessage ( FCM_COMMAND, ("rc =" + Str$(rc)) )
    GoTo SelectGroupWithSurfaces

    App.feViewRegenerate ( 0 )
    
End Sub
 

 

Best Regards,
Chip Fricke
Principal Applications Engineer - Femap Product Development

Re: setting mesh attributes on surfaces using an API

Pioneer
Pioneer

Thanks! Helps a lot.