Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
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: 

Highlight Ballooned Assembly item Drawing View

2 REPLIES 2
Reply
Message 1 of 3
bradeneuropeArthur
221 Views, 2 Replies

Highlight Ballooned Assembly item Drawing View

How can I highlight a ballooned Assembly item in the drawing view, via coding?

bradeneuropeArthur_0-1699956566054.png

Like highlight the balloon selected in on the sheet.

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

2 REPLIES 2
Message 2 of 3

This sample is not ideal, but it can be a good starting point for your research.

Sub Main()
    Dim drawing As DrawingDocument = ThisDoc.Document

    Dim hSet As HighlightSet = drawing.CreateHighlightSet()

    Do
        Dim balloon As Balloon = ThisApplication.CommandManager.Pick(
            SelectionFilterEnum.kDrawingBalloonFilter,
            "Select balloon")

        hSet.Clear()

        If balloon Is Nothing Then Exit Do

        Dim drawingView As DrawingView = balloon.ParentView
        Dim refAsm As AssemblyDocument = drawingView.ReferencedDocumentDescriptor.ReferencedDocument

        For Each balloonValueSet As BalloonValueSet In balloon.BalloonValueSets
            For Each compDef As ComponentDefinition In balloonValueSet.ReferencedRow.BOMRow.ComponentDefinitions
                Dim occurrencesByComponentDefinition As ComponentOccurrencesEnumerator =
                        refAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(compDef)
                For Each occurrence As ComponentOccurrence In occurrencesByComponentDefinition
                    Dim occurrenceCurves As DrawingCurvesEnumerator = drawingView.DrawingCurves(occurrence)
                    For Each drawingCurve As DrawingCurve In occurrenceCurves
                        For Each drawingCurveSegment As DrawingCurveSegment In drawingCurve.Segments
                            hSet.AddItem(drawingCurveSegment)
                        Next
                    Next
                Next
            Next
        Next
    Loop

End Sub
Message 3 of 3

Hi @bradeneuropeArthur.  I agree that there is likely no really good, clean, error proof way to do this task.  I was about to tell you about the two different ways to approach this, but Michael beat me to an example the one way.  The other way is through the Leader, LeaderNodes, LeaderNode.AttachedEntity, and so on.  However, in a quick test on a couple test drawings of assemblies, I am not getting good results with that route either.  It has to do with the GeometryIntent and its type.  If it is a Geometry type, then we can usually dig deeper to get the model, but if it is a Point type or parameter type, no luck.  Plus, this route can be a long rabbit hole, unfortunately.

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
	Dim oDDoc As DrawingDocument = ThisDoc.Document
	Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
	Dim oBalloons As Inventor.Balloons = oSheet.Balloons
	If oBalloons.Count = 0 Then Return
	Dim oHLS As HighlightSet = oDDoc.CreateHighlightSet
	oHLS.Color = ThisApplication.TransientObjects.CreateColor(0, 255, 0) 'green
	For Each oBalloon As Inventor.Balloon In oBalloons
		oHLS.Clear
		If oBalloon.Attached = False Then Continue For
		Dim oView As DrawingView = oBalloon.ParentView
		Dim oLeader As Inventor.Leader = oBalloon.Leader
		If oLeader.HasRootNode = False Then Continue For
		Dim oNodes As LeaderNodesEnumerator = oLeader.AllNodes
		For Each oNode As LeaderNode In oNodes
			Dim oGI As GeometryIntent = Nothing
			Try : oGI = oNode.AttachedEntity : Catch : End Try
			If oGI Is Nothing Then Continue For
			Logger.Info("GeometryIntent.IntentType.ToString = " & oGI.IntentType.ToString)
			Logger.Info("GeometryIntent.Intent Type = " & TypeName(oGI.Intent))
			If oGI.IntentType = IntentTypeEnum.kGeometryIntent Then
				Dim oDGeom As Object = oGI.Geometry
				Logger.Info("GeometryIntent.Geometry Type = " & TypeName(oDGeom))
				If TypeOf oDGeom Is DrawingCurve Then
					Dim oDC As DrawingCurve = oDGeom
					Dim oMGeom As Object = Nothing
					Try : oMGeom = oDC.ModelGeometry : Catch : End Try
					If oMGeom Is Nothing Then Continue For
					If TypeOf oMGeom Is Edge Then
						Dim oEdge As Edge = oMGeom
						Dim oBody As SurfaceBody = oEdge.Parent
						Dim oOcc As ComponentOccurrence = Nothing
						If TypeOf oBody.Parent Is ComponentOccurrence Then
							oOcc = oBody.Parent
							Dim oDCs As DrawingCurvesEnumerator = Nothing
							Try : oDCs = oView.DrawingCurves(oOcc) : Catch : End Try
							If oDCs Is Nothing OrElse oDCs.Count = 0 Then Continue For
							For Each oDCurve As DrawingCurve In oDCs
								For Each oDCSeg As DrawingCurveSegment In oDCurve.Segments
									oHLS.AddItem(oDCSeg)
								Next
							Next
						End If
					End If
				End If
			End If
		Next 'oNode
		MsgBox("Review currently highlighted geometry for Ballooned Item # " & oBalloon.BalloonValueSets.Item(1).ItemNumber, , "iLogic")
	Next 'oBalloon
End Sub

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

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

Post to forums  

Autodesk Design & Make Report