Page 1 of 1

BOM Sorting Issue

Posted: Fri Sep 16, 2022 1:46 pm
by gupta9665
I'm using the attached 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.
BOM SORTING.swp
(29.5 KiB) Downloaded 263 times

Re: BOM Sorting Issue

Posted: Sun Sep 18, 2022 6:35 pm
by josh
Have you tried doing a manual sort through the UI using he exact same parameters?

How is it inconsistent? Does the same BOM sort the same every time, just not as you expect? Or does the same BOM sort differently if you run it twice?

You've specified literal sort order. This will cause 10, 11, 12, etc to come before 2. Is that what you're expecting?

Re: BOM Sorting Issue

Posted: Mon Sep 19, 2022 3:31 am
by Hansjoerg
What a coincidence, I ran into the exact same problem last week. I have also written a macro to sort the parts list, and also with me the sorting results were partly not correct.

However, for me it was not dependent on the number of lines in the BOM, but on the type of BOM used.

With the type "only parts" it worked correctly. With the type "top level only" the sorting was not usable.

My VAR gave me great support in solving the problem.
He found out that a missing setting in my templates triggered the problem.

I used the following command in the macro to set the missing setting in the template:

IModelDocExtension::SetUserPreferenceToggle(swUserPreferenceToggle_e.swOneConfigOnlyTopLevelBom, swUserPreferenceOption_e.swDetailingNoOptionSpecified, <OnFlag>)

After that, the BOM of the top level were also sorted correctly

Re: BOM Sorting Issue

Posted: Mon Sep 19, 2022 7:26 am
by AlexLachance
Hansjoerg wrote: Mon Sep 19, 2022 3:31 am What a coincidence, I ran into the exact same problem last week. I have also written a macro to sort the parts list, and also with me the sorting results were partly not correct.

However, for me it was not dependent on the number of lines in the BOM, but on the type of BOM used.

With the type "only parts" it worked correctly. With the type "top level only" the sorting was not usable.

My VAR gave me great support in solving the problem.
He found out that a missing setting in my templates triggered the problem.

I used the following command in the macro to set the missing setting in the template:

IModelDocExtension::SetUserPreferenceToggle(swUserPreferenceToggle_e.swOneConfigOnlyTopLevelBom, swUserPreferenceOption_e.swDetailingNoOptionSpecified, <OnFlag>)

After that, the BOM of the top level were also sorted correctly


Now, this is the kind of support we should be having and expecting.

Re: BOM Sorting Issue

Posted: Mon Sep 19, 2022 7:59 am
by gupta9665
josh wrote: Sun Sep 18, 2022 6:35 pm Have you tried doing a manual sort through the UI using he exact same parameters?

How is it inconsistent? Does the same BOM sort the same every time, just not as you expect? Or does the same BOM sort differently if you run it twice?

You've specified literal sort order. This will cause 10, 11, 12, etc to come before 2. Is that what you're expecting?
Thank you for your reply Josh.

Manually sorting is working prefect every time with same settings. And this macro works perfect on small top level BOMs but give incorrect results when used on a large assembly BOM.

I've tried changing literal to numeric but macro still doesn't work.

Re: BOM Sorting Issue

Posted: Mon Sep 19, 2022 8:01 am
by gupta9665
Hansjoerg wrote: Mon Sep 19, 2022 3:31 am My VAR gave me great support in solving the problem. He found out that a missing setting in my templates triggered the problem.

I used the following command in the macro to set the missing setting in the template:

IModelDocExtension::SetUserPreferenceToggle(swUserPreferenceToggle_e.swOneConfigOnlyTopLevelBom, swUserPreferenceOption_e.swDetailingNoOptionSpecified, <OnFlag>)

After that, the BOM of the top level were also sorted correctly
Thank you for your inputs Hansjoerg, let me check with this setting and confirm.

Re: BOM Sorting Issue

Posted: Mon Sep 19, 2022 11:37 am
by gupta9665
Hansjoerg wrote: Mon Sep 19, 2022 3:31 am I used the following command in the macro to set the missing setting in the template:

IModelDocExtension::SetUserPreferenceToggle(swUserPreferenceToggle_e.swOneConfigOnlyTopLevelBom, swUserPreferenceOption_e.swDetailingNoOptionSpecified, <OnFlag>)

After that, the BOM of the top level were also sorted correctly
Hansjoerg, this setting did the trick. The macro is working perfect now. Thank you for your help.

Re: BOM Sorting Issue

Posted: Tue Sep 20, 2022 11:39 am
by Hansjoerg
The thanks do not belong to me but to this user -> @RonE
He is the one who found the solution.