iLogic Thread Call out with additional text

iLogic Thread Call out with additional text

Formsprag
Advocate Advocate
1,589 Views
14 Replies
Message 1 of 15

iLogic Thread Call out with additional text

Formsprag
Advocate
Advocate

Good afternoon Forum, 

 

I am trying to get a hole thread note with additional text as shown in the image below. I can get the code to give me the diameter of the hole but I just can't figure the hole thread note out.

 

The diameter is called out as:

Dim HoleDim2 = genDims.AddDiameter("F_S_F2_JH", Dim2Pos, E_S_F2_JH)

 

Any help for this noob would be greatly appreciated.

 

2020-07-23_16-32-01.jpg

 

Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("Sheet:1")
Dim TOP_VIEW = Sheet_1.DrawingViews.ItemByName("TOP VIEW")
Dim holeThreadNotes = Sheet_1.DrawingNotes.HoleThreadNotes
Dim genDims = Sheet_1.DrawingDimensions.GeneralDimensions

' Add Annotations
ThisDrawing.BeginManage()
	
	Dim F_S_F1_DH = TOP_VIEW.GetIntent("2021_2-250008-15-001:1", "F_S_F1_DH")
	Dim E_S_F1_DH = TOP_VIEW.GetIntent("2021_2-250008-15-001:1", "E_S_F1_DH")
	Dim WP_S_F1_DHCP = TOP_VIEW.GetIntent("2021_2-250008-15-001:1", "WP_S_F1_DHCP")
	Dim WP_S_F2_JHCP = TOP_VIEW.GetIntent("2021_2-250008-15-001:1", "WP_S_F2_JHCP")
	Dim WP_S_F2_MHCP = TOP_VIEW.GetIntent("2021_2-250008-15-001:1", "WP_S_F2_MHCP")
	Dim F_S_F2_JH = TOP_VIEW.GetIntent("2021_2-250008-15-001:1", "F_S_F2_JH")
	Dim E_S_F2_JH = TOP_VIEW.GetIntent("2021_2-250008-15-001:1", "E_S_F2_JH")
	Dim E_S_F2_MH = TOP_VIEW.GetIntent("2021_2-250008-15-001:1", "E_S_F2_MH")

	
		' Calculate Positions
		
		Dim Dim1Pos = ThisDrawing.Geometry.Point2d(0, 0)
		Dim1Pos.InDatabaseUnits = WP_S_F1_DHCP.PointOnSheet	
		Dim1Pos.Y = Dim1Pos.Y + 0.25 + (HoleDiameter / 2) * TOP_VIEW.Scale
		Dim1Pos.X = Dim1Pos.X + 0.25 + (HoleDiameter / 2) * TOP_VIEW.Scale
		
		Dim Dim2Pos = ThisDrawing.Geometry.Point2d(0, 0)
		Dim2Pos.InDatabaseUnits = WP_S_F2_JHCP.PointOnSheet	
		Dim2Pos.Y = Dim2Pos.Y + 0.25 + (HoleDiameter / 2) * TOP_VIEW.Scale
		Dim2Pos.X = Dim2Pos.X + 0.25 + (HoleDiameter / 2) * TOP_VIEW.Scale
		
		Dim Dim3Pos = ThisDrawing.Geometry.Point2d(0, 0)
		Dim3Pos.InDatabaseUnits = WP_S_F2_MHCP.PointOnSheet	
		Dim3Pos.Y = Dim3Pos.Y + 0.25 + (HoleDiameter / 2) * TOP_VIEW.Scale
		Dim3Pos.X = Dim3Pos.X + 0.25 + (HoleDiameter / 2) * TOP_VIEW.Scale
				
		Dim HoleDim1 = genDims.AddDiameter("F_S_F1_DH", Dim1Pos, E_S_F1_DH)	
		Dim HoleDim2 = genDims.AddDiameter("F_S_F2_JH", Dim2Pos, E_S_F2_JH)
		Dim HoleDim3 = genDims.AddDiameter("F_S_F2_MH", Dim3Pos, E_S_F2_MH)
		
			
ThisDrawing.EndManage()

 

0 Likes
1,590 Views
14 Replies
Replies (14)
Message 2 of 15

WCrihfield
Mentor
Mentor

The lines to create a HoleThreadNote, then modify its text are similar to the following:

Dim oHTN As HoleThreadNote = holeThreadNotes.Add(oPosition, oHoleOrThreadEdge, oLinearDiaFalse, oDimStyle)
oHTN.FormattedHoleThreadNote = 

