Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Select CS objects & show fields

JamesM

New member
I'm using Intralink 3.4 and trying to run a series of where-used reports in a script and save them to a file. Originally I had been writing each report to a file and going back later to remove all the header information - not a very clean way to do it. I am trying to change it to use getSelectedObjects to assign the results to a variable, then write the variable to a file. The problem is that I need certain fields to show in the file and when I use getSelectedObjects, all that is returned is the part name. Part of the code is below. Is there a way to use getSelectedObjects and then manipulate the item to show the desired fields?


IL.deselectAll( "PIV" );
IL.select( "PIV", line2 );
IL.openWindow( "WhereUsedReport", "", "" ); // generate where-used report
IL.openWindow( "TableConfig", "", "" ); // open table config window
IL.setTableConfiguration( "<current>" );
IL.removeAllVisibleColumns( );
IL.addVisibleColumn( "Name" );
IL.addVisibleColumn( "Description*" );
IL.addVisibleColumn( "Revision" );
IL.addVisibleColumn( "Release Level" );
IL.removeAllSortableColumns( );
IL.clearFilter( );
IL.addFilter( "Type Name", "=", new Object[]{"Drawing" } ); // keep drw only
IL.ok( );
IL.setCriteriaFlag( 0 ); // keep latest version only
IL.selectAll( "PIV");
Object workobjects[] = IL.getSelectedObjects ( "PIV" );
if (workobjects.length != 0)
{
fullname = workobjects[0].toString();
out.write( fullname );
out.newLine();
JOptionPane.showMessageDialog(null, "Object = " + fullname,"OK",JOptionPane.INFORMATION_MESSAGE);
}
//IL.printContent( "Where_Used_Report.txt", 1 ); // print to text file
IL.closeWindow( ); // close where-used window
 
That definitely solves the original problem of not being able to display all fields. I have to admit that I had a printout of your article on my desk and completely missed that.


Another problem that has appeared now happens when the getTableCellValue method encounters a null object. I'm doing where-used reports on a series of files and some are not used anywhere. This causes a


Invoke: com.ptc.intralink.client.cs.report.CSGenericReportEventManag er.getTableCellValue(PIV,0,0,{null})


To try to catch these, I am trying


Object workobjects = IL.getTableCellValue ( "PIV", 0, 0 );
if (workobjects != null)
{
fullname = workobjects.toString();
out.write( fullname );
out.newLine();
}



but with no success. I have never had good luck with detecting null objects in Java but am not sure why. Any thoughts?
 
For some examples of handling exceptions in Intralink Scripting,
refer to my other Pro/Files article:

http://www.profilesmagazine.com/p37/mettes.html


To catch the exception most likely you will need to do something
like this:

Object valObj = null;

try {
valObj = IL.getTableCellValue( "PIV", 0, 0 );
if (workobjects == null) {
// didn't get a decent value, use some default
}
else {
// got a good value, use it
}
}
catch (Exception e) {
// getTableCellValue() totally failed, deal with it
}


Most likely the exception is probably occuring deep inside Intralink
code, not in your own, so you have to catch it there.
 

Sponsor

Back
Top