import com.ptc.cipjava.jxthrowable; import com.ptc.pfc.pfcAssembly.Assembly; import com.ptc.pfc.pfcComponentFeat.ComponentFeat; import com.ptc.pfc.pfcComponentFeat.ComponentFeats; import com.ptc.pfc.pfcFeature.Feature; import com.ptc.pfc.pfcFeature.FeatureStatus; import com.ptc.pfc.pfcFeature.FeatureType; import com.ptc.pfc.pfcFeature.Features; import com.ptc.pfc.pfcModel.Model; import com.ptc.pfc.pfcModel.ModelDescriptor; import com.ptc.pfc.pfcModel.ModelType; import com.ptc.pfc.pfcSession; import com.ptc.pfc.pfcGlobal; public class pAssembly { private Session curSession; private Model resolvedModel; private Assembly curAsm; private ComponentFeats allPrt = null; private ComponentFeats allAsm = null; private Features components; public pAssembly () { try { curSession = pfcGlobal.GetCurrentSession(); } catch (Exception err) { } } public pAssembly (Model curModel) { this(); setModel(curModel); } public void setModel (Model curModel) { this(); try { this.curAsm = (Assembly)curModel; // Komponenten der obersten Ebene ermitteln components = curAsm.ListFeaturesByType (Boolean.TRUE, FeatureType.FEATTYPE_COMPONENT); } catch (Exception err) { } } public Features getRootComponents () { return components; } public void getComList (Model model) { setModel(model); getComList(); } // Assembly rekursiv auflösen public void getComList () { try { if (allPrt == null) allPrt = ComponentFeats.create (); if (allAsm == null) allAsm = ComponentFeats.create (); for (int a = 0; a < components.getarraysize (); ++a) { Feature curFeat = components.get(a); ComponentFeat curComp = (ComponentFeat)curFeat; ModelDescriptor curCompDescr = curComp.GetModelDescr (); if (checkall || curFeat.GetStatus () != FeatureStatus.FEAT_SUPPRESSED && curFeat.GetStatus () != FeatureStatus.FEAT_SIMP_REP_SUPPRESSED) { if (curCompDescr.GetType () == ModelType.MDL_ASSEMBLY && curCompDescr != null) { allAsm.set (allAsm.getarraysize (), curComp); Model descrModel = curSession.GetModelFromDescr(curCompDescr); if (descrModel != null) { pAssembly subAsm = new pAssembly (descrModel); subAsm.getComList (); ComponentFeats tmpp = subAsm.getParts (); for (int c = 0; c < tmpp.getarraysize (); ++c) { allPrt.set (allPrt.getarraysize (), tmpp.get (c)); ++c; } } } if (curCompDescr.GetType () == ModelType.MDL_PART && curCompDescr != null) { ComponentFeat cfeat = (ComponentFeat)curFeat; allPrt.set (allPrt.getarraysize (), cfeat); } } } } catch (jxthrowable err) { } } // Liste aller PRT' s in einer Assembly public ComponentFeats getParts () { return allPrt; } // Liste aller Assemblies und Subassemblies public ComponentFeats getAssemblies () { return allAsm; } // Anzahl der Teile in einem Modell public int getNumOfComp (Model search) { try { int number = 0; ComponentFeats tmpFeat = null; // Nacharbeiten des Modellnamen String fileName = search.GetFullName(); if (search.GetType () == ModelType.MDL_PART) tmpFeat = allPrt; if (search.GetType () == ModelType.MDL_ASSEMBLY) tmpFeat = allAsm; for (int a = 0; a < tmpFeat.getarraysize (); ++a) { ComponentFeat tempComp = (ComponentFeat)tmpFeat.get (a); ModelDescriptor tempModel = tempComp.GetModelDescr (); if (tempModel.GetFullName().toUpperCase().equals (fileName.toUpperCase())) { ++number; } } return number; } catch (jxthrowable err) { PalfLog.setError(this, ".getNumOfComp", err); return 0; } } // Liste aller Assemblies und Parts public Features getFullList () { try { Features feats = Features.create(); for (int a = 0; a < allPrt.getarraysize (); ++a) { feats.append(allPrt.get(a)); } for (int b = 0; b < allAsm.getarraysize (); ++b) { feats.append(allAsm.get(b)); } return feats; } catch (jxthrowable err) { PalfLog.setError(this, ".getFullList", err); } return null; } }