Insert a note for a threaded hole in a drawing in Inventor using C# / VBA

Insert a note for a threaded hole in a drawing in Inventor using C# / VBA

vincenzobYFDD6
Explorer Explorer
203 Views
4 Replies
Message 1 of 5

Insert a note for a threaded hole in a drawing in Inventor using C# / VBA

vincenzobYFDD6
Explorer
Explorer

Good morning, is there a way to insert a thread note in Inventor via API? See image.sd

 

vincenzobYFDD6_1-1738757577842.png

 

0 Likes
204 Views
4 Replies
Replies (4)
Message 2 of 5

NachoShaw
Advisor
Advisor

Yes its possible.

NachitoMax_0-1738772985631.gif

 

this code assumes you have the note selected

    Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument

    If oDoc.SelectSet.Count <> 1 Then
        MsgBox ("A thread note must be selected.")
        Exit Sub
    End If

    If Not TypeOf oDoc.SelectSet(1) Is HoleThreadNote Then
        MsgBox ("A thread note must be selected.")
        Exit Sub
    End If

	Dim oThreadNote As HoleThreadNote = CType(oDoc.SelectSet(1), HoleThreadNote)
	oThreadNote.FormattedHoleThreadNote = "Thread Note Value Changed"

 

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 3 of 5

NachoShaw
Advisor
Advisor

and this one creates a thread note. Again, it assumes the thread is selected.

NachitoMax_0-1738773794077.gif

 

	Dim oApp As Inventor.Application = ThisApplication
    Dim oDoc As DrawingDocument = oApp.ActiveDocument

    If oDoc.SelectSet.Count <> 1 Then
        MsgBox ("A single thread edge must be selected.")
        Exit Sub
    End If

    If Not TypeOf oDoc.SelectSet(1) Is DrawingCurveSegment Then
        MsgBox ("A thread edge must be selected.")
        Exit Sub
    End If

    Dim oThreadEdge As DrawingCurve = oDoc.SelectSet(1).Parent

    If Not (oThreadEdge.EdgeType = kThreadEdge) Then
        MsgBox ("A thread edge must be selected.")
        Exit Sub
    End If

    Dim oPosition As Point2d = oApp.TransientGeometry.CreatePoint2d(22, 21)
    Dim oThreadNote As HoleThreadNote = oDoc.ActiveSheet.DrawingNotes.HoleThreadNotes.Add(oPosition, oThreadEdge)

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 4 of 5

JelteDeJong
Mentor
Mentor

Something you might want to have a look at. In the blog post "Automatically generate hole position dimensions" I show how you can add notes to all your holes, automatically to your drawing

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 5 of 5

vincenzobYFDD6
Explorer
Explorer

Sure, JelteDeJong, I had already found your solution. Very, very valid and helpful.

0 Likes