Skip to main content
5-Regular Member
September 16, 2022
Question

Counting Parts using relations

  • September 16, 2022
  • 4 replies
  • 4628 views

Hi all,

 

so i was wondering if there is a way to count the amount of parts in a assembly or creo file using relations i was to create a relation that basically states that 

if number of parts <50 

use parameter x 

else if number of parts => 50 

use parameter y

 

is this possible?

4 replies

tbraxton
22-Sapphire II
22-Sapphire II
September 16, 2022

Creo will report the number of components in an assembly. I am not sure if this qty is available as a system parameter though. If you can capture this reported number in a parameter, then you should be able to do it.

 

See how to report the # here:

https://www.ptc.com/en/support/article/CS32738 

 

If you have a drawing, you can create a custom BOM table.

https://www.ptc.com/en/support/article/CS70231 

 

5-Regular Member
September 16, 2022

Saw those articles too the problem is i have to do extra steps to get the numbers im hopeing to do something more automated. is there a parameter or setting that creo uses for BOMs? 

24-Ruby III
September 16, 2022

Hi,

parameter that contains the number of assembly components that Creo would automatically update does not exist. You have to somehow find out the number of assembly components and then enter the number into the parameter. 

23-Emerald III
September 16, 2022

ModelCheck can also report on the number of components in an assembly but not sure if that information can be extratcted to a Creo parameter. That would be a nice enhancement.

Another enhancement would be for Creo to expose the number of components in an assembly since the assembly file does know which files are contained in it.

Do you need total number of components in an assembly or number of unique components in an assembly. Those 2 numbers could vary widely.

5-Regular Member
September 19, 2022

TBH either we are just trying to find a more efficient way to make sure people know when they need to change certain parameters

1-Visitor
September 18, 2022

It is possible.

 

However, I don't know whether it is possible within Creo.

 

If I am in your situation, I would do as follow:

 

1. Create a new drawing for the assembly.

2. Add a repeat region, using rpt.qty to get the number of each component.

3. Get the sum of the number of all components (https://support.ptc.com/help/creo/creo_pma/usascii/index.html#page/detail/To_Get_a_Summation_of_Parameter_Values_of_a_Repe.html)

If you create a template after putting the parameter holding the sum to the table, the sum will be automatically calculated after you create a drw using that template.

4. Export the repeat region, then delete the newly created drawing.

5. Read the exported file to get the total number of parts (using an automation script, eg. Autohotkey or Python)

6. Add the relations (that you wrote in your question, although some minor syntax changes are needed) to the asm file and regenerate. (I recommend using ModelCHECK to add the relations.)

 

7. Using a script to automate the whole process (from step 1 to step 6), then you can use a shortcut/hotkey, (eg. Control+Shift+G) to reevaluate total number of parts and update your parameter. 

5-Regular Member
September 19, 2022

Let me try thtat out and see how much we can automat cause the main goal is automation where possible

1-Visitor
September 19, 2022

I think we can fully automate this.

 

I forgot to mention that to add the relations using modelCheck, the .mcs file should be updated before the check. Of course we can use the script to do the update.

 

More over, because you know the number of parts and have to update the .mcs file anyway, you can forget about relations, and directly use one parameter with two possible values. I means, for example, if the number of parts is 60, you know that the parameter value must be the value of y, then you can simply add the line

 

ASM_PARAMETER	SingleParam STR EQ Y

 to the .mcs file, then run ModelCheck. 

 

If the number of parts is 40, add the line 

ASM_PARAMETER	SingleParam STR EQ X

instead. By doing so, you don't need relations. The comparison with 50 is done by the script.

 

There is another way that does not require modelCheck. At step 6, we can record two mapkeys corresponding to two cases, i.e. number of parts bigger or smaller than 50. After getting the number of parts, we can simply trigger one of the mapkeys using the script.

 

joe_morton
18-Opal
18-Opal
September 28, 2022

Maybe you could use Alternate Mass somehow? I haven't played around with this to see if it's actually viable, but my idea would be to set all parts with an Alternate Mass = 1. Then the total mass of the assembly would give the count of all part occurrences.