Get Drawing Curves for a Drawing View

By Wayne Brill

The DrawingCurves property of a DrawingView returns an Enumerator which is a collection DrawingCurve objects in the  DrawingView.

Here are VBA and VB.NET examples that iterate through all the views on the active sheet and print the type of DrawingCurve in the immediate window.

VBA

Sub DrawingCuves()
 
    Dim oDrawDoc As DrawingDocument
    Dim count As Integer
    Dim oSheet As Sheet
    Dim oDrawView As DrawingView
 
    Set oDrawDoc = ThisApplication.ActiveDocument
    Set oSheet = oDrawDoc.ActiveSheet
             
    For Each oDrawView In oSheet.DrawingViews
   
        Debug.Print "View Name: " & oDrawView.Name
       
        Dim oDrawViewCurves As DrawingCurvesEnumerator
        Set oDrawViewCurves = oDrawView.DrawingCurves()
        Debug.Print "No: Entities in the view: " & _
                                                 oDrawViewCurves.count
       
        Dim oCircularCurve As DrawingCurve
        For count = 1 To oDrawViewCurves.count
            Set oCircularCurve = oDrawViewCurves. _
                                                                  Item(count)
           Select Case oCircularCurve.CurveType
            Case 5121:
                Debug.Print "Unknown curve type."
            Case 5122:
                Debug.Print "Line curve."
            Case 5123:
                    Debug.Print "Line segment curve."
            Case 5124:
                Debug.Print "Circular curve."
            Case 5125:
                Debug.Print "Circular arc curve."
            Case 5126:
                Debug.Print "Ellipse full curve."
            Case 5127:
                Debug.Print "Elliptical arc curve."
            Case 5128:
                Debug.Print "B-spline curve."
           End Select
        Next
    Next
End Sub

VB.NET

Public Class Form1             Dim m_inventorApp As Inventor.Application _                                          = Nothing             Private Sub Button1_Click(ByVal sender As  _                                    System.Object, _                      ByVal e As System.EventArgs) _                            Handles Button1.Click                 ' Get an active instance of Inventor            Try                m_inventorApp = System.Runtime. _                       InteropServices.Marshal. _           GetActiveObject("Inventor.Application")                 Catch 'Inventor not started                System.Windows.Forms.MessageBox. _                 Show("Start an Inventor session")                Exit Sub            End Try                 'Call the Sub            DrawingCuves()        End Sub             Sub DrawingCuves()                 Dim oDrawDoc As DrawingDocument            Dim count As Integer            Dim oSheet As Sheet            Dim oDrawView As DrawingView                 oDrawDoc = m_inventorApp.ActiveDocument            oSheet = oDrawDoc.ActiveSheet                 For Each oDrawView In oSheet.DrawingViews                     Debug.Print("View Name: " _                                  & oDrawView.Name)                     Dim oDrawViewCurves As  _                             DrawingCurvesEnumerator                oDrawViewCurves = _                           oDrawView.DrawingCurves()                Debug.Print _                   ("No: Entities in the view: " & _                              oDrawViewCurves.Count)                     Dim oCircularCurve As DrawingCurve                For count = 1 To oDrawViewCurves.count                    oCircularCurve = oDrawViewCurves. _                                            Item(count)                    Select Case oCircularCurve.CurveType                        Case 5121                            Debug.Print _                                ("Unknown Curve type.")                        Case 5122                            Debug.Print("Line curve.")                        Case 5123                            Debug.Print _                                ("Line segment curve.")                        Case 5124                            Debug.Print("Circular curve.")                        Case 5125                            Debug.Print _                                ("Circular arc curve.")                        Case 5126                            Debug.Print _         &
#160;                      ("Ellipse full curve.")                        Case 5127                            Debug.Print _                                ("Elliptical arc curve.")                        Case 5128                            Debug.Print("B-spline curve.")                    End Select                Next            Next        End Sub    End Class

Comments

3 responses to “Get Drawing Curves for a Drawing View”

  1. This is very helpful. I was really on a problem on how to do the curving. I’m glad I found your blog.

  2. It is truly the solution for the long search with regards of my problem in curving.I owe this to you.God bless.

  3. Yes, me too I find this article very helpful in my research about drawing curves. This helps me alot. Thanks so much.

Leave a Reply to Mincy EnrightCancel reply

Discover more from Autodesk Developer Blog

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

Continue reading