Changing Hole Thread Precision works but not all the time Ilogic

Changing Hole Thread Precision works but not all the time Ilogic

maxim.teleguz
Advocate Advocate
407 Views
5 Replies
Message 1 of 6

Changing Hole Thread Precision works but not all the time Ilogic

maxim.teleguz
Advocate
Advocate

here is the code I have so far:

 

'make selected dim reference existing data to string for hole callout call each one out to set it in memory 
'and Then the only one that you wont Set Is precision.
Dim odim As DrawingDimension
Line1 :
'odim = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDimensionFilter, "Select Dimension")
odim = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Select Dimension")
'MsgBox(TypeName(odim))
If odim Is Nothing Then
	Exit Sub
Else
	odim.Precision = 3
	'odim.TolerancePrecision = 0
	If TypeOf odim Is HoleThreadNote = True Then
		Dim oHNote As HoleThreadNote = odim
		'MsgBox(oHNote.FormattedHoleThreadNote, , "")
		'a = InputBox("","FormattedHoleThreadNote", oHNote.FormattedHoleThreadNote)
		a = oHNote.FormattedHoleThreadNote
		'oHNote.FormattedHoleThreadNote = "<HoleProperty HolePropertyID='kHoleDiameterHoleProperty' Precision='3' AlternatePrecision='3'</HoleProperty>"
		
		Dim TXT2Find As String = "Precision='2'"
		Dim NewTXT As String = "Precision='3'"
		'odim.OverrideModelValue = 0
		
		If a Like NewTXT Then
		MsgBox("nothing changed")
		Exit Sub
		Else
		a = Replace(a, TXT2Find, NewTXT)
		End If

        'If TXT2Find = "Precision='2'" Then
        'a.Replace = "Precision='3'"
		'End If
		
		'MsgBox(a)
		oHNote.FormattedHoleThreadNote = a
	End If

End If
GoTo Line1 

 

If anyone can help me figure out what is wrong that would be amazing.

I know this question has been asked here for ages without a solution. Here I present to you a solution which could be better but at least it shows a method on how to do it. I just don't have the time to figure out all the bugs.


cleaned up code

Dim odim As DrawingDimension
Line1 :
odim = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Select Dimension")
If odim Is Nothing Then
	Exit Sub
Else
	odim.Precision = 3
	If TypeOf odim Is HoleThreadNote = True Then
		Dim oHNote As HoleThreadNote = odim
		a = oHNote.FormattedHoleThreadNote
		
		Dim TXT2Find As String = "Precision='2'"
		Dim NewTXT As String = "Precision='3'"
		'odim.OverrideModelValue = 0
		
		If a Like NewTXT Then
		MsgBox("nothing changed")
		Exit Sub
		Else
		a = Replace(a, TXT2Find, NewTXT)
		End If

		oHNote.FormattedHoleThreadNote = a
	End If

End If
GoTo Line1 



-Max 

0 Likes
408 Views
5 Replies
Replies (5)
Message 2 of 6

maxim.teleguz
Advocate
Advocate

this works in IDW drawing. forgot to mention that. 

0 Likes
Message 3 of 6

nedeljko.sovljanski
Advocate
Advocate

Hi @maxim.teleguz 

Your code works fine on regular dimension and it changes precision on 3 digits, but with hole notes it is problematic.

If you expect to make hole notes and change precision for depth such as

nedeljkosovljanski_0-1643789674530.png

then you have to pay attention on variable a

a = oHNote.FormattedHoleThreadNote

this will return (default)

"<HoleProperty HolePropertyID='kCustomDesignationHoleProperty'></HoleProperty> - <HoleProperty HolePropertyID='kThreadClassHoleProperty'></HoleProperty><HoleProperty HolePropertyID='kHoleDepthHoleProperty'False'></HoleProperty>"

As you can see there is no Precision inside to replace. Also I don't know what False' in last line doing there and that should be deleted.

String should be:

"<HoleProperty HolePropertyID='kCustomDesignationHoleProperty'></HoleProperty> - <HoleProperty HolePropertyID='kThreadClassHoleProperty'></HoleProperty><HoleProperty HolePropertyID='kHoleDepthHoleProperty' Precision='3' AlternatePrecision='2'></HoleProperty>"

So that means you need to add precision='3' if that doesn't exist.

 

 

Message 4 of 6

maxim.teleguz
Advocate
Advocate

Thank you for responding. 

What version of inventor are you using. They mustve changed the string of the hole dimension. But again this could also be the reason why the code wouldnt work in all situations. 

Basically the string didnt have any reference to precision. 

the reason behind finding in-string precision, is because not all the hole notes are the same a lot of them have differences. This way is to search precision and replace it with what you want. I guess my next step is to search for precision and if not found, add it. hmm.

I see that we need to come up with a universal hole property wild card approach. because it looks like you are dimensioning it from a section. would the hole property be different if dimensioned from the top view? 

thanks for testing this out. 

0 Likes
Message 5 of 6

nedeljko.sovljanski
Advocate
Advocate

I am using I2022.2.1

Message 6 of 6

maxim.teleguz
Advocate
Advocate

I developed this under 2020. 


@nedeljko.sovljanski wrote:

I am using I2022.2.1




0 Likes