Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

iLogic to Change Drawing's Part List Style

felix.cortes5K3Y2
Advocate

iLogic to Change Drawing's Part List Style

felix.cortes5K3Y2
Advocate
Advocate

Hi Forum,

 

I have two different Part List Styles that I use on my drawings and I am trying to write a code to switch in between them. Lets say I have a Part List Style named as "Style One" and "Style Two". Here's what I got so far:

 

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oPartsList As PartsList = oDrawDoc.ActiveSheet.PartsLists(1)
oPartsList.Style() = "Style Two"

 

This code doesn't seem to work. Anyone have an idea?

 

Thanks,

- Felix Cortes

0 Likes
Reply
Accepted solutions (1)
698 Views
3 Replies
Replies (3)

rhasell
Advisor
Advisor
Accepted solution

Hi

Try this.

Once you have got it working, expand the code to include a multivalue list, allowing a wider selection.

 

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oPartsList1 As PartsList
oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
			oPartsList1.Style = oDrawDoc.StylesManager.PartsListStyles.Item("Style Two")

 

 

Reg
2025.2

felix.cortes5K3Y2
Advocate
Advocate

Thanks rhasell

 

How could I add a multilist? Seems like iLogic only has a limited input boxes

0 Likes

rhasell
Advisor
Advisor

Hi

 

Here is a copy of my code.

You will need to create a parts list style for each configuration.

The code is not triggered, so it has to be run after a change is made.

 

'Apply Parts List Filter
'Created 17/07/2017
'PRTL = Parts List
'Reg Hasell

Sub Main
	'Choose the parts list, 1 is the first one placed.
	oPRTL = InputBox("Choose the Parts List", "Parts List Filter", "1")

	'Create a multi value list if not there.
	Call Create_Params()
	Call ApplyFilter(oPRTL)

End Sub

Sub Create_Params()
	' Get the UserParameters collection
	Dim userParams As UserParameters
	userParams = ThisDoc.Document.Parameters.UserParameters
	'check for parameter and create if not found
	Try
		oPartslist = Parameter("Parts_List")
	Catch
		'multi-value text parameter
		userParams.AddByValue("Parts_List", "ALL", UnitsTypeEnum.kTextUnits)
		'Option of two types, this is also present in the Global Form
		MultiValue.SetList("Parts_List", "ALL", "No_Fasteners", "Fasteners_Only")
	End Try
	Parameter.Param("Parts_List").IsKey​ = True
End Sub

Sub ApplyFilter(oPRTL)
	On Error Resume Next
	Dim oDrawDoc As DrawingDocument
	oDrawDoc = ThisApplication.ActiveDocument

	Dim oPartsList1 As PartsList
	oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(oPRTL)
	oPartslist = Parameter("Parts_List")
	If oPartslist = "ALL"
		oPartsList1.Style = oDrawDoc.StylesManager.PartsListStyles.Item("Parts List")
	Else If oPartslist = "No_Fasteners"
	oPartsList1.Style = oDrawDoc.StylesManager.PartsListStyles.Item("Parts List-NoFasteners")
	Else If oPartslist = "Fasteners_Only"
	oPartsList1.Style = oDrawDoc.StylesManager.PartsListStyles.Item("Parts List-Fasteners")
	End If
End Sub
Reg
2025.2