But since I don't have your files, and can't make sense of the earlier part of your code, I couldn't be more precise.

The oPosition is a Point2d object, for the placement location of it.

The oHoleOrThreadEdge is just asking for an Object, and might accept a GeometryIntent, but is most likely just wanting you to select the circle (DrawingCurve) that represents the hole on the drawing.

The oLinearDiaFalse is a Boolean, that is asking if this is going to be a LinearDiameterType, which should be set to False.

And the oDimStyle position is asking for an Object, but is obviously wanting you to specify the DimensionStyle object.

Then the next line is accessing the FormattedHoleThreadNote string of it.

This is going to use XML tags to maintain the live links to the model information which normally shows within.

Here is a link to a reference page that talks about using XML tags in this way.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 15

WCrihfield
Mentor
Mentor

By the way a good way to get started on modifying the text string is to create one, then use an InputBox to show what it already has within the formatted string.  Using the InputBox allows you to select & copy the contents.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 15

yan.gauthier
Advocate
Advocate

Hi,

 

There is something particular when accessing HoleThreadNote text.

 

you can add a suffix or prefix to your HoleThread note by editing the HoleThreadNote.Text.FormattedText value. Default Value is <DimensionValue/> (note this is XML formatted).

 

Change it to be HoleThreadNote.Text.FormattedText.value = "<DimensionValue/>" & stringVariable

 

Also, you need your Dimension Style to have suffx and prefix set to be above and below2020-07-24 10_00_43-Autodesk Inventor Professional 2020.png

 

But, if you wish to edit the HoleThreadNote text itself, this is another type of challenge

0 Likes
Message 5 of 15

Formsprag
Advocate
Advocate

I guess I just don't get it, struggling with hole and thread notes.

 

Here's what I am trying to do:

 

HoleDim5 needs to state:

 

DOWEL PIN HOLES

DIAGONALLY PLACED 

<QTYNOTE>n<HDIA> THRU

 

HoleDim6 needs to state:

 

JACKING HOLES
FOR ALIGNMENT
<QTYNOTE><THDCD> - <THRC>
(JACKING BOLTS ARE OPTIONAL)

 

All I can both of them to do is give me the diameter, anything outside of that gives me an error.

I am by no means a programmer so most of instruction given in the post above was way over my head, i'm really outside of my comfort zone.

 

Thanks,

0 Likes
Message 6 of 15

Formsprag
Advocate
Advocate

This sounds like a very useful tool, can you explain how to use it?

0 Likes
Message 7 of 15

WCrihfield
Mentor
Mentor

Try something like this:

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oHTNs As HoleThreadNotes = oDDoc.ActiveSheet.DrawingNotes.HoleThreadNotes
Dim oHoleCircle As DrawingCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select the Circle that represents the hole.")
Dim oCP As Point2d = oHoleCircle.CenterPoint
Dim oPosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d((oCP.X+3),(oCP.Y+3))
Dim oNotLinear As Boolean = False
Dim oDimStyle As DimensionStyle = oDDoc.StylesManager.DimensionStyles.Item(1)
Dim oHTN As HoleThreadNote = oHTNs.Add(oPosition, oHoleCircle, oNotLinear, oDimStyle)
oChoice = InputBox("Here is the selectable contents of the HoleThreadNote's Formatted Text.","FORMATTED STRING",oHTN.FormattedHoleThreadNote)

Or, to make this test even more productive, edit the actual note on your drawing the way you want it first, then skip the steps within this code that deal with creating the note, and just get the one you edited, then use the InputBox example to return how it will look when it's formatted the way you want it.😉

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 15

Formsprag
Advocate
Advocate

Ok, so using the new "Hole Note" snippet from 2021 I was able to get the hole thread callout but I am still unable to change the dimension placement (length of the flag) or add the additional text. The text needs to be static, I do not want the user to be able to change it or alter it in any way. I would like iLogic to place it the same way and location every time. Here's the 2021 snippet I was able to use successfully:

 

Dim Dim1Pos = ThisDrawing.Geometry.Point2d(0, 0)
		Dim1Pos.InDatabaseUnits = WP_S_F4_GHCP.PointOnSheet	
		Dim1Pos.Y = Dim1Pos.Y + 0.275 + (HoleDiameter / 2) * LH_SIDE_VIEW.Scale
		Dim1Pos.X = Dim1Pos.X - 0.17 + (HoleDiameter / 2) * LH_SIDE_VIEW.Scale

 

