Reply

Callout Annotation using VB.Net

Hello All,

 

How to add Callout Annotation to a Drawing View for Bend Lines.

I am to get the number of bend lines present in the Drawing View.

 

I have saved the Callout Text as "%BN%BO" (Bend Angle, Bend Direction).

But how to add it to the bend lines using VB.Net.

 

Please find the attached image which tells what is exactly required.

 

Thanks

Shruthi

6 REPLIES

Re: Callout Annotation using VB.Net

The following code should create a callout attached to the midpoint of each bend line in the first drawing view of the active sheet:

'----------------------------------------------------------------------
' DFT: Create a callout on all bend lines in the first drawing view
'----------------------------------------------------------------------
Dim objDoc As SolidEdgeDraft.DraftDocument = objApp.ActiveDocument
Dim objSheet As SolidEdgeDraft.Sheet = objDoc.ActiveSheet
Dim objView As SolidEdgeDraft.DrawingView = objSheet.DrawingViews.Item(1)
Dim objBalloons As SolidEdgeFrameworkSupport.Balloons = objSheet.Balloons
Dim objBall As SolidEdgeFrameworkSupport.Balloon = Nothing
Dim x, y, z As Double
Dim objTerminator As Object = Nothing
Dim keyPoint As Boolean
Dim kpt As SolidEdgeFramework.KeyPointType
Dim hnd As Integer

objApp.ScreenUpdating = False

For Each objDVLine As SolidEdgeDraft.DVLine2d In objView.DVLines2d
  ' Check, if it is a bend line
  If objDVLine.BendQuantity > 0 Then
    ' Get the coordinates of the bend line's midpoint (0=start, 1=end, 2=middle)
    objDVLine.GetKeyPoint(2, x, y, z, kpt, hnd)
    objView.ViewToSheet(x, y, x, y)
    ' Create the callout
    objBall = objBalloons.AddByTerminator(objDVLine.Reference, x, y, z, True)
    objBall.GetTerminator(objTerminator, x, y, z, keyPoint)
    objBall.AddVertex(x + 0.03, y + 0.02, z)
    objBall.TextScale = 1.0
    objBall.BalloonText = "%BN%BO"
    objBall.Leader = True
    objBall.BreakLine = True
  End If
Next

objApp.ScreenUpdating = True
Dim objWin As SheetWindow = objApp.ActiveWindow
objWin.Update()

 

Re: Callout Annotation using VB.Net

Wow! That's really helpful! Thanks.

I was searching for a way to write a code on button click which calls the callout function with the text "%BN%BO", then click on the desired (bend)line to display. But this is so much better!

Must say, don't understand the part where you get the coordinates and place the leader there, but put the code behind a button click event and it works.

 

Have one question / desired modification; How can i modify the code so that i first click the button, and then choose the drawing view.

Even better: that the code always searches for a flat pattern drawing view, and executes on that view. If there isn't one, it gives a message box information.

 

Thanks in advance!

Re: Callout Annotation using VB.Net

The MouseEvents sample on GitHub will show you how to pick things like a drawing view. Specifically, the seLocateDrawingView filter and seLocateQuickPick locate mode should work. Regarding the flat pattern drawing view, I would imagine you can interrogate the selected drawing view for that information.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Callout Annotation using VB.Net

If you want to click on the drawing view with the flattened model, checkout the sample mentioned by Jason Newell.

If you want to find this view automatically, then you will need to iterate through all drawing views and check, if its ModelMember is flat. The updated code follows below. It only checks the active sheet, if you need to run your script on a whole draft document with multiple sheets, just wrap an iteration through all sheets around the code.

'----------------------------------------------------------------------
' DFT: Create a callout on all bend lines in the drawing view with a flattened model
'----------------------------------------------------------------------
Dim objDoc As SolidEdgeDraft.DraftDocument = objApp.ActiveDocument
Dim objSheet As SolidEdgeDraft.Sheet = objDoc.ActiveSheet

' Avoid screen updating (flickering) while adding the callouts
objApp.ScreenUpdating = False

' Iterate through all drawing views on the active sheet
For Each objView As SolidEdgeDraft.DrawingView In objSheet.DrawingViews

  ' Check if the displayed sheetmetal model in this view is flattened
  If objView.ModelMembers.Item(1).IsFlat Then

    Dim objBalloons As SolidEdgeFrameworkSupport.Balloons = objSheet.Balloons
    Dim objBall As SolidEdgeFrameworkSupport.Balloon = Nothing
    Dim x, y, z As Double
    Dim objTerminator As Object = Nothing
    Dim keyPoint As Boolean
    Dim kpt As SolidEdgeFramework.KeyPointType
    Dim hnd As Integer

    For Each objDVLine As SolidEdgeDraft.DVLine2d In objView.DVLines2d
      ' Check, if it is a bend line
      If objDVLine.BendQuantity > 0 Then
        ' Get the coordinates of the bend line's midpoint (0=start, 1=end, 2=middle)
        objDVLine.GetKeyPoint(2, x, y, z, kpt, hnd)
        objView.ViewToSheet(x, y, x, y)
        ' Create the callout
        objBall = objBalloons.AddByTerminator(objDVLine.Reference, x, y, z, True)
        objBall.GetTerminator(objTerminator, x, y, z, keyPoint)
        objBall.AddVertex(x + 0.03, y + 0.02, z)
        objBall.TextScale = 1.0
        objBall.BalloonText = "%BN%BO"
        objBall.Leader = True
        objBall.BreakLine = True
      End If
    Next
  End If
Next

objApp.ScreenUpdating = True
Dim objWin As SheetWindow = objApp.ActiveWindow
objWin.Update()

Re: Callout Annotation using VB.Net

[ Edited ]

Again, really helpful! Thanks Jason and Martin.

Was trying to put the drawing views in a for loop, but missed the line 

objView.ModelMembers.Item(1).IsFlat

 

In my case it is enough to only iterate through the drawing views in the active sheet.

Now when i click the button, regardless of the number of views, it will only add bendline annotations to the flat pattern.

That's exactly what i meant to do!

Re: Callout Annotation using VB.Net

Hi...I am able to insert callout..but I want to change it's style....

Make Text style as Underline or text position as above.

 

When I set this property in coding it won't reflect in Solide Edge Drawing...

 

Please suggest...