iLogic - Update Hole Tolerances - Not Being Caught on Drawing?

iLogic - Update Hole Tolerances - Not Being Caught on Drawing?

tdswanson
Collaborator Collaborator
814 Views
5 Replies
Message 1 of 6

iLogic - Update Hole Tolerances - Not Being Caught on Drawing?

tdswanson
Collaborator
Collaborator

Hey everyone:

 

I've written some code that allows the user to select a hole, then it applies a standard tolerance to the hole based on its diameter value(s).

 

Anyway, the code updates the tolerance values in the IPT file just fine.  However, when I go to the drawing environment and point a leader to the hole in question, the leader will not always pickup the changes in the model, even after the model is saved and rebuilt.

 

Is there some "refresh" command or something that I'm missing?  Typically resolution requires the hole dialog box to opened and the OK button being hit in order for the leader to update to the model's tolerance.  Suggestions?

 

Thanks!

 

Here's the code:

 

Dim oDoc As Document
	oDoc = ThisApplication.ActiveEditDocument
Dim i As Integer
	i = 1

Dim FeatureCount As Integer
Dim HoleModCount As Integer
Dim Proceed As Integer
If ThisDoc.Document.SelectSet.count <1 Then ' Verify the total number of selected features
	q = MessageBox.Show("You must select at least one hole.", "iLogic Error", MessageBoxButtons.OK, MessageBoxIcon.asterisk, MessageBoxDefaultButton.Button1)
	Exit Sub
End If

Dim OriginalUnits as Integer
OriginalUnits = oDoc.unitsofmeasure.LengthUnits ' Get the current units of measure

If oDoc.unitsofmeasure.LengthUnits <> 11272 Then oDoc.unitsofmeasure.LengthUnits = 11272 'Set to inches

FeatureCount = ThisDoc.Document.SelectSet.count ' Store the total number of selected features
HoleModCount = 0 ' Zero the counter for modified holes

