Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

API: Update NASTRAN Tube Dimensions

Pioneer
Pioneer

Hello,

 

I'm trying write a code that will update the dimensions (DIM1, DIM2) of NASTRAN Tube properties based on a user-selected set of properties and input values. My code is working to update the DIM1 and DIM2 values but the geometric properties (i.e. Area, Izz, Iyy, etc. ) are NOT updating accordingly. Those values only update if I manually edit the property and click the "Change Shape" box. Any ideas on how to force femap to automatically update the geometric property values of the beam?

 

Thank you,

Sams

 

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

    'Have user select beam properties'
    Dim pSet As femap.Set
    Set pSet = App.feSet

    rc = pSet.Select( femap.zDataType.FT_PROP, True, "Select Beam Properties" )
    If rc <> femap.zReturnCode.FE_OK Then Exit Sub

    Dim pDIM1 As Double
    Dim pDIM2 As Double

    rc = App.feGetReal ( "Enter Outer Radius value for NASTRAN Tube Property", 0, 1e8, pDIM1 )
    If rc <> femap.zReturnCode.FE_OK Then Exit Sub

    rc = App.feGetReal ( "Enter Inner Radius value for NASTRAN Tube Property", 0, 1e8, pDIM2 )
    If rc <> femap.zReturnCode.FE_OK Then Exit Sub

    Dim pTube As femap.Prop
    Set pTube = App.feProp

    Dim tubeProps As Variant

    Dim PropID As Long

    PropID = pSet.First( )

    Dim i As Long

    While PropID <> 0
    	rc = pTube.Get( PropID )
    	If pTube.type = femap.zElementType.FET_L_BEAM Then
    		tubeProps = pTube.pmat
    		tubeProps( 40 ) = pDIM1
    		tubeProps( 41 ) = pDIM2
    		i = i + 1
    	End If
    	pTube.pmat = tubeProps
    	rc = pTube.Put ( PropID)
    	pTube.ComputeStdShape( FSHP_NAS_TUBE, ,FSOR_RIGHT, FSEV_PBEAML, False, False, False)


    	PropID = pSet.Next( )

    Wend

    App.feAppMessage( FCM_NORMAL, " " )
    App.feAppMessage( FCM_WARNING, "Outer radius set to: " &pDIM1 )
    App.feAppMessage( FCM_WARNING, "Inner radius set to: " &pDIM2 )
    App.feAppMessage( FCM_NORMAL, "for " & i & " NASTRAN tube properties")
    App.feAppMessage( FCM_NORMAL, "API beam update complete" )

End Sub
4 REPLIES 4

Re: API: Update NASTRAN Tube Dimensions

Siemens Phenom Siemens Phenom
Siemens Phenom

Try this. I think the problem was that you need the ComputeStdShape before the .Put. Also your call for ComputeStdShape was missing the second argument. So above I created a variant and added DIM1 and DIM2 into it. You had some things with tubeProps.pmat which I think you meant to be .vpval. 

 

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

    'Have user select beam properties'
    Dim pSet As femap.Set
    Set pSet = App.feSet

    rc = pSet.Select( femap.zDataType.FT_PROP, True, "Select Beam Properties" )
    If rc <> femap.zReturnCode.FE_OK Then Exit Sub

    Dim pDIM1 As Double
    Dim pDIM2 As Double

    rc = App.feGetReal ( "Enter Outer Radius value for NASTRAN Tube Property", 0, 1e8, pDIM1 )
    If rc <> femap.zReturnCode.FE_OK Then Exit Sub

    rc = App.feGetReal ( "Enter Inner Radius value for NASTRAN Tube Property", 0, 1e8, pDIM2 )
    If rc <> femap.zReturnCode.FE_OK Then Exit Sub

    Dim pTube As femap.Prop
    Set pTube = App.feProp

    Dim tubeProps As Variant

    ''''Added variant for second argument in ComputeStdShape
    Dim vpDim(5) As Variant
    vpDim(0) = pDIM1
    vpDim(1) = pDIM2

    Dim PropID As Long

    PropID = pSet.First( )

    Dim i As Long

    While PropID <> 0
        rc = pTube.Get( PropID )
        If pTube.type = femap.zElementType.FET_L_BEAM Then
            tubeProps = pTube.vpval
            tubeProps( 40 ) = pDIM1
            tubeProps( 41 ) = pDIM2
            i = i + 1
        End If

        ''''Changed ComputeStdShape before .Put and added second argument
        rc = pTube.ComputeStdShape(FSHP_NAS_TUBE, vpDim,FSOR_RIGHT,FSEV_PBEAML,False,False,False)
        rc = pTube.Put ( PropID)

        PropID = pSet.Next( )

    Wend

    App.feAppMessage( FCM_NORMAL, " " )
    App.feAppMessage( FCM_WARNING, "Outer radius set to: " &pDIM1 )
    App.feAppMessage( FCM_WARNING, "Inner radius set to: " &pDIM2 )
    App.feAppMessage( FCM_NORMAL, "for " & i & " NASTRAN tube properties")
    App.feAppMessage( FCM_NORMAL, "API beam update complete" )

End Sub

Re: API: Update NASTRAN Tube Dimensions

Siemens Phenom Siemens Phenom
Siemens Phenom

The previous post is correct.  You always need to make all changes prior to doing the "Put"... otherwise you are just changing the API object and not the actual model.  Also, you can never skip arguments in API calls. In this case, using ComputeStdShape(...) it doesn't matter what you have the object property dimensions set or updated to...the call is always going to update them to whatever dimensions are passed in the second argument.

Re: API: Update NASTRAN Tube Dimensions

Pioneer
Pioneer

T_Giampietro,

 

Thank you so much for posting and explaining the solution! I really appreciate your help and have learned a few things!

 

-Sams

Re: API: Update NASTRAN Tube Dimensions

Pioneer
Pioneer
grudy,

Thank you so much for explaining the details of T_Giampietro's solution. I appreciate the reply!

-Sams