BOM Sorting Issue

I’m using the BOM Sorting macro to sort the BOMs in my drawing. The macro works perfectly for smaller sized BOMs but give inconsistent results when using with a BOM of large assembly (100 + rows). Anyone has faced similar issues? If yes where you able to find any solution or workaround?

Unfortunately I can not share the files.

Thank you in advance for any help.

Have not seen this before. Can you specify the inconsistencies you’re facing?

The sort is not working as expected. It works well on smaller BOMs but not on larger BOMs.

Can you please check the codes and suggest any changes?

It’s very hard to give a solution without seeing code and/or having a test assembly.

I’m basically throwing darts in the dark.

It seems the delta here is the data not the API. Several issues that come to mind:

  • Custom properties data type (number vs text) affects the sort logic.
  • Indented BOMs are sorted differently than parts-only or top levels.
  • Untrimmed text could affect the sort logic too.

Amen, thank you for your inputs. I’ve shared the link for the macro in the first post.

Here is it again the BOM Sorting macro

The BOM is top level and sorting is done by the column numbers. Interestingly, the sorting works OK on smaller BOMs but gives inconsistent results when using with a BOM of large assembly (100 + rows).

In case anyone is still trying out, the solution from Hansjoerg here helped solved the issue BOM Sorting Issue - CAD Forum

If you want to short only list:

List<List<string>> NewFilterList = new List<List<string>>();
...bla bla....
//NewFilterList[index][0] = "1.1.10"; etc.
 NewFilterList.Sort((x, y) =>
	int ret = 0;
	var xsplit = x[0].Split(".".ToCharArray()).Select(z => int.Parse(z, CultureInfo.InvariantCulture)).ToList();
	var ysplit = y[0].Split(".".ToCharArray()).Select(z => int.Parse(z, CultureInfo.InvariantCulture)).ToList();
	for (int i = 0; i < Math.Max(xsplit.Count, ysplit.Count); i++)

		if (xsplit.Count - 1 < i)
			ret = -1;
			return ret;
		else if (ysplit.Count - 1 < i)
			ret = 1;
			return ret;
			ret = xsplit[i] - ysplit[i];
			if (ret != 0)
				return ret;
return ret;

I prefer this code script.