Showing results for 
Search instead for 
Do you mean 
Solved! Go to solution

Converting to Wireframe for beam modeling


I have attached a parasolid file of a roll cage and am wondering what the best way is to convert it a wireframe model so I can mesh with beam elements. Any help would be appreciated.

Thank you

Accepted by topic author Surry99
a week ago

Re: Converting to Wireframe for beam modeling

I wrote this API that will find the centerlines of the straight tubes.  You will still have to do some trimming and extending, and also do the couple of curved pieces by hand.  We're working on some auto centerline code for FEMAP v11.4, and your part has given us some ideas, we'll try to get some of this inside FEMAP for the next release, here's the API for now, I hope it helps - the codes turns off the visibility of each solid it processes so you can see which ones got done.




The HTML Clipboard

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

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

    Dim radius As Double
    Dim baseVec As Variant
    Dim normVec As Variant
    Dim surfCG As Variant
    Dim cylCG As Variant
    Dim pt2(2) As Double

    Dim endA(2) As Double
    Dim endB(2) As Double

    Dim ctrPt As Variant

    Dim soSet As femap.Set
    Set soSet = App.feSet
    Dim cuSet As femap.Set
    Set cuSet = App.feSet

    Dim maxLength As Double
    maxLength = 0.0

    Dim feCurve As femap.Curve
    Set feCurve = App.feCurve

    Dim surfArea As Double
    Dim surfID As Long
    Dim feSolid As femap.Solid
    Set feSolid = App.feSolid
    Dim suSet As femap.Set
    Set suSet = App.feSet

    Dim cyl_suSet As femap.Set
    Set cyl_suSet = App.feSet
    Dim sArea As Double

    While feSolid.Next = FE_OK
        surfArea = 0.0
        surfID = 0
        suSet.AddRule( feSolid.ID, FGD_SURFACE_ONSOLID )
        While feSurf.NextInSet( suSet.ID) = FE_OK
            If feSurf.IsCylinder() = FE_OK Then
                feSurf.Area( sArea )
                If sArea > surfArea Then
                    surfID = feSurf.ID
                    surfArea = sArea
                End If
            End If
        If feSurf.Get( surfID ) = FE_OK Then
            If feSurf.IsCylinder() Then
                If feSurf.Cylindrical( radius, baseVec, normVec ) = FE_OK Then
                    If surfCG ) = FE_OK Then
                        App.feViewShow( FT_SURFACE, -feSurf.ID )
                        pt2(0) = baseVec(0) + normVec(0)
                        pt2(1) = baseVec(1) + normVec(1)
                        pt2(2) = baseVec(2) + normVec(2)
                        If App.feCoordOntoLine( surfCG, baseVec, pt2, cylCG ) = FE_OK Then
                            maxLength = 0.0
                            soSet.AddRule( feSurf.ID, FGD_SOLID_BYSURFACE )
                            cuSet.AddRule( soSet.First(), FGD_CURVE_ONSOLID )
                            While feCurve.NextInSet( cuSet.ID ) = FE_OK
                                If feCurve.Length() > maxLength Then
                                    maxLength = feCurve.Length()
                                End If
                            If maxLength > 0.0 Then
                                maxLength = maxLength / 2.0
                                endA(0) = cylCG(0) + maxLength * normVec(0)
                                endA(1) = cylCG(1) + maxLength * normVec(1)
                                endA(2) = cylCG(2) + maxLength * normVec(2)
                                endB(0) = cylCG(0) - maxLength * normVec(0)
                                endB(1) = cylCG(1) - maxLength * normVec(1)
                                endB(2) = cylCG(2) - maxLength * normVec(2)
                                App.feLinePoints( False, endA, endB, True )
                                App.feEntitySetVisibility( FVIS_SOLID, -soSet.First, False, True )

                            End If
                        End If
                    End If
                End If
            End If
        End If
End Sub

Re: Converting to Wireframe for beam modeling

Thank you very much.

Re: Converting to Wireframe for beam modeling

Dear Mark,

Great API code!, it runs OK, good job. As a suggestion to improve the PAI it should be great if the output centerlines to go automatically to a new layer named CENTERLINES. To generate the centerline for the curved tubes I suggest to use command "Geometry > Curve - Spline > Midspline", the result is the following:


Best regards,

Blas Molero Hidalgo, Ingeniero Industrial, Director
Blog Femap-NX Nastran: