Skip to main content
August 24, 2017
Question

Add text file to drawing using jlink

  • August 24, 2017
  • 1 reply
  • 5821 views

 I am trying to add a text file of notes to a drawing using JLink. I have tried using code shown by PTC Located here: https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS206301&lang=en&source=snippet

 but when I change the string to a line read it fails. Here is the code I am using:

 

DetailNoteItem note = null;
DetailTextLines allLines = DetailTextLines.create();
int number=0;
while(lineRead!=null) // example shows for 3 lines. However, this could be the actual number of lines present in your input text file on disk
{

String iLineText = "Test " + number; This works but if I change number to lineRead it fails.

DetailTexts iDetailTexts = DetailTexts.create();
iDetailTexts.insert(0, pfcDetail.DetailText_Create(iLineText));
allLines.insert(number, pfcDetail.DetailTextLine_Create(iDetailTexts));
lineRead = textList.readLine();
number++;
}
textList.close();
// Allocate a note description, and set its properties
DetailNoteInstructions instrs = pfcDetail.DetailNoteInstructions_Create(allLines);
instrs.SetLeader(allAttachments);
// Create the note
note = (DetailNoteItem) drawing.CreateDetailItem(instrs);
note.Show();

1 reply

20-Turquoise
August 24, 2017

Where is the code that is opening and reading the text file?

What is lineRead?

What is the error message?

August 24, 2017

String textFile = "C:\\data\\Standards\\std-notes\\test.txt";
BufferedReader textList = new BufferedReader(new FileReader(textFile));
String lineRead = textList.readLine();

 

No error message.

 

I would prefer to just add the note from file but I am not sure how to do that and have not found any code to show how to do that either.

20-Turquoise
August 24, 2017

@unknown wrote:

String textFile = "C:\\data\\Standards\\std-notes\\test.txt";
BufferedReader textList = new BufferedReader(new FileReader(textFile));
String lineRead = textList.readLine();

 

No error message.


Ok then what line of code is it failing at?