Hide Table of Contents

Measure Selected Entities Example (VBA)

This example shows how to use the IMeasure APIs.

 

'****************************************************

'

' Preconditions: Model document is open and measurable objects

'                are selected.

'

' Postconditions: None.

'

'****************************************************

Option Explicit

 

Dim swApp As SldWorks.SldWorks

Dim Part As ModelDoc2

Dim Measure As Measure

Dim boolstatus As Boolean

 

Sub main()

 

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

Set Measure = Part.Extension.CreateMeasure

 

Measure.ArcOption = 0       'Can set this to 0, 1, or 2

                            ' 0 - Center to Center

                            ' 1 - Minimum Distance

                            ' 2 - Maximum Distance

Dim strDisplay As String

 

boolstatus = Measure.Calculate(Nothing)

If (boolstatus) Then

    If (Not (Measure.Length = -1)) Then

        Debug.Print "Length: " & Measure.Length

    End If

    

    If (Not (Measure.Area = -1)) Then

       Debug.Print "Area: " & Measure.Area

    End If

    

    

    If (Not (Measure.ArcLength = -1)) Then

        Debug.Print "Arc length: " & Measure.ArcLength

    End If

    

    If (Not (Measure.ChordLength = -1)) Then

       Debug.Print "Chord length: " & Measure.ChordLength

    End If

    

    If (Not (Measure.Diameter = -1)) Then

       Debug.Print "Diameter: " & Measure.Diameter

    End If

    

    If (Not (Measure.Radius = -1)) Then

        Debug.Print "Radius: " & Measure.Radius

    End If

 

    If (Not (Measure.Perimeter = -1)) Then

        Debug.Print "Perimeter: " & Measure.Perimeter

    End If

 

    If (Not (Measure.X = -1)) Then

        Debug.Print "X coordinate: " & Measure.X

    End If

    

    If (Not (Measure.Y = -1)) Then

        Debug.Print "Y coordinate: " & Measure.Y

    End If

    

    If (Not (Measure.Z = -1)) Then

        Debug.Print "Z coordinate: " & Measure.Z

    End If

    

    If (Not (Measure.DeltaX = -1)) Then

        Debug.Print "DeltaX: " & Measure.DeltaX

    End If

    

    If (Not (Measure.DeltaY = -1)) Then

        Debug.Print "DeltaY: " & Measure.DeltaY

    End If

 

    If (Not (Measure.DeltaZ = -1)) Then

        Debug.Print "DeltaZ: " & Measure.DeltaZ

    End If

 

    If (Not (Measure.Angle = -1)) Then

        Debug.Print "Angle: " & Measure.Angle

    End If

 

    If (Not (Measure.CenterDistance = -1)) Then

        Debug.Print "Center distance: " & Measure.CenterDistance

    End If

    

    If (Not (Measure.NormalDistance = -1)) Then

        Debug.Print "Normal distance: " & Measure.NormalDistance

    End If

    

    If (Not (Measure.Distance = -1)) Then

        Debug.Print "Distance: " & Measure.Distance

    End If

    

    If (Not (Measure.TotalLength = -1)) Then

        Debug.Print "Total length: " & Measure.TotalLength

    End If

    

    If (Not (Measure.TotalArea = -1)) Then

        Debug.Print "Total Area : " & Measure.TotalArea

    End If

    If (Measure.IsParallel) Then

        Debug.Print "IsParallel : " & Measure.IsParallel

    End If

    

    If (Measure.IsIntersect) Then

        Debug.Print "Is Intersect : " & Measure.IsIntersect

    End If

 

    If (Measure.IsPerpendicular = -1) Then

        Debug.Print "Is Perpendicular : " & Measure.IsPerpendicular

    End If

    

    If (Not (Measure.Projection = -1)) Then

        Debug.Print "Projection : " & Measure.Projection

    End If

 

    If (Not (Measure.Normal = -1)) Then

        Debug.Print "Normal : " & Measure.Normal

    End If

 

    If (Not (Measure.SpericalCenterDistance = -1)) Then

        Debug.Print "Sperical Center Distance : " & Measure.SpericalCenterDistance

    End If

    

    If (Measure.IsConcentricSpheres) Then

        Debug.Print "Is Concentric Spheres : " & Measure.IsConcentricSpheres

    End If

Else

    Debug.Print "Invalid combination of selected entities."

End If

    

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:   Measure Selected Entities 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) 2014 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.