原文地址:
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
本文介绍了一种方法,即如何从三维模型中的一个矩形面(Face)创建一个平面草图(PlanarSketch),并进一步获取该草图的物理属性如面积等。通过VBA代码实现将选定的Face转换为草图,并将其边界投影到草图中,最后通过Profile对象调用RegionProperties方法获得所需属性。
1万+

被折叠的 条评论
为什么被折叠?



