By Adam Nagy
The code which is getting Region Properties information from a given sketch can be extended for Section Views as well. You just need to create a sketch on the Section View and project the curves from that view into the region:
Sub CreateSketchForSectionView() ' Select the section view in the UI first Dim oView As SectionDrawingView Set oView = ThisApplication.ActiveDocument.SelectSet(1) ' Create the sketch Dim oDSketch As DrawingSketch Set oDSketch = oView.sketches.Add() ' Fill it with the curves from the section view Call oDSketch.Edit Dim oCurve As DrawingCurve For Each oCurve In oView.DrawingCurves Dim oEntity As SketchEntity Set oEntity = oDSketch.AddByProjectingEntity(oCurve) Next Call oDSketch.ExitEdit ' Create a profile from the entities Dim oProfile As Profile Set oProfile = oDSketch.Profiles.AddForSolid() ' Get region properties Dim oRegionProps As RegionProperties Set oRegionProps = oProfile.RegionProperties ' Set the accuracy to medium. oRegionProps.Accuracy = AccuracyEnum.kMedium ' Display the region properties of the profile. Call MsgBox("Area: " & oRegionProps.Area) Call MsgBox("Perimeter: " & oRegionProps.Perimeter) Call MsgBox("Centroid: " & _ oRegionProps.Centroid.X & ", " & _ oRegionProps.Centroid.Y) Dim adPrincipalMoments(2) As Double Call oRegionProps.PrincipalMomentsOfInertia( _ adPrincipalMoments(0), _ adPrincipalMoments(1), _ adPrincipalMoments(2)) Call MsgBox("Principal Moments of Inertia: " & _ adPrincipalMoments(0) & ", " & _ adPrincipalMoments(1)) Dim adRadiusOfGyration(2) As Double Call oRegionProps.RadiusOfGyration( _ adRadiusOfGyration(0), _ adRadiusOfGyration(1), _ adRadiusOfGyration(2)) Call MsgBox("Radius of Gyration: " & _ adRadiusOfGyration(0) & ", " & _ adRadiusOfGyration(1)) Dim Ixx As Double Dim Iyy As Double Dim Izz As Double Dim Ixy As Double Dim Iyz As Double Dim Ixz As Double Call oRegionProps.MomentsOfInertia(Ixx, Iyy, Izz, Ixy, Iyz, Ixz) Call MsgBox(" Ixx: " & Ixx) Call MsgBox(" Iyy: " & Iyy) Call MsgBox(" Ixy: " & Ixy) Call MsgBox("Rotation Angle from projected Sketch " & _ "Origin to Principal Axes: " & _ Str(oRegionProps.RotationAngle)) End Sub