Message 1 of 6
iLogic - Update Hole Tolerances - Not Being Caught on Drawing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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()