Hallo,ich möchte mit Jlink (WF3) eine vereinfachte Darstellung in einer Baugruppe erzeugen und Komponenten ersetzen.
Folgender Code soll in erster Annäherung alle Komponenten einer Baugruppe ausschließen:
import com.ptc.cipjava.*;
import com.ptc.pfc.pfcAssembly.*;
import com.ptc.pfc.pfcFeature.FeatureType;
import com.ptc.pfc.pfcFeature.Features;
import com.ptc.pfc.pfcSession.Session;
import com.ptc.pfc.pfcSimpRep.*;[CODE][/CODE]
import com.ptc.pfc.pfcComponentFeat.*;
import javax.swing.JOptionPane;
public class mysimprep
{
public mysimprep(Session session, Assembly Baugruppe)
{
try
{
SimpRepCompItemPath itempath = null;
SimpRepItem simitem = null;
ComponentFeat cmp_feat = null;
Features components = Baugruppe.ListFeaturesByType(new Boolean(true), FeatureType.FEATTYPE_COMPONENT);
intseq int_path = intseq.create();
SimpRepExclude sre = pfcSimpRep.SimpRepExclude_Create();
SimpRepItems simprepitems = SimpRepItems.create();
for (int i = 0; i < components.getarraysize(); i++)
{
cmp_feat = (ComponentFeat)components.get(i);
int_path.set(i, cmp_feat.GetId());
itempath = pfcSimpRep.SimpRepCompItemPath_Create(int_path);
simitem = pfcSimpRep.SimpRepItem_Create(itempath);
simitem.SetAction( sre);
simitem.SetItemPath(itempath);
simprepitems.set(i, simitem);
}
CreateNewSimpRepInstructions instrs = pfcSimpRep.CreateNewSimpRepInstructions_Create("Test");
instrs.SetDefaultAction(SimpRepActionType.SIMPREP_EXCLUDE);
instrs.SetItems((SimpRepItems)simprepitems);
SimpRep sr = Baugruppe.CreateSimpRep(instrs);
sr.SetInstructions(instrs);
Baugruppe.ActivateSimpRep(sr);
}
catch (jxthrowable x)
{
JOptionPane.showMessageDialog ( null, "simprep Fehler", "Fehler", JOptionPane.ERROR_MESSAGE );
}
}
}
Pro/E erstellt zwar eine vereinfachte Darstellung unter dem Namen "Test" und der Standartregel "Exclude" in der Baugruppe, die Komponenten sind aber lediglich inaktiv und nicht excluded.
Ich habe folgende Fragen:
- wo liegt der Fehler?
- wie muß ich den Code umschreiben, um einzelne Komponenten zu ersetzen (substitude)?
Vielen Dank im Vorraus
Tella Nu
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP