
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, all. I have been using inventor for a little while but I am not super tech savvy when it comes to programming, so iLogic is taking me a long time to teach myself. Using codes I have found online I have done some modifications to get the result I want. However, I am having some trouble getting the result I want now. What I want is to tell iLogic that if the assemlby updates my iProperties values then I want a message box to pop up and tell me what has been updated. Here is the code I am currently using.
SyntaxEditor Code Snippet
Sub Main() question = MessageBox.Show("Click OK to run iProperties Change.", "Run Rule",MessageBoxButtons.OKCancel) Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument Call Iterate(oAsmDoc.ComponentDefinition.Occurrences, 1) End Sub Private Sub Iterate(Occurrences As ComponentOccurrences, Level As Integer) 'Iterate through Assembly Dim oOcc As ComponentOccurrence For Each oOcc In Occurrences 'Find Parts in Assembly Dim SheetMetalAssembly As String SheetMetalAssembly = oOcc.Name Try 'Write iProps to Parts iProperties.Value(SheetMetalAssembly, "Summary", "Author") = "SethL" iProperties.Value(SheetMetalAssembly, "Project", "Designer") = "SethL" iProperties.Value(SheetMetalAssembly, "Project", "Engineer") = "SethL" iProperties.Value(SheetMetalAssembly, "Summary", "Company") = "BEVEL CORPORATION" iProperties.Value(SheetMetalAssembly, "Summary", "Category") = "Mass Roll Up" iProperties.Value(SheetMetalASsembly, "Summary", "Comments")= "=<Width> x <Length> x <Height> x <Thickness>" Catch 'MsgBox("Message!") iLogicVb.UpdateWhenDone = True End Try 'Run through the sub assemblies If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then Call Iterate(oOcc.SubOccurrences, Level + 1) End If Next MessageBox.Show ("You have successfully updated iProperties for each of the following parts:" _ & vbLf & "Author" _ & vbLf & "Category" _ & vbLf & "Comments" _ & vbLf & "Company" _ & vbLf & "Designer" _ & vbLf & "Project", "Success!") End Sub
As you can see I have a message box that will come up at the end of my code, but I had to manually tell the box what was updated. I know i can use a string list to show me an error list of parts that were not updated, but that is not what I am looking for. Also, If I hit "OK" then the assembly will update (which is good), but if I hit "Cancel" then the assembly will still update and my "Successs!" box will still come up. I want the "Success!" box to only come up when I have actually hit "OK" and after the assembly has successfully been updated. If I hit "Cancel" then I want my "Run Rule" box to close and I do NOT want another box to pop up and say "Success!"
I hope this all makes sense. Please let me know if this does not make sense and I will do my best to rephrase. Thank you in advance for your help.
Solved! Go to Solution.