Cancel
Showing results for 
Search instead for 
Did you mean: 

Find the vol and cg of a solid part using API

Creator
Creator

Hi,

i am kind anew to the API world, any help would be highly appreciated.

 

so far i have managed to make a solid body in which the code asks the user to input the length, bredth and height to make a cuboid.

now i want to slice the solid using a user defined plane and find the volume of the remaining solid.

once this is completed i want to slice the remaing solid using (say 10;number of planes inputed by the user) equidistant planes and find the volume and cg of each of these slices.

 

Version:1.0 StartHTML:091 EndHTML:000003499 StartFragment:246 EndFragment:000003460The HTML Clipboard

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

    Dim feCSys As femap.CSys
    Set feCSys = App.feCSys

    Dim l As Long
    Dim b As Long
    Dim h As Long

    rc = App.feGetInt("Length", 0,1000 , l)
    rc = App.feGetInt("Breadth", 0,1000 , b)
    rc = App.feGetInt("Height", 0,1000 , h)
    Dim size As Variant
    size = Array(l,b,h)
    Dim cs As Variant
    cs = Array(0,0,0)
    Dim Area As Long
    Dim vol1 As Long
    Dim CG As varient
    Dim Inertia As Variant

    Dim s As femap.Set
    Set s= App.feSet
    s.AddAll(FT_SOLID)
    Dim g As Group
    Set g = App.feGroup
    App.feSolidPrimitive(0, 1, True,cs,size, "tank 3d model")

    rc= feMeasureSolidmassProp(s.ID, Area, vol1, CG, Inertia)
    App.feAppMessage( FCM_NORMAL,Str$(vol1) )










End Sub

i cannot make the femeasuresolidmassprop to work. please provide some help

 

Kind regards

John

 

3 REPLIES

Re: Find the vol and cg of a solid part using API

Siemens Phenom Siemens Phenom
Siemens Phenom

The HTML Clipboard

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

    Dim feCSys As femap.CSys
    Set feCSys = App.feCSys

    Dim l As Long
    Dim b As Long
    Dim h As Long

    rc = App.feGetInt("Length", 0,1000 , l)
    rc = App.feGetInt("Breadth", 0,1000 , b)
    rc = App.feGetInt("Height", 0,1000 , h)
    Dim size As Variant
    size = Array(l,b,h)
    Dim cs As Variant
    cs = Array(0,0,0)
    Dim Area As Double
    Dim vol1 As Double
    Dim CG As Variant
    Dim Inertia As Variant

    Dim s As femap.Set
    Set s= App.feSet
    s.AddAll(FT_SOLID)
    Dim g As Group
    Set g = App.feGroup
    App.feSolidPrimitive(0, 1, True,cs,size, "tank 3d model")

    rc= App.feMeasureSolidMassProp(s.ID, Area, vol1, CG, Inertia)
    App.feAppMessage( FCM_NORMAL,Str$(vol1) )

End Sub

Here are some changes to your script. You needed Area and vol1 as Double because they are REAL8. Also you needed App. in front of feMeasureSolidMassProperties

Re: Find the vol and cg of a solid part using API

Creator
Creator

Hello, 

 

Thanks for the reply.

got it to work, but the output shows zero insted of the correct vol. how can i correct that? and could you please help me to use the solid slice option uisng a user defined plane

 

kind regards

john

Re: Find the vol and cg of a solid part using API

Siemens Phenom Siemens Phenom
Siemens Phenom

The HTML Clipboard

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

    Dim feCSys As femap.CSys
    Set feCSys = App.feCSys

    Dim pl As femap.Plane
    Set pl = App.fePlane

    Dim pBase As Variant
    Dim pNorm As Variant
    Dim pAx As Variant

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

    Dim sTrack As femap.TrackData
    Set sTrack = App.feTrackData

    Dim sID As Long

    Dim l As Long
    Dim b As Long
    Dim h As Long

    rc = App.feGetInt("Length", 0,1000 , l)
    rc = App.feGetInt("Breadth", 0,1000 , b)
    rc = App.feGetInt("Height", 0,1000 , h)
    Dim size As Variant
    size = Array(l,b,h)
    Dim cs As Variant
    cs = Array(0,0,0)
    Dim Area As Double
    Dim vol1 As Double
    Dim CG As Variant
    Dim Inertia As Variant


    Dim g As Group
    Set g = App.feGroup

    sTrack.Start(FT_SOLID)

    App.feSolidPrimitive(0, 1, True,cs,size, "tank 3d model")

    sTrack.Created(FT_SOLID, s.ID, True)

    sID = s.First

    rc= App.feMeasureSolidMassProp(sID, Area, vol1, CG, Inertia)
    App.feAppMessage( FCM_NORMAL,Str$(vol1) )

    App.feViewRegenerate(0)

    App.fePlanePick("Select Plane for Slice", pBase, pNorm, pAx)

    App.feSolidSlice(s.ID, pBase, pNorm, True)

End Sub

Try using this