Hide Table of Contents

Get Temporary Axes in Each Drawing View Example (VBA)

This example shows how to get the temporary axes in each drawing view and convert them to lines.

 

'-------------------------------------------------

'

' Preconditions: Drawing document is open with at least

'                one view of a model with at least one temporary axis.

'

' Postconditions: Temporary axes converted to lines.

'

'-------------------------------------------------

Option Explicit

 

Dim swApp As SldWorks.SldWorks

Dim swDrawDoc As SldWorks.DrawingDoc

Dim swSelMgr As SldWorks.SelectionMgr

Dim swView As SldWorks.View

Dim pline As SldWorks.SketchSegment

Dim itr As Long

 

Sub main()

    

    Set swApp = Application.SldWorks

    Set swDrawDoc = swApp.ActiveDoc

    Set swSelMgr = swDrawDoc.SelectionManager

    ' Iterate through the views

    Set swView = swDrawDoc.GetFirstView

    

    While Not swView Is Nothing

    

        If Not swView.Type = swDrawingSheet Then

        

            Debug.Print swView.GetName2

            swDrawDoc.ActivateView swView.GetName2

                    

            Dim nCount As Long, vTempAxesPoints As Variant, nJump As Long

            ' Get number of temporary axes

            nCount = swView.GetTemporaryAxesCount

            Debug.Print " Number of temporary axes = " & nCount

            

            nJump = 6

  ' Get temporary axes

            vTempAxesPoints = swView.GetTemporaryAxes

            

            For itr = 0 To nCount - 1

            

                Dim startPt(2) As Double

                Dim endPt(2) As Double

            

                startPt(0) = vTempAxesPoints(nJump * itr)

                startPt(1) = vTempAxesPoints(nJump * itr + 1)

                startPt(2) = vTempAxesPoints(nJump * itr + 2)

                

                endPt(0) = vTempAxesPoints(nJump * itr + 3)

                endPt(1) = vTempAxesPoints(nJump * itr + 4)

                endPt(2) = vTempAxesPoints(nJump * itr + 5)

                

                Debug.Print "   Temporary axis " & itr; " data :"

                Debug.Print "     start : x = " & startPt(0)

                Debug.Print "             y = " & startPt(1)

                Debug.Print "             z = " & startPt(2)

                Debug.Print "     end   : x = " & endPt(0)

                Debug.Print "             y = " & endPt(1)

                Debug.Print "             z = " & endPt(2)

                

' Convert temporary axes to line

                Set pline = swDrawDoc.CreateLine2(startPt(0), startPt(1), startPt(2), endPt(0), endPt(1), endPt(2))

    

                If Not pline Is Nothing Then

                    

                    ' Color

                    Dim clr As Long

                    clr = swApp.GetUserPreferenceIntegerValue(swSystemColorsConstructionGeometry)

                    pline.Color = clr

                    ' Width

                    pline.Width = swLW_NORMAL

                    ' Style ( only an approximation )

                    pline.Style = swLineCHAIN

                    

                End If

            Next itr

            

        End If

        ' Get next view

        Set swView = swView.GetNextView

    Wend

    

    swDrawDoc.ClearSelection2 True

    

End Sub



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Get Temporary Axes in Each Drawing View Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2016 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.