Hide Table of Contents

Get Silhouette Edge Example (VBA)

This example shows how to get the silhouette edge to which an annotation is attached in a drawing.

 

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

'

' Prerequisites: RealEdgeAsSilhouette.SLDDRW exists, and

'                an annotation is attached to a silhouette

'                edge in Drawing View2.

'

' Postconditions: The silhouette edge is selected, then

'                RealEdgeAsSilhouette.SLDDRW is closed.

'

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

Option Explicit

Sub main()

    

    Dim SwApp As SldWorks.SldWorks

    Dim swModel As SldWorks.ModelDoc2

    Dim SelMgr As SldWorks.SelectionMgr

    Dim MacroFolder As String

    Dim PartFolder As String

    Dim LongStatus As Long

    Dim LongWarnings As Long

    Dim BoolStatus As Boolean

    

    If SwApp Is Nothing Then Set SwApp = Application.SldWorks

 

    'Get folder paths

    MacroFolder = Left(SwApp.GetCurrentMacroPathName(), InStrRev(SwApp.GetCurrentMacroPathName(), "\"))

    PartFolder = MacroFolder

    

    'Set current eorking directory to the parts folder

    SwApp.SetCurrentWorkingDirectory PartFolder

    ' Open file

    Set swModel = SwApp.OpenDoc6("RealEdgeAsSilhouette.SLDDRW", SwConst.swDocumentTypes_e.swDocDRAWING, 0, "", LongStatus, LongWarnings)

    If swModel Is Nothing Then ErrorMsg SwApp, "Failed to open: ", True

 

    Dim drDoc As SldWorks.DrawingDoc

    Dim drView As SldWorks.View

    

    ' Activate the drawing view with the annotation

    Set drDoc = swModel

    BoolStatus = drDoc.ActivateView("Drawing View2")

    Set drView = drDoc.ActiveDrawingView

    

    Dim params

    Dim vobj

    Dim silEdge As SldWorks.SilhouetteEdge

    Dim drAnn As SldWorks.Annotation

    

    ' Get the annotation and any attached entities

    Set drAnn = drView.GetFirstNote.GetAnnotation

    params = drAnn.GetAttachedEntities3

    ' If the attached entity is a silhouette edge, then select it

    For Each vobj In params

        Set silEdge = vobj

        BoolStatus = silEdge.Select(False, Nothing)

    Next vobj

    'Close documents

    SwApp.CloseDoc swModel.GetTitle

    'Set objects to Nothing

    Set swModel = Nothing

        

End Sub

 

' Error function

Function ErrorMsg(SwApp As Object, Message As String, EndTest As Boolean)

    SwApp.SendMsgToUser2 Message, 0, 0

    SwApp.RecordLine "'*** WARNING - General"

    SwApp.RecordLine "'*** " & Message

    SwApp.RecordLine ""

    If EndTest Then

        SwApp.ExitApp

        End

    End If

End Function



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 Silhouette Edge 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) 2010 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.