Cancel
Showing results for 
Search instead for 
Did you mean: 

API Bar Offsets - Updating Reference Point and Offset Values

Creator
Creator

I have a model that I import into Femap from a bdf text file. The Bar properties do not contain information for the reference point location and dimensions for the shape. I am trying to establish where the reference point is on the section and have the reference Y and Z dimensions update accordingly through an API script. I then want to move the Bar element offset to the reference point. My problem is I haven't been able to yet using the API.

bar-prop.png

By default on the import the property Reference Point Location is set to 1 and the Reference Y and Z coordinates are both 0 (verified using the API script below). When I open the Femap gui for updating the property shape, the reference point location as 1 and provides the Reference Point position (H,V). I assume it is only calculated for the properties window in the gui. Clicking OK here in the property shape gui does not actually update the property shape values. To actually update the shape you must check the Change Shape option then click OK. I have lots of properties and this isn't an option (well it is, but there must be a better way). Then if I change the Reference Point in the API, the Reference Y and Z don't get updated. You can test it out using the script below.

So here is what I've been working with so far as an example.

Bar Model

$ Femap Property 1 : Steel Bar
PBARL          1       1 MSCBML0     BAR                                +
+           0.08     1.0      0.
$ Femap Material 1 : 2024-T351 Al Plate .25-.5
MAT1           1  1.07+7             .332.5906-4 1.255-5     70.        +       
+         42000.  40000.  38000.
MAT4           1.0016435  83.0762.5906-4                        
GRID           1       0      1.      0.      0.       0
GRID           2       0     10.      0.      0.       0
GRID           3       0      1.      0.      0.       0
GRID           4       0      4.      0.      0.       0
GRID           5       0      7.      0.      0.       0
GRID           6       0     10.      0.      0.       0
CBAR           1       1       3       4      0.      1.      0.
CBAR           2       1       4       5      0.      1.      0.
CBAR           3       1       5       6      0.      1.      0.

API Script

 api-propertyVals.png

Sub Main
	' This script updates beam and bar elements reference orientation
	'  points.

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

	Dim elSet As femap.Set
	Set elSet = App.feSet
    Dim prSet As femap.Set
	Set prSet = App.feSet
	Dim bmrulset As femap.Set
	Set bmrulset = App.feSet
	Dim bmset As femap.Set
	Set bmset = App.feSet

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

    Dim shpdims(6) As Double

	If elSet.Select( FT_ELEM, True, "Select Beams to Define Reference Point" ) <> FE_OK Then
		End
	End If

    ' Add beam and bar type rules to a set
	bmrulset.AddRule(FET_L_BEAM,FGD_ELEM_BYTYPE)
	bmrulset.AddRule(FET_L_BAR,FGD_ELEM_BYTYPE)

	' combine common elements from each set to a new BEAM and BAR set
	bmset.AddCommon(elSet.ID,bmrulset.ID)

    prSet.AddSetRule(bmset.ID, FGD_PROP_ONELEM)

    While prSet.Next()

        Prop.Get( prSet.CurrentID )
        If Prop.flagI(2) <> 0 Then
            shpdims(0) = Prop.pval(40)
            shpdims(1) = Prop.pval(41)
            shpdims(2) = Prop.pval(42)
            shpdims(3) = Prop.pval(43)
            shpdims(4) = Prop.pval(44)
            shpdims(5) = Prop.pval(45)

            App.feAppMessage( FCM_NORMAL, "Property ID " & Str(Prop.ID))
            App.feAppMessage( FCM_NORMAL, "Ref Point " & Str(Prop.pval(51)))
            App.feAppMessage( FCM_NORMAL, "Ref Y " & Str(Prop.pval(52)))
            App.feAppMessage( FCM_NORMAL, "Ref Z " & Str(Prop.pval(53)))
            Prop.pval(51) = 7   ' Trying to move the ref point here from default
            rc = Prop.ComputeStdShape(Prop.flagI(1), shpdims, Prop.pval(50), Prop.flagI(2), True, True, True)
            Prop.Put( prSet.CurrentID )
            App.feAppMessage( FCM_NORMAL, "Ref Point " & Str(Prop.pval(51)))
            App.feAppMessage( FCM_NORMAL, "Ref Y " & Str(Prop.pval(52)))
            App.feAppMessage( FCM_NORMAL, "Ref Z " & Str(Prop.pval(53)))
        End If

    Wend
    
    App.feModifyOffsetsToRefPt(elSet.ID)
    
End Sub

 

1 REPLY

Re: API Bar Offsets - Updating Reference Point and Offset Values

Siemens Phenom Siemens Phenom
Siemens Phenom

It looks like you will have to manually set the H and V values.  From what I can infer, the call "Prop.pval(51) = 7" is accurately changing that property array value, but has no bearing on "...(52) or ...(53)".

 

Since you are already getting the dimensions of your bar, you could do something like the API below:

 


Sub Main
    ' This script updates beam and bar elements reference orientation
    '  points.

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

    Dim elSet As femap.Set
    Set elSet = App.feSet
    Dim prSet As femap.Set
    Set prSet = App.feSet
    Dim bmrulset As femap.Set
    Set bmrulset = App.feSet
    Dim bmset As femap.Set
    Set bmset = App.feSet

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

    Dim shpdims(6) As Double

    If elSet.Select( FT_ELEM, True, "Select Beams to Define Reference Point" ) <> FE_OK Then
        End
    End If

    ' Add beam and bar type rules to a set
    bmrulset.AddRule(FET_L_BEAM,FGD_ELEM_BYTYPE)
    bmrulset.AddRule(FET_L_BAR,FGD_ELEM_BYTYPE)

    ' combine common elements from each set to a new BEAM and BAR set
    bmset.AddCommon(elSet.ID,bmrulset.ID)

    prSet.AddSetRule(bmset.ID, FGD_PROP_ONELEM)

    While prSet.Next()

        Prop.Get( prSet.CurrentID )
        If Prop.flagI(2) <> 0 Then
            shpdims(0) = Prop.pval(40)
            shpdims(1) = Prop.pval(41)
            shpdims(2) = Prop.pval(42)
            shpdims(3) = Prop.pval(43)
            shpdims(4) = Prop.pval(44)
            shpdims(5) = Prop.pval(45)

            App.feAppMessage( FCM_NORMAL, "Property ID " & Str(Prop.ID))
            App.feAppMessage( FCM_NORMAL, "Ref Point " & Str(Prop.pval(51)))
            App.feAppMessage( FCM_NORMAL, "Ref Y " & Str(Prop.pval(52)))
            App.feAppMessage( FCM_NORMAL, "Ref Z " & Str(Prop.pval(53)))

            Prop.pval(51) = 7.0   ' Trying to move the ref point here from default
'****************************************************************************************************************
' Manually set H and V values to some location on dimensions of bar
            Prop.pval(52) = shpdims(0)
            Prop.pval(53) =  shpdims(1)
'****************************************************************************************************************

            rc = Prop.ComputeStdShape(Prop.flagI(1), shpdims, Prop.pval(50), Prop.flagI(2), True, True, True)

            Prop.Put( prSet.CurrentID )

            App.feAppMessage( FCM_NORMAL, "Ref Point " & Str(Prop.pval(51)))
            App.feAppMessage( FCM_NORMAL, "Ref Y " & Str(Prop.pval(52)))
            App.feAppMessage( FCM_NORMAL, "Ref Z " & Str(Prop.pval(53)))
        End If

    Wend

    rc = App.feModifyOffsetsToRefPt(elSet.ID)
    App.feViewRegenerate(0)

End Sub