ilogic Change Selected Part List style to selected multi list style

ilogic Change Selected Part List style to selected multi list style

mtoddHBKNF
Participant Participant
296 Views
4 Replies
Message 1 of 5

ilogic Change Selected Part List style to selected multi list style

mtoddHBKNF
Participant
Participant

I would like to be able to change the part list style depending on 

a) Sheet Size. If A size this is the menu, if B size this is the menu. 

b) Selected Part List Style. 

 

I created and saved multiple part list styles in my drawing template. One is set as default, but depending on the type of assembly the columns could vary. It is very easy manual change, but just to make it even easier for those new to inventor I would like to add the ilogic to my form. I would appreciate the help once again!

0 Likes
Accepted solutions (1)
297 Views
4 Replies
Replies (4)
Message 2 of 5

mateusz_baczewski
Advocate
Advocate

@mtoddHBKNF 

Hi,

I'm sending a short example code that changes the style of parts lists on a given sheet. From this, you should be able to create the code you need:

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oActiveSheet As Sheet = oDoc.ActiveSheet

Dim oStylesManager As DrawingStylesManager = oDoc.StylesManager
Dim partsListStyle = oStylesManager.PartsListStyles.Item("Parts List D size-I-IQ-PN-D-M-S-LG-N")
Dim oPartsLists As PartsLists = oActiveSheet.PartsLists

For Each oPartsList As PartsList In oPartsLists
	oPartsList.Style  = partsListStyle
Next
If you found it helpful, a "Like" would be much appreciated!
If this post solved your problem, please mark it as "Solution.".

0 Likes
Message 3 of 5

mtoddHBKNF
Participant
Participant

I was able to find that code previously and that code works great, but what I wanted to add is a List with all the different options like the attached picture. Unfortunate my code is not working. My programming knowledge is limited.

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Hi @mtoddHBKNF.  Not sure which way you wanted to go with this iLogic rule, so I am showing both ways I had in mind.  Central section is commented out, and was for letting a user choose one of the names from a list, then applying that style to all PartsLists on the active sheet.  The last portion, which is not commented out, is for setting that list of names as the multi-value list of a text type user parameter in the drawing.  I hope one of those is what you were looking for.  It still does not check sheet size, then apply one automatically, just based on that size, but one step at a time, right.

Sub Main
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
	If oDDoc Is Nothing Then Return
	Dim oPListStyles As PartsListStylesEnumerator = oDDoc.StylesManager.PartsListStyles
	Dim oPLSNames As New List(Of String)
	For Each oPLS As PartsListStyle In oPListStyles
		oPLSNames.Add(oPLS.Name)
	Next
	
'<<< section for applying chosen style to all PartsLists on active sheet >>>
'	Dim sPrompt As String = "Select a PartsListStyle to use."
'	Dim sTitle As String = "PartsList Styles"
'	Dim sListName As String = "PartsList Styles List"
'	Dim sChosenPLSName As String = InputListBox(sPrompt, oPLSNames, oPLSNames.Item(0), sTitle, sListName)
'	If sChosenPLSName Is Nothing OrElse sChosenPLSName = "" Then Return
'	Dim oChosenPLS As PartsListStyle = oPListStyles.Item(sChosenPLSName)
'	For Each oPList As PartsList In oDDoc.ActiveSheet.PartsLists
'		oPList.Style = oChosenPLS
'	Next
'<<< end of that section >>>

'<<< set list of names as multi-value text type user parameter >>>
	Dim oUParams As UserParameters = oDDoc.Parameters.UserParameters
	Dim oUParam As UserParameter = Nothing
	Dim sParamName As String = "PartsListStyleNamesList"
	Try
		oUParam = oUParams.Item(sParamName)
	Catch
		oUParam = oUParams.AddByValue(sParamName, "", UnitsTypeEnum.kTextUnits)
		'may need to add extra set of double quotes around each entry to get it to work
		iLogicVb.Automation.MultiValueSetValueOptions(True)
		iLogicVb.Automation.ParamMultiValues(oDDoc, sParamName) = oPLSNames.ToArray()
		'oUParam.ExpressionList.SetExpressionList(oPLSNames.ToArray())
	End Try
	oDDoc.Update2(True)
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

mtoddHBKNF
Participant
Participant

It works great Thanks

0 Likes