Changing Parts List Styles with iLogic

Changing Parts List Styles with iLogic

JUSTIN_BRADFORD
Contributor Contributor
1,423 Views
11 Replies
Message 1 of 12

Changing Parts List Styles with iLogic

JUSTIN_BRADFORD
Contributor
Contributor

I'm working in Inventor 2020. I have 1 titleblock with two different parts list style. One style is call "Zeeco-Customer" and the other style is "Zeeco -Shop". I have an ilogic form that pops up when you create a new drawing that asks the user to select is the drawing is a customer or a shop drawing based on options in a parameter. 

 

When the user picks customer I want it apply the Zeeco-customer style and they select shop I want it to apply the Zeeco-Shop Style. I've got some other things running just fine with these titleblocks but I cannot for the life of me make this style change work. 

 

Any suggestions?

0 Likes
Accepted solutions (1)
1,424 Views
11 Replies
Replies (11)
Message 2 of 12

dalton98
Collaborator
Collaborator
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

oDoc.ActiveSheet.PartsLists(1).Style = oDoc.StylesManager.PartsListStyles.Item(2)
0 Likes
Message 3 of 12

JUSTIN_BRADFORD
Contributor
Contributor

@dalton98 I appreciate the quick reply. I know I'm not thinking correctly and just missing something. Here is what my rule is. The rule editor doesn't show any error but when I make my variable selection Inventor doesn't like it. 

'Shop BOM Style = Flares-Shop BOM
'Shop Customer BOM Style = Flares-GA Parts List
'Customer T-Block = Zeeco-Flares-Customer-QR-US
'Shop T-block = Zeeco-Flares-Shops-QR-US
'Paramter Name = Titleblock
	'Variables = Customer Or Shop

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
oDoc.ActiveSheet.PartsLists.Style(1) = oDoc.StylesManager.PartsListStyles.Item(2)

'Change t-block and BOM style based on variable selected
If TitleBlock = "Customer" Then
ActiveSheet.TitleBlock = "Zeeco-Flares-Customer-QR-US" And
oDoc.StylesManager.PartsListStyles.Item(2) = "Flares-GA Parts List"

ElseIf TitleBlock = "Shop" Then
ActiveSheet.TitleBlock = "Zeeco-Flares-Shops-QR-US" And
oDoc.StylesManager.PartsListStyles.Item(2)) = "Flares-Shop BOM"
End If

iLogicVb.UpdateWhenDone = True

ThisApplication.ActiveView.Fit

 

 

0 Likes
Message 4 of 12

dalton98
Collaborator
Collaborator

I was assuming you already had the parts list on your drawing. If you want to set the parts list style before hand use this:

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
if TitleBlock = "customer" oDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.PartsListStyle = oDoc.StylesManager.PartsListStyles.Item("Flares-GA Parts List")
Else
oDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.PartsListStyle = oDoc.StylesManager.PartsListStyles.Item(1)
End If
0 Likes
Message 5 of 12

JUSTIN_BRADFORD
Contributor
Contributor

Thank you sir. I'm still getting some errors and it's not swapping out but I'm not sure if it's my code or something like admin rights causing it. 

0 Likes
Message 6 of 12

dalton98
Collaborator
Collaborator

Ok I rewrote ur code. If there is already an active parts list then you will have to use the first code I posted

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
'oDoc.ActiveSheet.PartsLists.Style(1) = oDoc.StylesManager.PartsListStyles.Item(2)

'Change t-block and BOM style based on variable selected
If TitleBlock = "Customer" Then
ActiveSheet.TitleBlock = "Zeeco-Flares-Customer-QR-US"
oDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.PartsListStyle = oDoc.StylesManager.PartsListStyles.Item("Flares-GA Parts List")

ElseIf TitleBlock = "Shop" Then
ActiveSheet.TitleBlock = "Zeeco-Flares-Shops-QR-US"
oDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.PartsListStyle = oDoc.StylesManager.PartsListStyles.Item("Flares-Shop BOM")
End If

iLogicVb.UpdateWhenDone = True

ThisApplication.ActiveView.Fit

 

0 Likes
Message 7 of 12

JUSTIN_BRADFORD
Contributor
Contributor

@dalton.parrish I really appreciate your help. The titleblock is still swapping but the parts list stays as is no matter which version I use with or without a parts list in place. 

0 Likes
Message 8 of 12

dalton98
Collaborator
Collaborator
Accepted solution

Ok I looked around and apparently this is a bug. I fixed it by creating another rule and running that rule in the current rule.

Rule "bugfix"

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Try
oDoc.ActiveSheet.PartsLists(1).Style = oDoc.StylesManager.PartsListStyles.Item(2)
Catch
End Try

 Main rule:

iLogicVb.RunRule("bugfix")

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

If TitleBlock = "Shop"

ActiveSheet.TitleBlock = "ADAMS ASSY TB"
oDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.PartsListStyle = oDoc.StylesManager.PartsListStyles.Item(2)

Try
	oDoc.ActiveSheet.PartsLists(1).Style = oDoc.StylesManager.PartsListStyles.Item(2)
Catch
End Try

Else If TitleBlock = "Customer"
	ActiveSheet.TitleBlock = "ADAMS MULTI PART"
	oDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.PartsListStyle = oDoc.StylesManager.PartsListStyles.Item(1)
Try
	oDoc.ActiveSheet.PartsLists(1).Style = oDoc.StylesManager.PartsListStyles.Item(1)
Catch
End Try

End If

 

0 Likes
Message 9 of 12

JUSTIN_BRADFORD
Contributor
Contributor

That did it! Thanks again for the continued help on this one. 

0 Likes
Message 10 of 12

JUSTIN_BRADFORD
Contributor
Contributor

@dalton98 I’m reviving an old thread and hoping you can help me out again.  Everything we discussed and you helped me with is implemented and working great. The parts list and title block changes were all done on sheet 1 of the drawings. I’ve not been asked to create another title lock for everything but sheet 1 that is different. I can’t seems to make this work without also changing sheet 1. We can manually swap it but automating it makes it nice for the other guys that aren’t as inventor savvy. 

Thanks for any help you can provide. 

0 Likes
Message 11 of 12

dalton98
Collaborator
Collaborator

This skips over sheet 1:

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument

For i = 2 To oDoc.Sheets.Count
	oDoc.Sheets.Item(i).Activate
	ActiveSheet.TitleBlock = "NEW BLOCK"
Next

Also, idk why i told you to make another rule to call from your main rule, you should just be able to paste that code in your main rule. For that rule you should also force it to make sheet one active since your using multi-sheets.

oDoc.Sheets.Item(1).Activate
0 Likes
Message 12 of 12

JUSTIN_BRADFORD
Contributor
Contributor

Thanks for the help!

0 Likes