How Do i Get a Drawing curve from a edge to balloon with

How Do i Get a Drawing curve from a edge to balloon with

davidt162003
Advocate Advocate
538 Views
6 Replies
Message 1 of 7

How Do i Get a Drawing curve from a edge to balloon with

davidt162003
Advocate
Advocate

Im trying to get the top edge of the nozzle to always be the point where the arrow of the balloon is placed. But for some reason its just not doing it, i think i manged ti create the geometry intent correctly but it still docent seem to work. im coding in VB.net 

    

  Dim EdgeAttribute = PartDoc.AttributeManager.FindObjects(, , attributeName)
  Dim Edge As Edge = EdgeAttribute(1)
  Return Edge
Dim Proxy As EdgeProxy
    pOcc.CreateGeometryProxy(Edge, Proxy)
    PointCollection.add(Sheet.CreateGeometryIntent(ViewToBallon.DrawingCurves(Proxy)))

Catch ex As Exception

End Try

If PointCollection.Count < 2 then
PointCollection.Add(Sheet.CreateGeometryIntent(DrawCurve))
End If



Dim Balloon = Sheet.Balloons.Add(PointCollection)

Dim BalloonVal = Split(pOcc.Name, ":").First
Balloon.BalloonValueSets(1).Value = BalloonVal

BalloonList.Add(Balloon)
HII
0 Likes
539 Views
6 Replies
Replies (6)
Message 2 of 7

bradeneuropeArthur
Mentor
Mentor

Could you share the complete code for testing?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
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:
My 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 !


 


EESignature

0 Likes
Message 3 of 7

davidt162003
Advocate
Advocate

Yeah sure 

Here is the creation of the attribute. I know this works as im able to see the created attribute in the attribute manager.

 

  Friend Sub AddAttributeToEdge(Edge As Edge, AttributeName As String, AttributeValue As String)
      ' Create a new attribute set for the edge
      Dim oAttributeSet As AttributeSet
      oAttributeSet = Edge.AttributeSets.Add("AttributeSet")
      ' Add a new attribute to the attribute set
      Dim oAttribute As Inventor.Attribute
      oAttribute = oAttributeSet.Add(AttributeName, ValueTypeEnum.kStringType, AttributeValue)
  End Sub

 

 This section is in a for loop where pOcc is a component occurence, View to balloon is a drawing view.

The view should be the view of an assembly in which  you can see the edge of the part document which has the attribute on. Ive edited the code slightly to make it easier to test. 

 

friend sub(ViewToBalloon as drawingview,_App as inventor.application,PartDoc as partdocument)  
   Dim BalloonList As New List(Of Balloon)
   Dim Sheet = ViewToBallon.Parent
   Dim DrawDoc As DrawingDocument = Sheet.Parent   
   Dim DrawCurves = ViewToBallon.DrawingCurves(pOcc)
       Dim DrawCurve = DrawCurves(1)
       Dim midpnt As Point2d

       midpnt = TryCast(DrawCurve.CenterPoint, Point2d)
       If midpnt Is Nothing Then midpnt = TryCast(DrawCurve.MidPoint, Point2d)
       If midpnt Is Nothing Then midpnt = GetiPoint2D(0, 0, _App)
       Dim PointCollection As ObjectCollection = _App.TransientObjects.CreateObjectCollection
       PointCollection.Add(midpnt)
       Try
           'Dim PartDoc = TryGetPart(pOcc._DisplayName.Split(":").First, _App) implement your own part doc here 

           Dim Edge = EdgeFromAttribute(PartDoc, "BalloonPoint")
           Dim Proxy As EdgeProxy
           pOcc.CreateGeometryProxy(Edge, Proxy)
           PointCollection.add(Sheet.CreateGeometryIntent(ViewToBallon.DrawingCurves(Proxy)))

       Catch ex As Exception

       End Try

       If PointCollection.Count < 2 then
       PointCollection.Add(Sheet.CreateGeometryIntent(DrawCurve))
       End If



       Dim Balloon = Sheet.Balloons.Add(PointCollection)'this is where it throws a error 

       Dim BalloonVal = Split(pOcc.Name, ":").First
       Balloon.BalloonValueSets(1).Value = BalloonVal

       BalloonList.Add(Balloon)
