Sort Sheets in IDW

Sort Sheets in IDW

Anonymous
Not applicable
2,503 Views
11 Replies
Message 1 of 12

Sort Sheets in IDW

Anonymous
Not applicable

Looking for an iLogic Snippet to sort the sheets in the browser. I see there is an ad-in for 2015 but I'm still on 2014. Any help many thanks.

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

MechMachineMan
Advisor
Advisor

Sort by name, or some other criteria?


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 12

Anonymous
Not applicable

Sort by name.

Thanks

0 Likes
Message 4 of 12

Anonymous
Not applicable
Accepted solution

Hello,

 

just did this :

 

Sub Main

	Dim drawingDoc As DrawingDocument = ThisDoc.Document
	Dim sheet As Sheet = Nothing
	Dim sheetsList As New List(Of Sheet)
	Dim browserPane As BrowserPane = drawingDoc.BrowserPanes.Item("Model")

	For Each sheet In drawingDoc.Sheets
		sheetsList.Add(sheet)
	Next
	
	sheetsList.Sort(AddressOf Comparer)
	
	For Each sheet In sheetsList
		Dim sheetNode As BrowserNode = browserPane.GetBrowserNodeFromObject(sheet)
		Dim bottomNode As BrowserNode = browserPane.TopNode.BrowserNodes.Item(browserPane.TopNode.BrowserNodes.Count)
		browserPane.Reorder(bottomNode, False, sheetNode)
	Next
	
End Sub

Private Function Comparer(x As Sheet, y As Sheet) As Integer
	Return String.Compare(x.Name,y.Name)
End Function

So you can just copy/paste it in an iLogic Rule, its pretty working 🙂

 

Best regards,

Message 5 of 12

Anonymous
Not applicable

Thanks It works

0 Likes
Message 6 of 12

Anonymous
Not applicable

I cut and pasted into 3 drawings with a number of sheets and it works fine. On the 4th one (with 2 sheets) I get the attached error.

When putting the code into my templates I get the same error. Probably because there is nothing to sort.

Ideas?

0 Likes
Message 7 of 12

Anonymous
Not applicable

Looks like There needs to be at least 3 sheets to work. With One ore Two it will error.

 

Steve

0 Likes
Message 8 of 12

Anonymous
Not applicable
Can you show me a printscreen of the Inventor instance so I can ses your drawing content?
0 Likes
Message 9 of 12

Anonymous
Not applicable

Here is a screen shot. Works with 3 sheets or more.

Steve

0 Likes
Message 10 of 12

mikhail_tsarev
Enthusiast
Enthusiast

Thanks for your code!

 

But for some reason it doesn`t work with my files... 

Here is a screenshot of the error message:error2.JPG

 

I would be very grateful if you could help me to find the solution. My knowledge of ilogic is not enough to identify the cause of such a behavior.

 

!UPD!

I found the solution! I need to replace "Model" with "Модель" (because I use the localized version and the name of the browser panel is translated). Now it works really good (and with DWG too)!

Thank you!

0 Likes
Message 11 of 12

Anonymous
Not applicable
I have had a stroke. Can’t think like I used to. Post like I did and ask your question to the masses.
0 Likes
Message 12 of 12

Anonymous
Not applicable

You are welcome!

0 Likes