I've attached some code that displays the total length of all loops on the
top face of the flat pattern. The code assumes that the active document
contains a flat pattern. The sub uses a function (GetTopFaceOfFlat) to get
the top face of the flat pattern. You can also select the desired face via
the UI and use that instead.
However, there is a caveat that you need to be aware of. This sub should
work fine in cases except where the outer profile has silhoutte edges,
chamfers, etc. This code assumes that the outer edge loop of the top face
matches the outer profile that you might see in the DXF output. This is not
always true. As I mentioned earlier, if the outer profile contains chamfers,
etc., this code will not provide the correct values. So make sure to test
various situations to decide if this will work for you.
Sanjay-
Sub GetTotalLength()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oFace As Face
'Set oFace = oDoc.SelectSet(1)
Set oFace = GetTopFaceOfFlat
Dim TotalLength As Double
TotalLength = 0
Dim oEdge As Edge
For Each oEdge In oFace.Edges
Dim oEvaluator As CurveEvaluator
Set oEvaluator = oEdge.Evaluator
Dim minparam As Double
Dim maxparam As Double
Call oEvaluator.GetParamExtents(minparam, maxparam)
Dim length As Double
Call oEvaluator.GetLengthAtParam(minparam, maxparam, length)
TotalLength = TotalLength + length
Next
MsgBox "Total length of all loops on face: " & TotalLength & " cms"
End Sub
Function GetTopFaceOfFlat() As Face
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oDef As SheetMetalComponentDefinition
Set oDef = oDoc.ComponentDefinition
'Assumes that the flat has been created
Dim oFlatPattern As FlatPattern
Set oFlatPattern = oDef.FlatPattern
Dim oFace As Face
For Each oFace In oFlatPattern.Body.Faces
' Only interested in planar faces
If oFace.SurfaceType = kPlaneSurface Then
Dim oPlane As Plane
Set oPlane = oFace.Geometry
Dim oZAxis As UnitVector
Set oZAxis =
ThisApplication.TransientGeometry.CreateUnitVector(0, 0, 1)
' Only interested in faces that have z-direction normal
If oPlane.Normal.IsParallelTo(oZAxis) Then
' Look for the face with Z = 0
If oPlane.RootPoint.Z <= 0.0000001 Then
Set GetTopFaceOfFlat = oFace
Exit For
End If
End If
End If
Next
End Function
wrote in message news:5331048@discussion.autodesk.com...
Correct that is exactly what I want I just want to be able to put it to a
custom iprop or something so I can get it into my idw. Thanks for the quick
response