Reorder-Renumber based on part list style

Reorder-Renumber based on part list style

koenroovers
Enthusiast Enthusiast
608 Views
9 Replies
Message 1 of 10

Reorder-Renumber based on part list style

koenroovers
Enthusiast
Enthusiast

Hello Everyone,


I have got an Ilogic implemented in the drawing template that reorders and renumbers the part list. For assemblies and weldments this works fine. But for mono drawings it doesn't. Can somebody help me with a line of code that checks the part list style and if it is mono then does nothing?

 

Mono part list style:

Parts List - Mono (Kieu)

 

Thanks in advance.

Koen

 

Code is below:

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList1 As PartsList
oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
oPartsList1.Sort("Opmerkingen", 1, "Kodenummer", 1)
oPartsList1.Renumber 

 

0 Likes
Accepted solutions (2)
609 Views
9 Replies
Replies (9)
Message 2 of 10

Michael.Navara
Advisor
Advisor

You are looking for this?

If oPartsList1.Style.Name = "Parts List - Mono (Kieu)" Then Return

 

0 Likes
Message 3 of 10

koenroovers
Enthusiast
Enthusiast

Sadly this is not the solution

0 Likes
Message 4 of 10

Michael.Navara
Advisor
Advisor
0 Likes
Message 5 of 10

koenroovers
Enthusiast
Enthusiast

I receive the following error:

koenroovers_0-1662359636407.png

This is the rule i'm using:

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList1 As PartsList

If oPartsList1.Style.Name = "Parts List - Mono (Kieu)" Then Return 

oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
oPartsList1.Sort("Opmerkingen", 1, "Kodenummer", 1)
oPartsList1.Renumber 
0 Likes
Message 6 of 10

Michael.Navara
Advisor
Advisor
Accepted solution

You need to set oPartsList1 first (Line 5)

 

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList1 As PartsList

oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)

If oPartsList1.Style.Name = "Parts List - Mono (Kieu)" Then Return 

oPartsList1.Sort("Opmerkingen", 1, "Kodenummer", 1)
oPartsList1.Renumber 

 

 

0 Likes
Message 7 of 10

koenroovers
Enthusiast
Enthusiast

@Michael.Navara 

Thank you very much, this was the solution!

0 Likes
Message 8 of 10

koenroovers
Enthusiast
Enthusiast

Hello @Michael.Navara 

Is there also a way to perform a check if there is a BOM present before executing the rule? 
Sometimes i create drawings without a BOM. And the rule doesn't have to be run in this case. 

0 Likes
Message 9 of 10

tyler.warner
Advocate
Advocate
Accepted solution

@koenroovers you can add a check for the PartsLists.Count:

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

If oSheet.PartsLists.Count = 0 Then
	Return
Else
	Dim oPartsList1 As PartsList
	oPartsList1 = oSheet.PartsLists.Item(1)
	
	If oPartsList1.Style.Name = "Parts List - Mono (Kieu)" Then Return 
	Try
		oPartsList1.Sort("Opmerkingen", 1, "Kodenummer", 1)
		oPartsList1.Renumber 
	Catch
	End Try
End If
If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
Message 10 of 10

koenroovers
Enthusiast
Enthusiast

Thank you @tyler.warner this worked!

0 Likes