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.pfcSolid.*; import com.ptc.pfc.pfcModelItem.*; import java.io.*; import java.util.*; import java.text.*; public class Make_BOM { static Session curSession; static final String MSGFILE = "bom.txt"; public static void start() { try { curSession = pfcGlobal.GetProESession(); UICommand inputCommand = curSession.UICreateCommand("Make BOM", new BOM_Listener(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 BOM_Listener extends DefaultUICommandActionListener { static Session session; static Model model; static BOMExportInstructions bom_instrs; public BOM_Listener(Session sess) { session = sess; } public void OnCommand () { try { String DateStg = getDatestgsh(); session=pfcGlobal.GetProESession(); model=session.GetCurrentModel(); String full_name = model.GetFullName(); String bom_name = full_name + "." + DateStg + ".bom"; bom_instrs = pfcModel.BOMExportInstructions_Create(); model.Export(bom_name, bom_instrs); String get_RL = model.GetReleaseLevel(); String get_REV = model.GetRevision(); String get_VER = model.GetVersion(); String inf_name = full_name + "." + DateStg + ".inf"; try { PrintStream ff = new PrintStream(new FileOutputStream(inf_name)); ff.println( "Release Level: " + get_RL ); ff.println( "Revision: " + get_REV ); ff.println( "Version: " + get_VER ); ff.flush(); ff.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 String getDatestgsh() { SimpleDateFormat df = new SimpleDateFormat ("MMddyy", Locale.getDefault()); Date tm = new Date(); String dateinst = df.format(tm); return dateinst; } }