.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Principal Moments of a region (or closed polyline)

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
R.Gerritsen4967
1008 Views, 2 Replies

Principal Moments of a region (or closed polyline)

Hi all,

 

I'm trying to calculate the principal moments (and section modulus) of a slection of closed polylines.

On this blog, I read that there are some new classes and functions in the AutoCad 2014 objectARX that can do this.

 

The one that interests me the most is 'RegionAreaProperties.PrincipalMoments Property'.

 

However with my limited programming skills, I can't get it to work in vb.net.

I thought is was just a property of a region, but something like 'myregion.RegionAreaProperties.PrincipalMoments' does not work.

With the code I already have I use a selectionfilter to select multiple closed polylines. I can convert these to regions if nescesary. But what is the next step? I can't find any samples of it. Not even in the Autodesk Developer's Guide.

 

Can anyone point me in the right direction? maybe a small example?

2 REPLIES 2
Message 2 of 3

Hi Gerritsen,

 

Here is a sample VB.Net code to determine the Moment of Inertial of a region about any axis and about its principal axes.

 

        <CommandMethod("Test")> _
        Public Sub TestMethod()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor

            Dim selectedObjectIds As New ObjectIdCollection()

            Dim peo As New PromptEntityOptions(vbLf & "Select a region :")
            peo.SetRejectMessage("Selection is not valid.")
            peo.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.Region), True)

            Dim per As PromptEntityResult = ed.GetEntity(peo)
            If per.Status <> PromptStatus.OK Then
                Return
            End If

            Dim ppo As New PromptPointOptions("Select axis origin point : ")
            Dim ppr As PromptPointResult = ed.GetPoint(ppo)
            If ppr.Status <> PromptStatus.OK Then
                Return
            End If
            Dim axisOrigin As Point3d = ppr.Value

            Dim ppo1 As New PromptPointOptions("Select X axis point : ")
            ppo1.BasePoint = axisOrigin
            Dim ppr1 As PromptPointResult = ed.GetPoint(ppo1)
            If ppr1.Status <> PromptStatus.OK Then
                Return
            End If

            Dim xAxis As Vector3d = (ppr1.Value - axisOrigin).GetNormal()
            Dim yAxis As Vector3d = xAxis.GetPerpendicularVector()

            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim region As Region = TryCast(tr.GetObject(per.ObjectId, OpenMode.ForRead), Region)
                Dim rap As RegionAreaProperties = region.AreaProperties(axisOrigin, xAxis, yAxis)
                Dim I As Vector2d = rap.MomentsOfInertia
                Dim Ip As Vector2d = rap.PrincipalMoments
                ed.WriteMessage("{0}Moments of Inertia Ia = {1} Ib = {2}", Environment.NewLine, I.X, I.Y)
                ed.WriteMessage("{0}Moments of Inertia about principal axes Ixx {1} Iyy = {2}", Environment.NewLine, Ip.X, Ip.Y)
                tr.Commit()
            End Using
        End Sub

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 3

@Balaji_Ram,

 

Thank you very much for this piece of code.

I've been playing around with your example, and I got it working within my own code.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost