import com.ptc.cipjava.*; import com.ptc.pfc.pfcSession.*; import com.ptc.pfc.pfcGlobal.*; import com.ptc.pfc.pfcCommand.*; import com.ptc.pfc.pfcModel.*; import com.ptc.pfc.pfcModelItem.*; import com.ptc.pfc.pfcSolid.*; import com.ptc.pfc.pfcModelItem.*; import com.ptc.pfc.pfcAssembly.*; import com.ptc.pfc.pfcComponentFeat.*; import com.ptc.pfc.pfcFeature.*; import com.ptc.pfc.pfcBase.*; import com.ptc.pfc.pfcDimension.*; import com.ptc.pfc.pfcGeometry.*; import com.ptc.pfc.pfcLayer.*; import com.ptc.pfc.pfcExceptions.*; import java.io.*; import java.util.*; import java.text.*; public class Test_BOM2 { static Session curSession; static final String MSGFILE = "bom.txt"; public static void start() { try { curSession = pfcGlobal.GetProESession(); UICommand inputCommand = curSession.UICreateCommand("Make BOM", new Test_BOM_Listener2(curSession)); curSession.UIAddButton(inputCommand, "Applications", "Applications.psh_util_pproc", "Make_BOM", "Create_BOM", MSGFILE); } catch(jxthrowable x) { System.out.println("Exception:"+x); } } public static void stop() {} } class Test_BOM_Listener2 extends DefaultUICommandActionListener { static Session session; static Model curmodel; static Assembly assy; static Models models; static Vector [] modelData; static String eol="
", eol2="

"; public Test_BOM_Listener2(Session sess) { session = sess; } public void OnCommand () { try { SimpleDateFormat df = new SimpleDateFormat ("MMddyy_HHmmss", Locale.getDefault()); Date tm = new Date(); String DateStg = df.format(tm); session=pfcGlobal.GetProESession(); curmodel=session.GetCurrentModel(); String full_name = curmodel.GetFullName(); models = session.ListModels(); //models = curmodel.ListModels(); int modelCount = models.getarraysize(); modelData = new Vector [modelCount]; for (int i = 0; i< modelCount; i++) { getModelInfo(i); } String inf_name = full_name + "." + DateStg + ".htm"; try { PrintStream vf = new PrintStream(new FileOutputStream(inf_name)); vf.println( "" ); vf.println( " " + inf_name + " BOM " ); vf.println( "" ); vf.println( "
" ); vf.println( "

" + inf_name + " BOM


" ); for (int i =0; i" ); vf.println( "
**********

" ); } vf.println( "

" ); vf.flush(); vf.close(); } catch(java.io.IOException IOEx) { System.out.println("Cannot create " + inf_name + " file."); } } catch (jxthrowable x) { System.out.println ("Caught exception: "+x); x.printStackTrace (); } } public void getModelInfo(int index) throws jxthrowable { Vector data_i; Model model_i; ModelType type; ModelDescriptor desc; Integer versionStamp; String get_RL, get_REV, get_VER, GenName, InstName, typeString; String name, mtypeString, path, fname, ftypeString, fstatusString; String itemtypeString, feattypeString; model_i = models.get(index); data_i = new Vector (10); name = model_i.GetFullName(); name = "Model Name: " + name + eol; data_i.addElement(name); desc = model_i.GetDescr(); path = desc.GetPath(); path = "File Directory/Folder Path: " + path + eol; data_i.addElement(path); get_RL = model_i.GetReleaseLevel(); get_RL = "Release Level: " + get_RL + eol; data_i.addElement(get_RL); get_REV = model_i.GetRevision(); get_REV = "Revision Level: " + get_REV + eol; data_i.addElement(get_REV); get_VER = model_i.GetVersion(); get_VER = "Version: " + get_VER + eol; data_i.addElement(get_VER); type = model_i.GetType(); mtypeString = pfctypeclass.pfcModelType[type.getValue()]; mtypeString = "Model Type: " + mtypeString + eol; data_i.addElement(mtypeString); itemtypeString = pfctypeclass.pfcModelItemType[type.getValue()]; itemtypeString = "Model Item Type: " + itemtypeString + eol; data_i.addElement(itemtypeString); feattypeString = pfctypeclass.pfcFeatureType[type.getValue()]; feattypeString = "Feature Item Type: " + feattypeString + eol; data_i.addElement(feattypeString); InstName = model_i.GetInstanceName(); InstName = "Instance Name: " + InstName + eol; data_i.addElement(InstName); GenName = model_i.GetGenericName(); GenName = "Generic Name: " + GenName + eol; data_i.addElement(GenName); modelData[index] = data_i; return; } }