Find All Curves on a Drawing View that Corresponds to Bend Center Lines in the Referenced Flat Pattern

By Barbara Han

Issue

I want to find all drawing curves that correspond to bend center lines in the referenced flat pattern. Is there a easy way to do this? After I have the drawing curve collection, I will make two collections out of it. One has to contain all the horizontal bend center lines and the other collection has to contain all the vertical bend center lines…

Solution

Below is a VB.NET sample that obtain all the curves on a particular drawing view that correspond to bend center lines in the referenced flat pattern and highlighting those curves. After you get those curves, you then can use DrawingCurveSegment object, which has StartPoint and EndPoint properties, to get horizontal and vertical bend lines.

Assumptions of the sample code:

  1. Drawing is active.
  2. The first drawing view in the active drawing is the view of a flat pattern.

Public Sub BendLinesInDrawings()

 

  Dim oDrawing As DrawingDocument

  oDrawing = m_inApp.ActiveDocument

 

  Dim oDrawingView As DrawingView

  oDrawingView = oDrawing.ActiveSheet.DrawingViews.Item(1)

 

  Dim oPartDoc As PartDocument

  oPartDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument

  Dim oFlatPattern As FlatPattern

  oFlatPattern = oPartDoc.ComponentDefinition.FlatPattern

 

  Dim oBendUpEdges As Edges

  oBendUpEdges = oFlatPattern.GetEdgesOfType(

    FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge)

 

  Dim oBendDownEdges As Edges

  oBendDownEdges = oFlatPattern.GetEdgesOfType(

    FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge)

 

  ‘ Collect up all bend edges

  Dim oBendEdges As ObjectCollection

  oBendEdges = m_inApp.TransientObjects.CreateObjectCollection

  Dim oEdge As Edge

  For Each oEdge In oBendUpEdges

    oBendEdges.Add(oEdge)

  Next

 

  For Each oEdge In oBendDownEdges

    oBendEdges.Add(oEdge)

  Next

  Dim oHighlight As HighlightSet = m_inApp.ActiveDocument.CreateHighlightSet

  Dim oRed As Color

  oRed = m_inApp.TransientObjects.CreateColor(255, 0, 0)

  oHighlight.Color = oRed

  For Each oEdge In oBendEdges

    Dim oDrawingCurves As DrawingCurvesEnumerator

 

    oDrawingCurves = oDrawingView.DrawingCurves(oEdge)

 

    Dim oCurve As DrawingCurve

    For Each oCurve In oDrawingCurves

      Dim oSegment As DrawingCurveSegment

      For Each oSegment In oCurve.Segments

        oHighlight.AddItem(oSegment)

      Next

    Next

  Next

End Sub


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading