Adding HoleThreadNote to correct side of Hole Feature

Adding HoleThreadNote to correct side of Hole Feature

NSBowser
Advocate Advocate
1,619 Views
5 Replies
Message 1 of 6

Adding HoleThreadNote to correct side of Hole Feature

NSBowser
Advocate
Advocate

I have a part with holes (using inventor hole features) in a circular pattern.

 

When placing a HoleThreadNote with the API using:

 

 

     HoleThreadNote holeNote = _dwgSheet.DrawingNotes.HoleThreadNotes.Add(textboxPoint, intent);

The note is attached to the 'wrong' side of the hole.

 

 

5-25-2017 3-09-04 PM.jpg

 

I've attempted to change the configuration settings for the note, after creation, such as the following (among some other attempts)

 

 

     holeNote.ArrowheadsInside = false;
     holeNote.LeaderFromCenter = false;
     holeNote.SingleDimensionLine = true;

 

What is the trick to getting the note to attach to the correct side of the hole? The Inventor API-help indicates that the location and intent should be enough to attach correctly, but It seems to be refusing on my samples.

 

Thanks in advance!

 

 

Additional Thoughts:

  • The hole curve is selected by looping through the curves and getting curves of kCircleCurve type picking the one in the upper left of the view
  • That curve is used in CreateGeometryIntent(curve)
  • TextboxPoint is a point2d simply offset form the curve.centerpoint 

 


Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
0 Likes
Accepted solutions (1)
1,620 Views
5 Replies
Replies (5)
Message 2 of 6

LishuangLu
Autodesk
Autodesk

Here's a sample code that can be used to create the HoleThreadNote by selecting the thread edge.

When using this mode, I can see the HoleNote to be created on the expected position. You may refer this and do the modification.

 

Sub AddThreadNote()
    ' Assumes that a drawing document is active
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument

    ' Check to make sure a thread edge is selected.
    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
    Set oThreadEdge = 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
    Set oPosition = ThisApplication.TransientGeometry.CreatePoint2d(25, 25)

    ' Create the thread note
    Dim oThreadNote As HoleThreadNote
    Set oThreadNote = oDoc.ActiveSheet.DrawingNotes.HoleThreadNotes.Add(oPosition, oThreadEdge)
End Sub

 

Thanks,

-Lisa

0 Likes
Message 3 of 6

NSBowser
Advocate
Advocate

In your sample, the selection is being done by the user, which defines the user selection point as the location to base the hole note

 

I am doing  the entire  drawing via automation. There is no user input. When the program places a hole note, it does so via looping through the holes and finding the correct one. I provide only the drawing curve and the point to place the hole note text box and it determines where to attach the arrowhead to the curve

 

However, the attachment is on the opposite side of the hole from what I would expect/desire.


Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
0 Likes
Message 4 of 6

LishuangLu
Autodesk
Autodesk

I modified the code by finding all drawing curve to create Hole thread note, at the same time, using the same 3 thread note property settings for the notes, there's no such issue in my side. see the capture.

 

Sub AddThreadNote()
    ' Assumes that a drawing document is active
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
   
    Dim oEdge As DrawingCurve
    Dim oPosition As Point2d
   
    Dim i As Integer: i = 1
    For Each oEdge In oDoc.Sheets(1).DrawingViews(1).DrawingCurves
        If oEdge.EdgeType = kThreadEdge And oEdge.CurveType = kCircleCurve Then
        Set oPosition = ThisApplication.TransientGeometry.CreatePoint2d(10 + 2 * i, 10 + 2 * i)

        ' Create the thread note
        Dim oThreadNote As HoleThreadNote
        Set oThreadNote = oDoc.ActiveSheet.DrawingNotes.HoleThreadNotes.Add(oPosition, oEdge)
       
        oThreadNote.ArrowheadsInside = False
        oThreadNote.LeaderFromCenter = False
        oThreadNote.SingleDimensionLine = True
    
        i = i + 1
        End If
    Next


   

