How to add two leader to single balloon in inventor drawing using inventor API

How to add two leader to single balloon in inventor drawing using inventor API

umesh.mhaskar
Contributor Contributor
2,636 Views
2 Replies
Message 1 of 3

How to add two leader to single balloon in inventor drawing using inventor API

umesh.mhaskar
Contributor
Contributor

Dear All,

              Anyone help me to add multiple leader to ballon using inventor api.

 

Regards,

Umesh Mhaskar

0 Likes
Accepted solutions (1)
2,637 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor
Programming help within Inventor has examples. I suggest starting there and playing with that until you get stuck.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 3

umesh.mhaskar
Contributor
Contributor
Accepted solution

Dim ThisApplication as inventor.Application

ThisApplication=GetObject(", Inventor.Application")

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

' Set a reference to the active sheet.
Dim oActiveSheet As Sheet
oActiveSheet = oDrawDoc.ActiveSheet

' Set a reference to the drawing curve segment.
' This assumes that a drwaing curve is selected.
Dim oDrawingCurveSegment1 As DrawingCurveSegment
oDrawingCurveSegment1 = oDrawDoc.SelectSet.Item(1)

' Set a reference to the drawing curve.
Dim oDrawingCurve1 As DrawingCurve
oDrawingCurve1 = oDrawingCurveSegment1.Parent

' Get the mid point of the selected curve
' assuming that the selection curve is linear
Dim oMidPoint As Point2d
oMidPoint = oDrawingCurve1.MidPoint


Dim oDrawingCurveSegment2 As DrawingCurveSegment
oDrawingCurveSegment2 = oDrawDoc.SelectSet.Item(2)

' Set a reference to the drawing curve.
Dim oDrawingCurve2 As DrawingCurve
oDrawingCurve2 = oDrawingCurveSegment2.Parent


' Set a reference to the TransientGeometry object.
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

Dim oLeaderPoints As ObjectCollection
oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection
If IsNothing(oPoint) Then
oPoint = oTG.CreatePoint2d(oMidPoint.X + 5, oMidPoint.Y + 5)
End If

' Create a couple of leader points.
Call oLeaderPoints.Add(oPoint)

' Add the GeometryIntent to the leader points collection.
' This is the geometry that the balloon will attach to.
Dim oGeometryIntent As GeometryIntent
oGeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve1)
Call oLeaderPoints.Add(oGeometryIntent)

' Set a reference to the parent drawing view of the selected curve
Dim oDrawingView As DrawingView
oDrawingView = oDrawingCurve1.Parent

' Set a reference to the referenced model document
Dim oModelDoc As Document
oModelDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument

' Check if a partslist or a balloon has already been created for this model
Dim IsDrawingBOMDefined As Boolean
IsDrawingBOMDefined = oDrawDoc.DrawingBOMs.IsDrawingBOMDefined(oModelDoc.FullFileName)

Dim oBalloon As Balloon
oBalloon = oDrawDoc.ActiveSheet.Balloons.Add(oLeaderPoints)

Dim oGeometryIntent2 As GeometryIntent = _
oActiveSheet.CreateGeometryIntent( _
oDrawingCurve2, oDrawingCurve2.MidPoint)

Dim oLeaderPoints2 As ObjectCollection = _
ThisApplication.TransientObjects. _
CreateObjectCollection

oLeaderPoints2.Add(oGeometryIntent2)

' add a new leader if the leader note has no leader,
' otherwise add a branch leader
If oBalloon.Leader.HasRootNode Then
' add a branch leader based on the root node
oBalloon.Leader.RootNode.AddLeader(oLeaderPoints2)
Else
' add a new leader when
'LeaderNote.Leader.HasRootNode = False
oBalloon.Leader.AddLeader(oLeaderPoints2)
End If

Dim oDrawingBOMRow As DrawingBOMRow
oDrawingBOMRow = oBalloon.BalloonValueSets(1).ReferencedRow

oBalloon.BalloonValueSets.Add(oDrawingBOMRow)
oBalloon.BalloonValueSets(2).OverrideValue = "2x"

0 Likes