'For Each CurrentHole As HoleFeature In oDoc.ComponentDefinition.Features.HoleFeatures ' Run on ALL Holes
'For Each CurrentHole As HoleFeature In ThisDoc.Document.SelectSet ' Run on SELECTED Holes
For Each CurrentHole In ThisDoc.Document.SelectSet ' Run on SELECTED Features
	'If CurrentHole.Suppressed = False Then Proceed = 0 'Run command on suppressed features
	If CurrentHole.Type = ObjectTypeEnum.kHoleFeatureObject Then ' Check to make sure this feature is a hole
		Proceed = 1 ' Green light
		If CurrentHole.Tapped = True Then Proceed = 0 ' Cancel if a tapped hole
		If Proceed = 1 Then
			'i = MessageBox.Show(CurrentHole.HoleType, "My iLogic Dialog", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
			Select Case CurrentHole.HoleType
				'kCounterBoreHole 21507 Hole Is counterbored. 
				'kCounterSinkHole 21506 Hole Is countersunk. 
				'kDrilledHole 21505 Hole Is drilled (no countersink Or counterboring). 
				'kSpotFaceHole 21508 Hole Is spotfaced. 
				
				Case 21505 'Hole Is drilled (no countersink Or counterboring)
					Dim oDef As PartComponentDefinition
					oDef = oDoc.ComponentDefinition
					Dim oHole(i) As HoleFeature
					oHole(i) = oDef.Features.HoleFeatures.Item(i)
					Dim oDiamParam(i) As Parameter
					oDiamParam(i) = oHole(i).HoleDiameter
					Dim CurrDiam
					CurrDiam = oDiamParam(i).Value / 2.54
					'i = MessageBox.Show(CurrDiam, "My iLogic Dialog", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
					Dim oTol(i) As Tolerance
					oTol(i) = oDiamParam(i).Tolerance
					If CurrDiam < 0.062 Then oTol(i).SetToDeviation("0.003 in", "-0.001 in")
					If CurrDiam > 0.06201 And CurrDiam <= 0.250 Then oTol(i).SetToDeviation("0.010 in", "-0.004 in")
					If CurrDiam > 0.25001 And CurrDiam <= 0.500 Then oTol(i).SetToDeviation("0.012 in", "-0.004 in")
					If CurrDiam > 0.50001 And CurrDiam <= 0.750 Then oTol(i).SetToDeviation("0.016 in", "-0.006 in")
					If CurrDiam > 0.75001 And CurrDiam <= 1.000 Then oTol(i).SetToDeviation("0.020 in", "-0.006 in")
					If CurrDiam > 1.00000 Then oTol(i).SetToDeviation("0.020 in", "-0.010 in")
					HoleModCount = HoleModCount + 1
					InventorVb.DocumentUpdate() ' Update Doc
					oDoc.Update()
					
				Case 21507 'Hole Is counterbored
					'Do the Through Hole Work First
					Dim oDef As PartComponentDefinition
					oDef = oDoc.ComponentDefinition
					Dim oHole(i) As HoleFeature
					oHole(i) = oDef.Features.HoleFeatures.Item(i)
					Dim oDiamParam(i) As Parameter
					oDiamParam(i) = oHole(i).HoleDiameter
					Dim CurrDiam
					CurrDiam = oDiamParam(i).Value / 2.54
					'i = MessageBox.Show(CurrDiam, "My iLogic Dialog", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
					Dim oTol(i) As Tolerance
					oTol(i) = oDiamParam(i).Tolerance
					If CurrDiam < 0.062 Then oTol(i).SetToDeviation("0.003 in", "-0.001 in")
					If CurrDiam > 0.06201 And CurrDiam <= 0.250 Then oTol(i).SetToDeviation("0.010 in", "-0.004 in")
					If CurrDiam > 0.25001 And CurrDiam <= 0.500 Then oTol(i).SetToDeviation("0.012 in", "-0.004 in")
					If CurrDiam > 0.50001 And CurrDiam <= 0.750 Then oTol(i).SetToDeviation("0.016 in", "-0.006 in")
					If CurrDiam > 0.75001 And CurrDiam <= 1.000 Then oTol(i).SetToDeviation("0.020 in", "-0.006 in")
					If CurrDiam > 1.00000 Then oTol(i).SetToDeviation("0.020 in", "-0.010 in")
					InventorVb.DocumentUpdate() ' Update Doc
					oDoc.Update()
					
					'For the Countebore
					Dim oDiamCboreParam(i) As Parameter
					oDiamCboreParam(i) = oHole(i).CboreDiameter
					Dim CurrDiamCbore
					CurrDiamCbore = oDiamCboreParam(i).Value / 2.54
					'i = MessageBox.Show(CurrDiamCbore, "My iLogic Dialog", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
					Dim oTolCbore(i) As Tolerance
					oTolCbore(i) = oDiamCboreParam(i).Tolerance
					If CurrDiamCbore < 0.062 Then oTolCbore(i).SetToDeviation("0.003 in", "-0.001 in")
					If CurrDiamCbore > 0.06201 And CurrDiamCbore <= 0.250 Then oTolCbore(i).SetToDeviation("0.010 in", "-0.004 in")
					If CurrDiamCbore > 0.25001 And CurrDiamCbore <= 0.500 Then oTolCbore(i).SetToDeviation("0.012 in", "-0.004 in")
					If CurrDiamCbore > 0.50001 And CurrDiamCbore <= 0.750 Then oTolCbore(i).SetToDeviation("0.016 in", "-0.006 in")
					If CurrDiamCbore > 0.75001 And CurrDiamCbore <= 1.000 Then oTolCbore(i).SetToDeviation("0.020 in", "-0.006 in")
					If CurrDiamCbore > 1.00000 Then oTolCbore(i).SetToDeviation("0.020 in", "-0.010 in")
					
					HoleModCount = HoleModCount + 1
					
				Case 21506 ' Hole Is countersunk
					Dim oDef As PartComponentDefinition
					oDef = oDoc.ComponentDefinition
					Dim oHole(i) As HoleFeature
					oHole(i) = oDef.Features.HoleFeatures.Item(i)
					Dim oDiamParam(i) As Parameter
					oDiamParam(i) = oHole(i).HoleDiameter
					Dim CurrDiam
					CurrDiam = oDiamParam(i).Value / 2.54
					'i = MessageBox.Show(CurrDiam, "My iLogic Dialog", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
					Dim oTol(i) As Tolerance
					oTol(i) = oDiamParam(i).Tolerance
					If CurrDiam < 0.062 Then oTol(i).SetToDeviation("0.003 in", "-0.001 in")
					If CurrDiam > 0.06201 And CurrDiam <= 0.250 Then oTol(i).SetToDeviation("0.010 in", "-0.004 in")
					If CurrDiam > 0.25001 And CurrDiam <= 0.500 Then oTol(i).SetToDeviation("0.012 in", "-0.004 in")
					If CurrDiam > 0.50001 And CurrDiam <= 0.750 Then oTol(i).SetToDeviation("0.016 in", "-0.006 in")
					If CurrDiam > 0.75001 And CurrDiam <= 1.000 Then oTol(i).SetToDeviation("0.020 in", "-0.006 in")
					If CurrDiam > 1.00000 Then oTol(i).SetToDeviation("0.020 in", "-0.010 in")
					HoleModCount = HoleModCount + 1
					InventorVb.DocumentUpdate() ' Update Doc
					oDoc.Update()
				
			End Select
		End If
	Else 
		Proceed = 0 ' Red light if the feature isn't a hole
	End If
	
	
	
	
	
	
	i = i + 1
Next CurrentHole ' Next Feature
ThisDoc.Document.Rebuild()
ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute

q = MessageBox.Show(HoleModCount & " hole(s) were updated", "iLogic Complete!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)


oDoc.unitsofmeasure.LengthUnits = OriginalUnits
InventorVb.DocumentUpdate() ' Update Doc
oDoc.Update()
0 Likes
815 Views
5 Replies
Replies (5)
Message 2 of 6

tdswanson
Collaborator
Collaborator

Bump....  Anyone else ever see this type of issue?

Message 3 of 6

HermJan.Otterman
Advisor
Advisor

Hello TD,

 

I have been working on a thread update program and here the problem was that in the updated design data the custom thread designation was used instead of the thread designation. because in the old drawings the thread designation was used, did it not update this, and I had to do this with code.

maybe you have the same.

can you post an example with a part and drawing, so I can see what's hapening?

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 4 of 6

tdswanson
Collaborator
Collaborator

Thanks for your message, however, I don't think these issues are related since my code ignores all threaded holes.  These are for basic holes and counterbored holes only, and don't use the thread table or callouts.  

0 Likes
Message 5 of 6

HermJan.Otterman
Advisor
Advisor

oke, so the existing holenotes? don't update? what if you place a new one next to the not updated one? is that one oke?

if so, than look at the differences in the text.

the parameter used in the holenote will not be changed.

can you share an example?

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 6 of 6

tdswanson
Collaborator
Collaborator

Hmmm....  Well, I went to setup a simple dummy block with some holes in it so that I could post an example and when I did so, I could not replicate the problem.  I'd run the iLogic that updated the hole tolerances, save the part, then switch to the drawing and the hole callout leaders would update right away like it should.

 

So I guess, problem solved!

 

Thanks for reading a posting!