Dim holeFace2 = LH_SIDE_VIEW.GetIntent("2021_2-250008-15-001:1", "F_S_F4_GH")
		Dim holeNotePt2 = Dim1Pos
		Dim holeNote2 = holeThreadNotes.Add("Hole Note 2", holeNotePt2, holeFace2)

Here's what the code places:

 

2020-07-30_7-34-36.jpg

 

Here's what I need the code to place:

 

2020-07-30_7-25-30.jpg

 

Any help is greatly appreciated......

0 Likes
Message 9 of 15

WCrihfield
Mentor
Mentor

I created an identical threaded hole on a test part, then created a drawing for it, then manually added the HoleThreadNote, to look exactly the same the one you just created in your last post. (without any of the custom text in it yet).

Then I used this simple iLogic rule to get its selectable contents.

Dim oHN As HoleThreadNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDefaultFilter, "Select a HoleThreadNote.")
If oHN Is Nothing Then Return
InputBox("Here is the selectable contents of the HoleThreadNote's FormattedText.","Formatted Text",oHN.FormattedHoleThreadNote)

And here is what was within the selectable portion of the InputBox:

<HoleProperty HolePropertyID='kCustomDesignationHoleProperty'></HoleProperty> - <HoleProperty HolePropertyID='kThreadClassHoleProperty'></HoleProperty> <StyleOverride Font='AIGDT' FontSize='0.2032'>x</StyleOverride><StyleOverride FontSize='0.2032'> <HoleProperty HolePropertyID='kThreadDepthHoleProperty' Precision='2' AlternatePrecision='2'False'></HoleProperty></StyleOverride>

 So, using this same method, I then further manually customized the holethreadnote, to make it appear the way you wanted it to.

And here is the InputBox result afterwords:

FOR EARTHING LUG<Br/><HoleProperty HolePropertyID='kCustomDesignationHoleProperty'></HoleProperty> - <HoleProperty HolePropertyID='kThreadClassHoleProperty'></HoleProperty><Br/>DIAGONALLY PLACED

So, you should be able to use some additional code your your last post, which sets this last result as the value of your existing notes' FormattedHoleThreadNote.  Something similar to this:

holeNote2.FormattedHoleThreadNote = "FOR EARTHING LUG<Br/><HoleProperty HolePropertyID='kCustomDesignationHoleProperty'></HoleProperty> - <HoleProperty HolePropertyID='kThreadClassHoleProperty'></HoleProperty><Br/>DIAGONALLY PLACED"

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 10 of 15

Formsprag
Advocate
Advocate

I understand the "Input Box" now, thanks that is going to be a real time saver.

 

However; I am getting a "End of statement expected" error now.

 

 

0 Likes
Message 11 of 15

WCrihfield
Mentor
Mentor

Something like this is probably going to be easier to implement though.

Dim oHoleNote As HoleThreadNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDefaultFilter, "Select a HoleThreadNote.")
If oHoleNote Is Nothing Then Return
Dim oFText As String = oHoleNote.Text.FormattedText
oHoleNote.Text.FormattedText = "FOR EARTHING LUG" & vbCrLf & oFText & vbCrLf & "DIAGONALLY PLACED"

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 12 of 15

WCrihfield
Mentor
Mentor

When I use the same InputBox method on the "oHoleNote.Text.FormattedText" instead of the "oHoleNote.FormattedHoleThreadNote", and select the base hole note on my drawing (without any customizations), I get the following selectable result.

<DimensionValue/>

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 13 of 15

WCrihfield
Mentor
Mentor

And another way...

oHoleNote.Text.FormattedText = oHoleNote.Text.FormattedText.Insert(0, "FOR EARTHING LUG<Br/>")
oHoleNote.Text.FormattedText = oHoleNote.Text.FormattedText.Insert(oHoleNote.Text.FormattedText.Length, "<Br/>DIAGONALLY PLACED")

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 14 of 15

Formsprag
Advocate
Advocate

Thanks for all your help it's really impressive how many ways you have given me to try this, but I think all of this is a little over my head and not quite what I'm looking for. This needs to be completely autonomous with no user interactions what-so-ever. I appreciate your help but I think I need to learn some fundamentals before attacking this project.

 

Thanks again,   

0 Likes
Message 15 of 15

WCrihfield
Mentor
Mentor

OK. So you're trying to automatically generate the whole drawing by code then, right?

Yes...that can be a big job, even for the best of us.  And the result will most likely need to be highly customized to suit your drawing style, format, and settings.

Good luck. 👍

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes