This code will be placed on part itself and i want it run when someone places it in a assembly. I cant use the save trigger because of restrictions
customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Dim iprop(1) As String iprop(1) = "Sync_Data" Try prop = customPropertySet.Item(iprop(1)) Catch customPropertySet.Add("", iprop(1)) End Try Dim partNumber As String = iProperties.Value("Project", "Part Number") partNumber = partNumber.Trim().ToUpper() i = GoExcel.FindRow("P:\_MASTER_PART_LIST\MASTER_PART_LIST.xls", "MASTER_PART_LIST", "Part No.", "=", partNumber) If Not iProperties.Value("Project", "Description") = GoExcel.CurrentRowValue("Description") And iProperties.Value("Custom", "Sync_Data") = "False" GoTo Send_Email Else If Not iProperties.Value("Project", "Description") = GoExcel.CurrentRowValue("Description") And iProperties.Value("Custom", "Sync_Data") = "True" GoTo Update_Info End If Update_Info: If i = -1 iProperties.Value("Project", "Description") = "The entered Part Number does not exist in the Master Parts List" iProperties.Value("Project", "Vendor") = "The entered Part Number does not exist in the Master Parts List" GoTo Skip_Email Else iProperties.Value("Project", "Description") = GoExcel.CurrentRowValue("Description") iProperties.Value("Project", "Vendor") = GoExcel.CurrentRowValue("Manufacturer") Dim partDescription As String = iProperties.Value("Project", "Description") partDescription = partDescription.ToUpper() iProperties.Value("Project", "Description") = partDescription iProperties.Value("Project", "Stock Number") = "MFG Part #" & iProperties.Value("Project", "Part Number") Dim partVendor As String = iProperties.Value("Project", "Vendor") partVendor = partVendor.ToUpper() iProperties.Value("Project", "Vendor") = partVendor iProperties.Value("Custom", "Sync_Data") = "False" GoTo Skip_Email End If Send_Email: oOApp = CreateObject("Outlook.Application") oOMail = oOApp.CreateItem(0) strbody = "The part number " & iProperties.Value("Project", "Part Number") & " iproperties does not match with the Master Parts List and requires update" With oOMail .bodyformat=2 .To = "Removed for Forums Post" ' The automatic send only works if a mailadress is set here .CC = "" .BCC = "" .Subject = iProperties.Value("Project", "Part Number") & " Iproperties is not current with Master Parts List" ''''' part that is missing . Display End With With oOMail ''''' .HTMLbody = strbody & vbNewLine & .HTMLBody ' add the signature without losing the HTML-formatting of the signature '.Attachments.Add ("C:\Test.jpg") '.Display 'To pop up the Mail just remove' .Send 'If you don't want to send automatic set ' End With Skip_Email:
I don't understand what is the reason.
If you have the library under your control, you can iterate all files in the library and check the values in single loop. You can repeat this check periodically when the XLS file is changed.
But to your question. If you want to check the files before use, you need to implement your own event handler for it. Default iLogic event handlers doesn't work properly for this purpose. The best approach is to implement your own add-in and call iLogic rule from this event handler. Or implement full code to this add-in.
If you want to choose the best event, you can use EventWatcher application from Inventor SDK. My recommended event is ApplicationEvents.OnOpenDocument Event.
Can't find what you're looking for? Ask the community or share your knowledge.