Sketch blocks order

Sketch blocks order

francesco_rossato
Enthusiast Enthusiast
1,127 Views
9 Replies
Message 1 of 10

Sketch blocks order

francesco_rossato
Enthusiast
Enthusiast

Hello everyone,

 

I'm creating a sketch blocks library with all the engravings we use in our products.

As some engravings will be added in a second step, my question is: is it possible to alphabetize the blocks folder? I don't seem to find this option in Inventor.

 

Thank you!!

 

Francesco

0 Likes
Accepted solutions (1)
1,128 Views
9 Replies
Replies (9)
Message 2 of 10

SharkDesign
Mentor
Mentor

Drag them into the order you want. I don't know if another way. 

 

 

  Inventor Certified Professional
0 Likes
Message 3 of 10

francesco_rossato
Enthusiast
Enthusiast

Hello James, and thank you for your reply!

 

unfortunately I can't drag the blocks. I thought it was the right method but that's not the case.

 

Francesco

0 Likes
Message 4 of 10

SharkDesign
Mentor
Mentor
Oh, sorry, I didn't have chance to try it yet, assumed that would be how it
works! 😂


  Inventor Certified Professional
Message 5 of 10

SharkDesign
Mentor
Mentor
Accepted solution

Long winded way of doing it.

 

  • Place all your blocks when you're done. 
  • Right click them and explode them all.
  • Recreate the blocks in the order that you want them.
  •  
  Inventor Certified Professional
Message 6 of 10

johnsonshiue
Community Manager
Community Manager

Hi Francesco,

 

I don't believe there is a way to do that. It is because the browser node is by creation order. Also, Block B could depend on Block A. As a result, it cannot be reordered.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 7 of 10

A.Acheson
Mentor
Mentor

Here is an iLogic partial solution to sorting sketch blocks . The only drawback is that it will not sort sketch blocks that are depended on each other. 

 

 

'[Concept:
'Before running this rule, ensure you test on a sample document and also back up your template.   
'This rule is to be run from an internal rule or external rule with the template part document containing the sketch blocks active. 
'It will create a list Of sketch blocks and sort the list
'Then add the Sketch block to a new part file in alphabetical order. 
'The rule will skip sketch blocks that are depended on each other, these will need to be reordered manually.

'Helpful Starting link
'https://forums.autodesk.com/t5/Inventor-ilogic-api-vba-forum/ilogic-copy-blocks-part-To-part/td-p/10008199

']

'[Start Of Rule
	'Document to copy from
	Dim FromDoc As PartDocument 
	FromDoc = ThisDoc.Document
	
	'Create new document
	Dim oNewDoc As PartDocument
	ToDoc = ThisApplication.Documents.Add(kPartDocumentObject, "", True)'Replace "" with template fullfileName if specific template is needed

	Dim BlockNames As New ArrayList
	Dim BlockName As String

	'Loop through all the Blocks in the Template
	For Each oFromBlock As SketchBlockDefinition In FromDoc.ComponentDefinition.SketchBlockDefinitions
		'Get sketch block by name 
		BlockName = oFromBlock.Name
		'Add block name to a list
		BlockNames.Add(BlockName)	
	Next

	'Display block names
	d0 = InputListBox("Prompt", BlockNames, d0, Title := "Before Sort", ListName := "Block List")

	'Sort the list of names
	BlockNames.Sort()

	'Display block names
	d0 = InputListBox("Prompt", BlockNames, d0, Title := "After Sort", ListName := "Block List")

	'Loop through sketch block names
	For Each BlockName In BlockNames
		'Loop through Sketch Block Collection
		For Each oFromBlock As SketchBlockDefinition In FromDoc.ComponentDefinition.SketchBlockDefinitions
			'Match the list to the block definition name
			If BlockName = oFromBlock.Name Then
				oFromBlock.CopyTo(ToDoc)
			End If
		Next
	Next
	'Loop through the blocks sorted and delete any that were added twice due to being dependent on other blocks. 
	For Each oToBlock As SketchBlockDefinition In ToDoc.ComponentDefinition.SketchBlockDefinitions
			'Match the list to the block definition name
			If Not BlockNames.Contains(oToBlock.Name)Then
				oToBlock.Delete
				'MessageBox.Show(oToBlock.Name, "Title")
			End If
		Next
MessageBox.Show("Sort all done!", "Champion")
'] 
'End Of Rule

Hopefully that will help anyone looking to sort blocks and save some time. 

 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 8 of 10

gcoombridge
Advisor
Advisor

That is a nice solution @A.Acheson!

 

I have done something similar and my only comment would be when sketch blocks are copied that have user parameters assigned to their dimensions, the parameter is copied to a new user parameter and loses its naming. I get around that by copying the parameter name to the comments field and renaming parameters to their comment fields later (if the comment <> ""). Comments for some reason are carried through...

 

All depends on whether the blocks are driven by parameters or not I guess...

Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399
Message 9 of 10

francesco_rossato
Enthusiast
Enthusiast

Hello @A.Acheson @gcoombridge, thank you for your reply.

 

@A.Acheson seems to be a very good solution! I'm gonna try it as soon as I can.

 

FYI, I'm not using parameters on my blocks, so there is no dependence on each other.

Francesco

0 Likes
Message 10 of 10

anthony_hendrick
Advocate
Advocate
Fantastic, thanks!
0 Likes