Hide Table of Contents

Display Grid Bubble Example (VBA)

This example shows how to set the text of ordinate dimensions and display a grid bubble at the end of each ordinate dimension extension line.

'--------------------------------------------------------------------
' Preconditions: Open public_documents\samples\tutorial\api\2012-sm.slddrw.
'
' Postconditions:
' 1. Creates ordinate dimensions.
' 2. Selects the ordinate dimensions.
' 3. Sets the text of the ordinate dimensions to B and displays
'    a grid bubble at the end of each ordinate dimension's extension 
'    line.
' 4. Examine the drawing.
'
' NOTE: Because the drawing is used elsewhere, do not save changes.
'--------------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModelDoc As SldWorks.ModelDoc2
Dim swDrawingDoc As SldWorks.DrawingDoc
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swDisplayDim As SldWorks.DisplayDimension
Dim boolstatus As Boolean
Dim error As Long
Dim selType As Long
Dim i As Long
Sub SelectDimensions()
boolstatus = swModelDocExt.SelectByID2("D1@Sketch3@2012-sm.SLDDRW", "DIMENSION", 8.77948412666479E-02, 0.282838220689655, 0, False, 0, Nothing, 0)
boolstatus = swModelDocExt.SelectByID2("D2@Sketch3@2012-sm.SLDDRW", "DIMENSION", 0.100748137818372, 0.284091765517241, 0, True, 0, Nothing, 0)
boolstatus = swModelDocExt.SelectByID2("D3@Sketch3@2012-sm.SLDDRW", "DIMENSION", 0.115372827473544, 0.283256068965517, 0, True, 0, Nothing, 0)
End Sub
Sub main()
    Set swApp = Application.SldWorks
    Set swModelDoc = swApp.ActiveDoc
    Set swDrawingDoc = swModelDoc
    Set swModelDocExt = swModelDoc.Extension
    
    'Add ordinate dimensions
    boolstatus = swDrawingDoc.ActivateView("Drawing View1")
    boolstatus = swModelDocExt.SelectByID2("", "VERTEX", 8.69591447149237E-02, 0.257349475858578, -499.97349537912, False, 0, Nothing, 0)
    boolstatus = swModelDocExt.SelectByID2("", "VERTEX", 0.101583834370096, 0.256931627582716, -499.97349537912, True, 0, Nothing, 0)
    boolstatus = swModelDocExt.SelectByID2("", "VERTEX", 0.114954979197682, 0.256931627582716, -499.97349537912, True, 0, Nothing, 0)
    error = swModelDocExt.AddOrdinateDimension(swAddOrdinateDims_e.swHorizontalOrdinate, 8.65412964390616E-02, 0.280748979310345, 0)   
    'Select the ordinate dimensions
    Set swSelMgr = swModelDoc.SelectionManager
    Call SelectDimensions
    'Change dimension values to letter B and
    'add grid bubble at end of extension lines
    Dim selCount As Long
    selCount = swSelMgr.GetSelectedObjectCount
    For i = 1 To selCount
        selType = swSelMgr.GetSelectedObjectType2(i)
        If selType = swSelDIMENSIONS Then
            Set swDisplayDim = swSelMgr.GetSelectedObject6(i, -1)
            swDisplayDim.SetText swDimensionTextAll, "B"
            swDisplayDim.GridBubble = True
        End If
    Next i
    swModelDoc.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:   Display Grid Bubble 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) 2018 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.