iLogic Assembly iProperties Change and Message Box Help

iLogic Assembly iProperties Change and Message Box Help

Anonymous
Not applicable
641 Views
3 Replies
Message 1 of 4

iLogic Assembly iProperties Change and Message Box Help

Anonymous
Not applicable

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. 

 

0 Likes
Accepted solutions (1)
642 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi seth.lanier,

 

One way to do this is just to set a flag variable.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

'set flag default
oFlag = False

If iProperties.Value("Summary", "Author") <> "SethL" Then
	'update iProps
	iProperties.Value("Summary", "Author") = "SethL"
	'set message flag
	oFlag = True	
End If

If iProperties.Value("Project", "Designer") <> "SethL" Then
	'update iProps
	iProperties.Value("Project", "Designer") = "SethL"
	'set message flag
	oFlag = True	
End If

If oFlag = True Then
	MessageBox.Show ("You updated iProperties.", "iLogic")
End If

EESignature

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you. I see how i can use this.

 

However, I would still like there to be a way that the message box will automatically tell me which iProperties.Value have been update. So instead of reading "You updated iProperties." It will reading something similar to "You have updated the iProperties values for the following: Author, Designer" Do you know of a way I can tell iLogic to do that?

0 Likes
Message 4 of 4

Curtis_Waguespack
Consultant
Consultant

 

Hi seth.lanier,

 

Maybe something more like this.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

'set flag default
oFlag = False

'set flag default
oAuthorFlag = ""
If iProperties.Value("Summary", "Author") <> "SethL" Then
	'update iProps
	iProperties.Value("Summary", "Author") = "SethL"
	'set message flags
	oFlag = True
	oAuthorFlag = "Author"	
End If

'set flag default
oDesignerFlag = ""
If iProperties.Value("Project", "Designer") <> "SethL" Then
	'update iProps
	iProperties.Value("Project", "Designer") = "SethL"
	'set message flags
	oFlag = True
	oDesignerFlag = "Designer"	
End If

If oFlag = True Then
	MessageBox.Show ("You have successfully updated the following iProperties:" _
& vbLf & oAuthorFlag _
& vbLf & oDesignerFlag, "Success!")
End If

EESignature

0 Likes