Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Open Drawing from Balloon

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Curtis_Waguespack
295 Views, 6 Replies

Open Drawing from Balloon

A quick example of how to open a drawing from a balloon.

 

@harvey3ELEA 

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument

While True

	'select Balloon
	Dim oBalloon As Balloon = Nothing
	oBalloon = ThisApplication.CommandManager.Pick _
	(SelectionFilterEnum.kDrawingBalloonFilter, _
	"Select a balloon to open a it's drawing. " & " (press ESC To Exit selection)")

	If IsNothing(oBalloon) Then Exit While

	Dim oLeader As Leader
	If oBalloon IsNot Nothing Then oLeader = oBalloon.Leader

	Dim oLeaderNode As LeaderNode = oLeader.AllNodes(oLeader.AllNodes.Count)
	Dim oIntent As GeometryIntent = oLeaderNode.AttachedEntity
	Dim oCurve As DrawingCurve = oIntent.Geometry
	Dim oProxy As EdgeProxy = oCurve.ModelGeometry
	Dim oOcc As ComponentOccurrence = oProxy.ContainingOccurrence
	Dim oRefDoc As Document = oOcc.Definition.Document
	Dim oFilePath As String = oRefDoc.FullFileName()
	Dim oDrawingFilePath As String = Left(oFilePath, Len(oFilePath) -3) & "idw"

	Try
		oDrawDoc = ThisApplication.Documents.Open(oDrawingFilePath, True)
		Exit While
	Catch
		MsgBox("Could not open " & oDrawingFilePath, , "iLogic")
	End Try


End While

 

6 REPLIES 6
Message 2 of 7

Now that's nice!  I did notice, however, the code doesn't like balloons that are on tangent surfaces, such as a pipe.  When I move the balloon to the pipe's cut edge, it performs the task properly.

 

Here's what I see when clicking on a tangent-connected balloon:

 

harvey3ELEA_0-1715176355663.png

 

Message 3 of 7

@harvey3ELEA , good catch, see this updated version

 

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument

While True

	'select Balloon
	Dim oBalloon As Balloon = Nothing
	oBalloon = ThisApplication.CommandManager.Pick _
	(SelectionFilterEnum.kDrawingBalloonFilter, _
	"Select a balloon to open it's drawing. " & " (press ESC To Exit selection)")

	If IsNothing(oBalloon) Then Exit While

	Dim oLeader As Leader
	If oBalloon IsNot Nothing Then oLeader = oBalloon.Leader
	Dim oLeaderNode As LeaderNode = oLeader.AllNodes(oLeader.AllNodes.Count)
	Dim oIntent As GeometryIntent = oLeaderNode.AttachedEntity
	Dim oCurve As DrawingCurve = oIntent.Geometry
	Dim oOcc As ComponentOccurrence = oCurve.ModelGeometry.ContainingOccurrence
	Dim oRefDoc As Document = oOcc.Definition.Document
	Dim oFilePath As String = oRefDoc.FullFileName()
	Dim oDrawingFilePath As String = Left(oFilePath, Len(oFilePath) -3) & "idw"

	Try
		oDrawDoc = ThisApplication.Documents.Open(oDrawingFilePath, True)
		Exit While
	Catch
		MsgBox("Could not open " & oDrawingFilePath, , "iLogic")
	End Try

End While

 

Message 4 of 7

Success!  That did the trick.

 

The boss is impressed at how I'm now able to use Inventor drawings more effectively with you're recent codes.  His first comment:  why doesn't Inventor already have those built in?

 

Thanks, Harvey

Message 5 of 7
DMOTS1
in reply to: Curtis_Waguespack

Thanks everyone!

Message 6 of 7
DMOTS1
in reply to: harvey3ELEA

Thanks!

Message 7 of 7
DeptaM
in reply to: Curtis_Waguespack

Hello, thank you for this rule. It's absolutely great.

Martin

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report