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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

pfcDetailNoteInstructions - TextHeight

Mat
15-Moonstone
15-Moonstone

pfcDetailNoteInstructions - TextHeight

Hi there,

I am trying to modify the text height of a table note.

What works right now is this:

var xyz = table.GetCellNote(cell);

var new_text_format = xyz.GetInstructions(false);

new_text_format.TextAngle = 12;

xyz.Modify(new_text_format);

But I want to modify the text's height not its angle.

Any suggestions?

ACCEPTED SOLUTION

Accepted Solutions
jnezu
7-Bedrock
(To:Mat)

Hello MATTHIAS

Did you already solve this problem.

Textheight of Detail note is a little bit complicated because textheight can be set by both each line and each segment of a line.

if you wanna set all texts to same height, the code will be like the following

var drawing = session.CurrentModel;

var matrix = drawing.GetSheetTransform(drawing.CurrentSheetNumber).Matrix;

var xyz = table.GetCellNote(cell);
var new_text_format = xyz.GetInstructions(false);

var new_text_lines=new_text_format.textLines;

for(var i=0;i<new_text_lines;i++)

{

var new_text_line=new_text_lines.item(i);

var new_texts=new_text_line.texts;

for(var j=0;j<new_texts.count;j++)

{

var new_text=new_texts.item(j);

new_text.TextHeight=12/matrix.Item(0, 0);//<-need to transform the coordinates

}

}


xyz.Modify(new_text_format);

View solution in original post

5 REPLIES 5
jnezu
7-Bedrock
(To:Mat)

Hello MATTHIAS

Did you already solve this problem.

Textheight of Detail note is a little bit complicated because textheight can be set by both each line and each segment of a line.

if you wanna set all texts to same height, the code will be like the following

var drawing = session.CurrentModel;

var matrix = drawing.GetSheetTransform(drawing.CurrentSheetNumber).Matrix;

var xyz = table.GetCellNote(cell);
var new_text_format = xyz.GetInstructions(false);

var new_text_lines=new_text_format.textLines;

for(var i=0;i<new_text_lines;i++)

{

var new_text_line=new_text_lines.item(i);

var new_texts=new_text_line.texts;

for(var j=0;j<new_texts.count;j++)

{

var new_text=new_texts.item(j);

new_text.TextHeight=12/matrix.Item(0, 0);//<-need to transform the coordinates

}

}


xyz.Modify(new_text_format);

Mat
15-Moonstone
15-Moonstone
(To:jnezu)

Hi Jun,

thanks for answering. I almost gave up hope solving this problem.

I will give it a try as soon as I have some spare time to work on it. Maybe by the end of this week.

Thanks a lot again.

Mat
15-Moonstone
15-Moonstone
(To:Mat)

OK, I was too curious, if this really would work.

And it does!!

After some tweaks:

var drawing = oSession.CurrentModel;

var matrix = drawing.GetSheetTransform(drawing.CurrentSheetNumber).Matrix;

var tables = drawing.ListTables();

var table = tables.Item(0); // just uses first table

var cell = pfcCreate("pfcTableCell").Create(2, 1); // this depends on the cell you like to modify

var xyz = table.GetCellNote(cell);

var new_text_format = xyz.GetInstructions(false);

var new_text_lines=new_text_format.TextLines;

for(var i=0;i<new_text_lines.Count;i++)

{

var new_text_line=new_text_lines.Item(i);

var new_texts=new_text_line.Texts;

for(var j=0;j<new_texts.Count;j++)

{

var new_text=new_texts.Item(j);

new_text.TextHeight=12/(matrix.Item(0, 0));//<-need to transform the coordinates

}

}

xyz.Modify(new_text_format);

oSession.CurrentWindow.Repaint();

drawing.Regenerate();

But, could You explain this transformation (matrix.Item(0,0))?

jnezu
7-Bedrock
(To:Mat)

Hello MATTHIAS,

The value you can get from(or set to) "pfcDetailText.TextHeight" is the value on Screen Coordinate System.

As you can see the section of "windows and views" in weblink User's Guide, there are 8 coordinate systems in Creo.

I think the textHeight value you wanna put is the value same as you input on Creo UI, right?

then the textHeight value 12 is the value on Drawing Coordinate System.

So you have to transform the value 12 from Drawing Coordinate System to Screen Coordinate System.

var matrix = drawing.GetSheetTransform(drawing.CurrentSheetNumber).Matrix;

matrix is transformation matrix information on current drawing sheet to Screen Coordinate System.

And then,

new_text.TextHeight=12/(matrix.Item(0, 0));//<-need to transform the coordinates

you can get the value on Screen Coordinate System from Drawing Coordinate System by deviding the value by matrix.item(0,0).

Please refer to "windows and views" in weblink User's Guide to transform one coordinate system to another for further information.

I hope you can solve your problem.

Jun

Mat
15-Moonstone
15-Moonstone
(To:jnezu)

Jun Nezu schrieb:

I think the textHeight value you wanna put is the value same as you input on Creo UI, right?

then the textHeight value 12 is the value on Drawing Coordinate System.

Entering values in Drawing CS would be the most intuitive to non-programmers, like I am.

This pitfall also caused some other problems. For example, in another script I place tables on a drawing. Those tables should always be right above the drawing's header.

For different kind of frames I had to end up with several empirically defined x,y cooridinates for each frame:

var table_pos_tol_x = new Array(

868.37678685,

813.91200899,

736.53198624,

627.38095237,

353.69318130);

var table_pos_tol_y = new Array(

183.01881810,

231.03076678,

298.13762649,

393.30357170,

387.78409102);

I look forward to simplify this mess.

Thanks again for Your help!

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags