AnsweredAssumed Answered

Callout generated using API does not point to selected entity

Question asked by Tim Hattrell on Jun 13, 2017

I have a small routine, part of a larger macro. The intent of the routine is to mark an entity with a call out on the screen. When the callout is displayed, it doesn't point to the selected entity. Do I have to specify the coordinates of the callout leader? If yes, what is the best way to get the relevant coordinates for an entity, ie an edge, vertex or surface?

 

Private Sub selectEntityAndAddCallout(swEntity As SldWorks.Entity, ByVal sCalloutText As String)

        Dim swModel As SldWorks.ModelDoc2

        Dim swSelMgr As SldWorks.SelectionMgr

        Dim swSelData As SldWorks.SelectData

        Dim swCallout As SldWorks.Callout

        Dim callH As New SwCalloutHandlerClass

        Dim boolstatus As Boolean

       

        Set swModel = <code deleted>

        Set swSelMgr = swModel.SelectionManager

        Set swSelData = swSelMgr.CreateSelectData

       

        'Select entity

        Call swModel.ClearSelection2(True)

        boolstatus = swEntity.Select4(False, swSelData)

       

        'Display callout

        Set swCallout = swSelMgr.CreateCallout2(1, callH)

        boolstatus = swSelMgr.SetCallout(1, swCallout) 'TODO: need to make callout point to selected entity.

        swCallout.Label2(0) = sCalloutText

        swCallout.Value(0) = ""

        swCallout.MultipleLeaders = False

        swCallout.ValueInactive(0) = True

       

End Sub

Outcomes