Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
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?
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
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?
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.
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.
TBH either we are just trying to find a more efficient way to make sure people know when they need to change certain parameters
since the original question tagged 'Toolkit'...
If one feels adventurous - retrieve an assembly into session and in the internal creo browser open 'script_engine_testing.html' from 'Common FIles/apps/creojs/creojsweb'. In 'script engine' frame open script 'assembly_structure.js' from the pull-down list of default scripts. The script, out-of-the-box, will print the whole assembly tree - modify the script to count components and feed the value into a parameter (sample code is in 'test_parameters.js'). To make it fully automatic setup model listeners (sample code is in 'model_retrieve_listener.js')
just a thought.
From Pro/Toolkit/OTK API standpoint - the main action will be in a recursive visit function for feature type PRO_FEAT_COMPONENT, use a custom relation or a listener to call the function to automate the process.
HIH.
HIH.
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.
Let me try thtat out and see how much we can automat cause the main goal is automation where possible
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.
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.