Check if drawing parts list is splitted

Check if drawing parts list is splitted

goran_nilssonK2TWB
Contributor Contributor
235 Views
4 Replies
Message 1 of 5

Check if drawing parts list is splitted

goran_nilssonK2TWB
Contributor
Contributor

Hello!

 

I want to check if drawing parts list is splitted. If it's splitted I want to get a message.

My code is using On error resume next, so it's not possible to use a Try.

I can't find any information if it's possible or not.

 

/Goran

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

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Hi @goran_nilssonK2TWB . I haven't found anything in the API to help tell if a table is splitted, so it looks like the only way to know if your table is splitted is to look in the browser. I found a solution to the problem on the forum, this is a VBA solution, if you need iLogic, here is the code:

 

Public Sub Main()
	Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
	If oDDoc Is Nothing Then Exit Sub  
	Dim oBrowserPane As BrowserPane = oDDoc.BrowserPanes.ActivePane
	Dim oTopBrowserNode As BrowserNode = oBrowserPane.TopNode   
	Dim oBrowserNode As BrowserNode    
	For Each oBrowserNode In oTopBrowserNode.BrowserNodes
		Dim oBrowserNode2 As BrowserNode
		For Each oBrowserNode2 In oBrowserNode.BrowserNodes
			Dim oNativeObject As Object = oBrowserNode2.NativeObject
			If TypeName(oNativeObject) = "PartsList" Then
				If oBrowserNode2.BrowserNodes.Count > 0 Then
					MsgBox("Parts List is split")
				Else
					MsgBox("Parts List is NOT split")
				End If
				Exit For
			End If
		Next
	Next       
End Sub

 

 

 

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 5

jclements7LNR5
Participant
Participant

I have an alternative method to determine if a parts list is split as I often have multiple parts lists on the same drawing/sheet and I don't want the routine to update the split sections just the main.

 

 

Sub main
	Dim DrawingDoc = ThisApplication.ActiveEditDocument
	Dim modelState As Integer = 0
	For Each oSheet In DrawingDoc.Sheets
		itemNumber=1
		While itemNumber < 10
			Try
				oPartsList = oSheet.PartsLists.Item(itemNumber)
				If modelState = oPartsList.ReferencedDocumentDescriptor.ReferencedModelState
					MsgBox("Parts List is split")
				Else
					MsgBox("Parts List is NOT split or this is the first occurance of it")
					modelState=oPartsList.ReferencedDocumentDescriptor.ReferencedModelState
				End If
					itemNumber = itemNumber + 1
			Catch
				Exit While
			End Try
		End While
	Next
End Sub
0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

Hi @jclements7LNR5.  Is that actually working for you.  It doesn't seem like it could work, because the PartsList.ReferencedDocumentDescriptor.ReferencedModelState property returns a variation of the ModelStateTypeEnum.  Each variation of that Enum has a name and an Integer type value, but none of its numerical values is zero.  At the beginning of your rule, you declared a variable named "modelState" as an Integer, then set its initial value to zero.  Then the first check is if any of the ModelStateTypeEnum variations equals that zero value, which it seems would always be False...at least for the first PartsList it encounters, but then that global variable would have a different value for any further iterations.  Because then, after it evaluates to False, it will go to the 'Else' portion of that block of code, where it is 'setting' the value of that variable to whichever ModelStateTypeEnum variation's numerical value it finds there.  Since the variable was declared outside of the iteration, the value it got assigned in the previous iteration will carry over into the new iteration, so if there were more than one PartsList on that sheet, it would be comparing the previous ModelStateTypeEnum numerical value from that variable against the value of that property in the next PartsList, instead of checking it against the original zero value.  Was the design intention here to see if two or more PartsLists on that sheet point to different types of ModelStates?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

jclements7LNR5
Participant
Participant

Setting the value to "0" is purposeful.  At least in the way I am using this I want to grab each parts list on the drawing/sheet once, sort and reorder.  I am ignoring the splits so that the numbered reordering stays sequential.  The split parts list have the same number for each split and are always grabbed sequentially so the updating the modelState integer allows the splits to be ignored.  I tweaked my code to be less specific to my situation when posting.