Hello all!
I put together a configurator with iLogic and I wanted it to check for errors before allowing save. I was using the following code to do this:
Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 5886 StartFragment: 314 EndFragment: 5854 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet
For Each oFeature As PartFeature In ThisDoc.Document.ComponentDefinition.Features If oFeature.HealthStatus <> HealthStatusEnum.kUpToDateHealth Then Question = MessageBox.Show("Errors were found in crossmember, suppress errors?", "Notice!",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation) If Question = vbYes Then oFeature.Suppressed = True Else If Question = vbNo Then MessageBox.Show("Please review crossmember", "Notice!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation) End If End If Next
This code works great, except it considers suppressed features as errors. Is there another way to check for errors, or something to add to this code so that it will accept suppressed features?
Thanks!
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi DanielPenner,
You could check for those with kSuppressedHealth first and skip those.
Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Hey Curtis, so I put kSuppressedHealth in my code and I works. The onle problem is it runs my "SaveAs" Sub for each feature. I'm pretty sure I'm missing something I just cant seem to figure out what.
Sub Main InventorVb.DocumentUpdate() For Each oFeature As PartFeature In ThisDoc.Document.ComponentDefinition.Features If oFeature.HealthStatus = HealthStatusEnum.kSuppressedHealth Or oFeature.HealthStatus = HealthStatusEnum.kUpToDateHealth Then SaveAs Else Question = MessageBox.Show("Errors were found in crossmember, suppress errors before saving?", "Notice!",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation) If Question = vbYes Then oFeature.Suppressed = True SaveAs Else If Question = vbNo Then MessageBox.Show("Please review crossmember", "Notice!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation) End If End If Next End Sub
Hi DanielPenner,
Give this version a try.
Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Sub Main InventorVb.DocumentUpdate() Dim bHealthy As Boolean bHealthy = True 'use true as defaut 'precheck For Each oFeature As PartFeature In ThisDoc.Document.ComponentDefinition.Features If oFeature.HealthStatus = HealthStatusEnum.kSuppressedHealth Then 'do nothing Else If oFeature.HealthStatus <> HealthStatusEnum.kUpToDateHealth Then bHealthy = False Exit For 'found unhealthy so exit End If Next 'work with unhealthy features If bHealthy = False Then Question = MessageBox.Show("Errors were found in crossmember, suppress errors before saving?", _ "Notice!",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation) If Question = vbYes Then For Each oFeature As PartFeature In ThisDoc.Document.ComponentDefinition.Features If oFeature.HealthStatus = HealthStatusEnum.kSuppressedHealth Then 'do nothing Else If oFeature.HealthStatus <> HealthStatusEnum.kUpToDateHealth Then oFeature.Suppressed = True End If Next 'do save as here End If Else 'bHealthy is True 'do save as here End If End Sub
Can't find what you're looking for? Ask the community or share your knowledge.