end sub
 Friend Function EdgeFromAttribute(PartDoc As PartDocument, attributeName As String)
     Dim EdgeAttribute = PartDoc.AttributeManager.FindObjects(, , attributeName)
     Dim Edge As Edge = EdgeAttribute(1)
     Return Edge
 End Function

 

 It might also be worth mentioning that the attribute i was trying to test was attached to the top circular face of a cylinder, Shown below. Also Also because of where it throws a error which is when i actually try add the balloon i think for some reason my geometry intent is invalid.

davidt162003_0-1705570638657.pngdavidt162003_1-1705570668688.png

ive checked in the debugger and 

 

HII
0 Likes
Message 4 of 7

FINET_Laurent
Advisor
Advisor

Hello @davidt162003,

 

Uhm I didn't go through all of your code. Just to clarify few things here is a sample code of mine that will create a balloon  on the specified edge. The structure will be : a drawing view of a part that is placed inside an assembly.

 

1. I would create a nozzle part with an attribute  on an edge to look for later on :

Dim e As Inventor.Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Pick an edge")

Dim ast As Inventor.AttributeSet = e.AttributeSets.Add("newSet")
ast.Add("newAtt", ValueTypeEnum.kStringType, "target")

2. On the drawing sheet I would get the desired view,

3. Loops through all the curves,

4. Skip if the curve is not made from an edge. Note that we are looking for edges proxies since we are working with assembly documents.

5. For each edge proxy we find, get the native edge,

6. Look for the attribute inside the native edge's attributes set,

7. If we have a match, get the current curve inside an object,

8. Exit the iteration,

9. Create a geometry intent of the curve,

10. bla bla bla,

 

Sample code to demonstrate :

Dim doc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
Dim s As Inventor.Sheet = doc.ActiveSheet

Dim nozzleView As Inventor.DrawingView = s.DrawingViews.Item(1)
Dim targetCurve As Inventor.DrawingCurve = Nothing

For Each c As Inventor.DrawingCurve In nozzleView.DrawingCurves
	If c.ModelGeometry.type <> ObjectTypeEnum.kEdgeProxyObject Then Continue For
	Dim e As Inventor.EdgeProxy = c.ModelGeometry
	Dim nativeE As Inventor.Edge = e.NativeObject
	
	If nativeE.AttributeSets.NameIsUsed("newSet") = True Then 
		targetCurve = c
		Exit For
		
	End If
Next	

If targetCurve Is Nothing Then
	MsgBox("Could not find target")
	Exit Sub

End If

Dim curveIntent As Inventor.GeometryIntent = s.CreateGeometryIntent(targetCurve)

Dim points As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

points.Add(ThisApplication.TransientGeometry.CreatePoint2d(targetCurve.CenterPoint.X - 5  , targetCurve.CenterPoint.Y + 1 ))
points.Add(curveIntent)

Dim newBaloon As Inventor.Balloon = s.Balloons.Add(points)

 

Result :

FINET_Laurent_0-1705580005544.png

 

I would probably have a look at this : Inventor 2023 Help | Balloons.Add Method | Autodesk 

Especialy for the points you have to reference.

 

And maybe this whould also be useful : Inventor 2023 Help | Proxies | Autodesk

 

I attached sample files for the demo.

 

Kind regards,

FINET L.

 

 

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 5 of 7

FINET_Laurent
Advisor
Advisor

@davidt162003,

 

Secondly, I would also avoid not specifying the object type time when declaring a variable. Unclear information also sometimes throws exceptions. 

       Dim Balloon = Sheet.Balloons.Add(PointCollection)'this is where it throws a error 
       Dim BalloonVal = Split(pOcc.Name, ":").First

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 6 of 7

FINET_Laurent
Advisor
Advisor

@davidt162003,

 

Thridly, after reading, I guess it would be possible to also use your function to get the edge object you want, and compare it with the edge referenced by the curve in the iteration. It is just another way around. There is actualy many ways to acomplish this task.

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 7 of 7

davidt162003
Advocate
Advocate

Hi Thank you for all the help 

I've actually managed to solve my problem By moving the leader point to a center-point(Generated from a work point proxy on the part) it keeps the geometry intent in my original method Ie just the first line it finds but then moves it. But ill definitely give your method a try as my current version Makes my leader a dot rather than a arrow presumably because of the differing Geometry intent.

HII
0 Likes