I have a fairly simple external iLogic rule I've been working on (and using) for the last couple of days, which I would like to add some additional functionality to. The rule is run on a part file, - it then looks at that part's Part Number iProperty, goes to an Excel price list, retrieves the corresponding Cost and Comments fields from the spreadsheet, and writes these to the appropriate iProperty values in the part.
Target = iProperties.Value("Project", "Part Number") i = GoExcel.FindRow("X:\R&D\R&D Structure\Fitting Cost Estimator.xls", "Price List", "PART #", "=", Target) Cost = GoExcel.CurrentRowValue("ESTIMATED COST") Comment = GoExcel.CurrentRowValue("COMMENTS") iProperties.Value("Project", "Estimated Cost") = Cost iProperties.Value("Summary", "Comments") = Comment InventorVb.DocumentUpdate() If Cost = 0 Then If Comment = "PART MISSING FROM PRICE LIST" MessageBox.Show("This fitting is missing from the price list.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning) Else MessageBox.Show("This fitting has no price entered in the price list.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning) End If End If
This rule is really only intended to update data for non-iPart components in our central library of purchased parts. However, this library contains a mix of normal parts and iParts, and it would be very easy to accidentally run the rule on an iPart. Is there something simple that could be added to the rule to check if the active document is an iPart, and skip it if so?
Solved! Go to Solution.
You can use something like this:
Dim partDoc As PartDocument partDoc = ThisApplication.ActiveDocument If partDoc.ComponentDefinition.IsiPartFactory _ Or partDoc.ComponentDefinition.IsiPartMember Then Return 'do nothing Else MessageBox.Show("This is NOT an iPart", "Title") End If
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Thanks, that works great. I modified it a bit to give a message box if run on an iPart, instead of just a Return. Later on I may add an additional check to exclude assemblies as well, but since there is currently only one assembly in this entire library folder, that can wait for now.