<?xml encoding=”UTF-8″>By Adam Nagy
If you want to turn a Face into a PlanarSketch (e.g. in order to get RegionProperties for it) then the following should work.
Create a sketch based on the face, then project all the edges into it. Then you could create a Profile from it, which will of course have 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
Code in action – just select the face you are interested in:
Additional code for printing RegionProperties data:
http://adndevblog.typepad.com/manufacturing/2015/09/querying-a-sketch-profile-to-get-regions.html


Leave a Reply