原文地址:
http://adndevblog.typepad.com/manufacturing/2015/10/face-to-planarsketch.html
有时我们可能需要得到某个面Face的一些物理属性,例如转动惯量,这些由RegionProperties提供,但这个属性是Profile对象特有的。通过代码,可以由Face转换成一个 平面草图(PlanarSketch),通过草图的Profile拿到RegionProperties。
例如,假设有个矩形面,以下代码先通过该Face创建草图,接着把Face上的边一一投影到草图,形成Profile,最后拿到Profile的RegionProperties。
Sub SketchFromFace()
' Before running this code, select the face
' you want to create a sketch from
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oFace As Face
Set oFace = oDoc.SelectSet(1)
Dim oDef As PartComponentDefinition
Set oDef = oDoc.ComponentDefinition
Dim oSketch As PlanarSketch
Set oSketch = oDef.Sketches.Add(oFace)
Dim oEdge As Edge
For Each oEdge In oFace.Edges
Call oSketch.AddByProjectingEntity(oEdge)
Next
Dim oProfile As Profile
Set oProfile = oSketch.Profiles.AddForSolid()
Debug.Print "Area = " + Str(oProfile.RegionProperties.Area)
End Sub