I have to make utility to generate bill of material for an assembly , For this what steps I have to follow to automate the BOM.
You have several options for this.
One is to use ProOutputFileMdlnameWrite with export file type set to PRO_BOM_FILE.
This will write the assembly bill of materials to a file similar to the one produced by the "Bill Of Materials" command from the ribbon. From this point you can manipulate the file according to you needs.
Another option is to visit all features in the assembly model using ProSolidFeatVisit. You will have to look for features of PRO_FEAT_COMPONENT type and get the model name and count for each separate component
Can you explain in detail using your first method. Is this in Creo or Windchill? "One is to use ProOutputFileMdlnameWrite with export file type set to PRO_BOM_FILE"
ProOutputFileMdlnameWrite is an Pro/Toolkit API and is to be used under Creo.
The use of the API is pretty straight forward. Check the toolkit documentation for details and code examples.
To add another idea, We define a repeat Region on sheet2 of the assembly drawing. a repeat region is quite common to assembly drawings. The benefits are that you can add filters to control the appearance of items, and you can add any parameters if you wish. I use toolkit to dump the table to a usable text file. During that process I add some unit-of-measure conversion on certain parts where the Creo UOM differs from our Business systems.