Hide Table of Contents

Create Compound Note Example (VBA)

This example shows how to create a compound note in a drawing document.

'----------------------------------------------------------
' Preconditions:
' 1. Open public_documents\samples\tutorial\api\2012-sm.slddrw.
' 2. Click the letter E in the drawing view.
'
' Postconditions:
' 1. Creates a compound note.
' 2. Click the compound note and drag it to a different
'    location in the drawing.
'
' NOTE: Because this drawing is used elsewhere, do not save
' changes.
'------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swDrawing As SldWorks.DrawingDoc
Dim swNote As SldWorks.note
Sub main()    
    Set swApp = CreateObject("SldWorks.Application")
    Set swModel = swApp.ActiveDoc
    Set swDrawing = swModel    
    ' Create the compound note
    makeCnote
End Sub
 
Sub makeCnote()
    Set swNote = swDrawing.CreateCompoundNote(0.00635, 0.05, 0.2, 0#)    
     ' Add text to note
     swNote.AddText "zero pt", 0, 0, 0
     swNote.AddText "top", 0.01, 0.01, 0    
     ' Prepare note for geometry
     swNote.BeginSketchEdit    
     ' Add geometry to note
     swDrawing.CreateLineVB 0, 0, 0, 0.01, 0.01, 0
     swDrawing.CreateCircleVB 0, 0, 0, 0.01414    
     ' Finish
     swNote.EndSketchEdit    
    ' Do some queries
    If (swNote.IsCompoundNote()) Then
        Dim count As Long
        Dim n2 As String
        Dim n1 As String
        Dim ht2 As Double
        ' If object is compound note
        ' Get number of text items
        count = swNote.GetTextCount()
        ' Get the second piece of text
        n2 = swNote.GetTextAtIndex(2)
        ' Get the first piece of text
        n1 = swNote.GetTextAtIndex(1)
        ' Get height of 2nd piece of text
        ht2 = swNote.GetHeightAtIndex(2)
    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:   Create Compound Note 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) 2019 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.