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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How to make a note with box in JLink??

robbiep
3-Newcomer

How to make a note with box in JLink??

Hi Everyone, I‘m a newcomer in JLink, so I have occurred a lot of problems during developing, but there is a little problem which I have not idea how to fix. This problem is about making customize note with box in drawing, but I cannot make note success in a box with leader. Just see my code following:

 

public static void setNoteDetail(Session session, Selection sel) throws jxthrowable {
		Model currentModel = session.GetCurrentModel();
		WoodSelection woodSel = new WoodSelection();
		Window win = session.GetCurrentWindow();
		win.Activate();
		if(currentModel.GetType() != ModelType.MDL_DRAWING) {
			return;
		}
		Drawing currentDrawing = (Drawing) currentModel;
		
//		font definition

		DetailText detailText = pfcDetail.DetailText_Create("@[123@]");
		DetailTexts detailTexts = DetailTexts.create();
		AnnotationTextStyle anotationTextStyle = pfcDetail.AnnotationTextStyle_Create();
		
		anotationTextStyle.SetHeight(3.5);
		detailText.SetTextStyle(anotationTextStyle);
		detailTexts.set(0, detailText);
		
		DetailTextLine detailTextLine = pfcDetail.DetailTextLine_Create(detailTexts);
		DetailTextLines detailTextLines = DetailTextLines.create();
		
		detailTextLines.set(0, detailTextLine);
		
		
		View2D view = sel.GetSelView2D();
		Point3D point = sel.GetPoint();
		Transform3D transformMatrix = view.GetTransform();
		point = transformMatrix.TransformPoint(point);
		
		FreeAttachment freeAttachment = pfcDetail.FreeAttachment_Create(point);
		freeAttachment.SetView(view);
		
		DetailNoteItem detailNoteItem = currentDrawing.CreateFreeNote(detailTextLines, freeAttachment);
		
//		arrow definition

		ParametricAttachment leaderParaAttachment = pfcDetail.ParametricAttachment_Create(sel);
		LeaderAttachment leaderAttachment = pfcDetail.LeaderAttachment_Create(leaderParaAttachment);
		LeaderAttachments leaderAttachments = LeaderAttachments.create();
		leaderAttachments.set(0, leaderAttachment);

		detailNoteItem.SetLeaders(leaderAttachments);

		detailNoteItem.Show();
		detailNoteItem.IsDisplayed();
	}

 

Well, I got result with this code just see the picture, the note without box,

robbiep_0-1576558167597.png

 

I do not know why , how to input text in JLink can CreO display note with box??

4 REPLIES 4
James62
12-Amethyst
(To:robbiep)

I didn't try running the code but, it seems like the '@' ']' '[' chars are being stripped and are not part of the text of the resulting note. Is that the case?

 

'@' is a unicode character.

 

Also see if the API allows for setting the text after the note is placed on the drawing. Doesn't look like the API is buggy, but it's worth a shot anyway.

robbiep
3-Newcomer
(To:James62)

Hello James62, thanks for your reply! Just like you see, '@' ']' '[' chars are being stripped in text when I add note with leader, if I comment the code of leader attachment definition( the following code), all the chars can be displayed right, you can see the following picture.

// leader attachment definition
ParametricAttachment leaderParaAttachment = pfcDetail.ParametricAttachment_Create(sel);
LeaderAttachment leaderAttachment = pfcDetail.LeaderAttachment_Create(leaderParaAttachment);
LeaderAttachments leaderAttachments = LeaderAttachments.create();
leaderAttachments.set(0, leaderAttachment);

detailNoteItem.SetLeaders(leaderAttachments);

 

robbiep_0-1576634878068.png

 

James62
12-Amethyst
(To:robbiep)

Ok, it looks like a bug. I didn't try to reproduce it. Surely the J-Link API isn't perfect. If you can report it to PTC please do.

Dale_Rosema
23-Emerald III
(To:robbiep)

It might be related to this:

 

https://community.ptc.com/t5/Simulation/GD-amp-T-text-boxes-in-Creo-3/m-p/322783

 

In the WYSISYG text box, you cannot do the @[ @], but this is available by editing the text in the properties box.

Announcements


Top Tags