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

jlink table.SetText (cell, lines);

amedina
1-Visitor

jlink table.SetText (cell, lines);

So I wrote a java program to read some tables. However now I want it to
modify the tables to add text and parameters to specific tables using a
function like in the manual. like this:

writeTextInCell (theTable, 5, 2, "REV"); (for text
writeTextInCell (theTable, 5, 3, "&asm.mbr.PROI_REVISION"); (for
the parameter)

In the end, I run the script, a window pops up expecting me to click on a
table, I click on the table, two extra columns are added and the bottom
column is merged. However I get no text.

Anyone knows how to add text to a cell??

thanks

regards

Alfonso


Here are the important parts on this complete breakfast:

currentModel = (Model2D) model;
tables = currentModel.ListTables();
TableCell cell1,cell2;
Table theTable = null;
String cellName;

SelectionOptions selops=null;
Selections sel = null;
selops = pfcSelect.SelectionOptions_Create("dwg_table");
selops.SetMaxNumSels(new Integer(1));
sel = session.Select(selops,null);
sel.get(0).UnHighlight();
theTable = (Table)sel.get(0).GetSelItem();
writeLog("Found table in drawing with
"+String.valueOf(theTable.GetColumnCount())+" columns and
"+String.valueOf(theTable.GetRowCount())+" rows");
//break;
writeLog(model.GetFullName());

theTable.InsertColumn(5, 4, false);
theTable.InsertColumn(15, 5, false);
theTable.MergeRegion (pfcTable.TableCell_Create(1,1),
pfcTable.TableCell_Create(1,6), false);
writeTextInCell (theTable, 5, 2, "REV");
writeTextInCell (theTable, 5, 3, "&asm.mbr.PROI_REVISION");
writeTextInCell (theTable, 6, 2, "RELEASE LEVEL");
writeTextInCell (theTable, 6, 3, "&asm.mbr.PROI_REVISION");
writeTextInCell (theTable, 7, 3, "test");
theTable.Display();




/*====================================================================*\
FUNCTION : writeTextInCell()
PURPOSE : Utility to add one text line to a table cell
\*====================================================================*/
private static void writeTextInCell(Table table, int row,
int col, String text)
throws com.ptc.cipjava.jxthrowable
{
TableCell cell = pfcTable.TableCell_Create (row, col);
stringseq lines = stringseq.create();
lines.insert (0, text);
table.SetText (cell, lines);
}
1 REPLY 1

I had them reopen this for anyone else having this problem.  One of the creo examples has the below function you can use to resolve this issue.

function writeTextInCell(table /* pfcTable */, row /* integer */,
  col /* integer */, text /* string */)
{
var cell = pfcCreate ("pfcTableCell").Create (row, col);
var lines = pfcCreate ("stringseq");
lines.Append (text);
table.SetText (cell, lines);
}
 
Announcements


Top Tags