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?
Solved! Go to Solution.
Solved by Balaji_Ram. Go to Solution.
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
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.