End Sub

0 Likes
Message 5 of 6

NSBowser
Advocate
Advocate

It seems that where you place the note makes some difference. I revised your code to allow me to test the behavior in a closed environment as you are. Here i am using VB in ilogic.

 

 

    Dim oDoc As DrawingDocument
    oDoc = ThisApplication.ActiveDocument
    
	Dim drawingView As DrawingView
	drawingview = oDoc.Sheets(1).DrawingViews(1)
	Dim viewCenter As Point2d
	viewCntr =  drawingView.Center
	
	oPos1 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X - 3, viewCntr.Y - 3)
	oPos2 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X - 3, viewCntr.Y + 3)
	oPos3 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X + 3, viewCntr.Y + 3)
	oPos4 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X + 3, viewCntr.Y - 3)
    
    Dim oEdge As DrawingCurve
	
    For Each oEdge In drawingView.DrawingCurves
        If oEdge.EdgeType = DrawingEdgeTypeEnum .kThreadEdge And oEdge.CurveType = CurveTypeEnum.kCircleCurve Then
			
			Dim oThreadNote As HoleThreadNote
			
			oThreadNote = oDoc.ActiveSheet.DrawingNotes.HoleThreadNotes.Add(oPos1, oEdge)
			oThreadNote.ArrowheadsInside = False
			oThreadNote.LeaderFromCenter = False
			oThreadNote.SingleDimensionLine = True
			
			oThreadNote = oDoc.ActiveSheet.DrawingNotes.HoleThreadNotes.Add(oPos2, oEdge)
			oThreadNote.ArrowheadsInside = False
			oThreadNote.LeaderFromCenter = False
			oThreadNote.SingleDimensionLine = True
			
			oThreadNote = oDoc.ActiveSheet.DrawingNotes.HoleThreadNotes.Add(oPos3, oEdge)
			oThreadNote.ArrowheadsInside = False
			oThreadNote.LeaderFromCenter = False
			oThreadNote.SingleDimensionLine = True
			
			oThreadNote = oDoc.ActiveSheet.DrawingNotes.HoleThreadNotes.Add(oPos4, oEdge)
			oThreadNote.ArrowheadsInside = False
			oThreadNote.LeaderFromCenter = False
			oThreadNote.SingleDimensionLine = True
        End If
    Next

 

 

My goal was to show what the different positions around the part would do. The results of the code above are thus:

 

image1.jpg

 

As you can see, the behavior appears to be relevant to the selection of the position of the note, and I've been unable to correct after placement.

 

 

Here are some other tests:

 

	oPos1 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X - 2, viewCntr.Y - 3)
	oPos2 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X - 2, viewCntr.Y + 3)
	oPos3 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X + 2, viewCntr.Y + 3)
	oPos4 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X + 2, viewCntr.Y - 3)

image2.jpg

 

 

	oPos1 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X - 3, viewCntr.Y - 2)
	oPos2 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X - 3, viewCntr.Y + 2)
	oPos3 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X + 3, viewCntr.Y + 2)
	oPos4 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X + 3, viewCntr.Y - 2)

image3.jpg

 

 


Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
0 Likes
Message 6 of 6

LishuangLu
Autodesk
Autodesk
Accepted solution

Thanks for revising the code and clarifying the problem!

With your help, I can understand the problem in my side, and I can manually modified the position for 2 and 3 to get the expected result, but for Pos4, it is nearly impossible to get the expected result in this direction.

    Set oPos1 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X - 3, viewCntr.Y - 3)
    Set oPos2 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X - 6, viewCntr.Y + 3)
    Set oPos3 = ThisApplication.TransientGeometry.CreatePoint2d(viewCntr.X + 2, viewCntr.Y - 3)

 

By searching our internal bug system, I found this is a known issue, this need to be fixed by developer. Would you please first using Pos1, Pos2, Pos3 as workaround and avoiding the problem of Pos4 before the problem being fixed?

 

Regards,

-Lisa

0 Likes