cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

J-link: question about selection

jaapkramer
1-Newbie

J-link: question about selection

Hi,

I have a question about selection of models with J-Link. I made a Part Properties query tool, which givesme a specific list of properties of the modelthat I pick with the mouse.

This works great when an assembly is loaded, but it doesn't work when there's just one model on the screen. In that case, I click on the part, but nothing happens. What I'd like is that when I start the J-Link tool, it determines whether there's an assy on the screen or just a single part. If it's an assembly, the user has to select the desired part. If there's just one model on the screen,J-Link should simply select that model and give me it's properties.

Does anyone know how to make that work in J-link??
Below is the code I use now for the selection.

Thanks!
Regards,

Jaap

private void partProp() {
Session session2 = null;
try {
session2 = pfcGlobal.GetProESession();
} catch (jxthrowable xx) {
UIHelper.showException(xx, "getting Pro/E session");
}
SelectionOptions sel_options;
Selection selektie;
Model model;
ComponentPath modelPath;
intseq parentIds;
Assembly modelParent;
ComponentPath parentPath = null;
String modelParentString = ";
try {
File file = new File("C:\\local\\temp\\PartProp.txt");
if (file.exists()) {
file.delete();
}
int max = 1;
sel_options = pfcSelect.SelectionOptions_Create("prt_or_asm");
sel_options.SetMaxNumSels(new Integer(max));
Selections selekties = session2.Select(sel_options, null);
selektie = selekties.get(0); //select first element
model = selektie.GetSelModel();
Solid solid = (Solid) model;
// etcetera.....
This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
1 REPLY 1



In Reply to Bjarne Frandsen:

Thanks all for the advice. My code now works fine. here's the code:

private void partProp() {
Session session2 = null;
try {
session2 = pfcGlobal.GetProESession();
} catch (jxthrowable xx) {
UIHelper.showException(xx, "getting Pro/E session");
}
SelectionOptions sel_options;
Selection selektie;
Model model;
Model curModel;
ComponentPath modelPath;
intseq parentIds;
Assembly modelParent;
ComponentPath parentPath = null;
String modelParentString = ";
try {
File file = new File("C:\\local\\temp\\PartProp.txt");
if (file.exists()) {
file.delete();
}
int max = 1;
curModel = session2.GetCurrentModel();
ModelType t = curModel.GetDescr().GetType();
//staat er een assy open of alleen een model??
if (t.equals(ModelType.MDL_ASSEMBLY)){
sel_options = pfcSelect.SelectionOptions_Create("prt_or_asm");
sel_options.SetMaxNumSels(new Integer(max));
Selections selekties = session2.Select(sel_options, null);
selektie = selekties.get(0); //1e element selecteren
model = selektie.GetSelModel();
}else {
model = session2.GetCurrentModel();
}
Solid solid = (Solid) model;

(etcetera)

regards,

Jaap

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags