Co-ords as a label

Any questions regarding the practice version are asked and answered here.
Post Reply
Paul Wood
Posts: 59
Joined: Thu Jun 13, 2013 8:14 am

Co-ords as a label

Post by Paul Wood »

Need to know if there is a simple function, to label a point with the co-ords (x, y and z) for that particular point
Dylan Revell
12d Support
Posts: 310
Joined: Thu Apr 05, 2007 2:46 pm

Post by Dylan Revell »

Hi,

I see you are posting this in the Practice Version forum.

In V9 you can run the Strings > Label Vertices option twice to get the x coord and y coord labelled.

In Version 10 you can use the Drafting > Text and Tables >Information Leader to very quickly place a leader arrow and label the x,y or x,y,z coordinates of a point.

Dylan
Paul Wood
Posts: 59
Joined: Thu Jun 13, 2013 8:14 am

Post by Paul Wood »

Thanks Dylan
Paul Wood
Posts: 59
Joined: Thu Jun 13, 2013 8:14 am

Post by Paul Wood »

Thanks Dylan

Your reply was very helpful, I was able to label the co-ords to point through drafting, but it seems when I label just a level, it only uses 2 decimal points. Is there somewhere I can edit this.

Cheers
darren mckimm
Posts: 373
Joined: Fri Oct 21, 2005 9:24 am

Post by darren mckimm »

i have a macro that creates x, y, z, names or ID

its a very good macro, but i cant remember where i got it from. may have been in the forum macro database. thank you to whoever wrote this.

here is the code you can copy to a .4dm file and compile.

daz

#include "set_ups.H"
#include "standard_library.H"

void manage_a_panel()
// ----------------------------------------------------------
// ----------------------------------------------------------
{


// create the panel
Panel panel = Create_panel("Label Vertices w");
Vertical_Group vgroup = Create_vertical_group(-1); Set_border(vgroup ," ");
Message_Box message = Create_message_box(" ");


//-----------------------------------------------------------------------------------------------------

Source_Box source_box = Create_source_box("to Label",message,Source_Box_All | Source_Box_Standard);

Append(source_box ,vgroup);

Textstyle_Data_Box text_data_box3 = Create_textstyle_data_box("TextStyle",message,Show_std_boxes);

Textstyle_Data textdata3;

Set_textstyle(textdata3,"Garrison Sans");
Set_colour (textdata3, 2); Set_text_type(textdata3,2);
Set_size (textdata3,2);
Set_offset (textdata3,1.5);
Set_raise (textdata3,1.5);

Set_data(text_data_box3,textdata3);

Append(text_data_box3,vgroup);



Vertical_Group deflt_grp = Create_vertical_group(1); Set_border(deflt_grp ," Label : ");


//--------------------------------------------------------------

Named_Tick_Box lblname_box2 = Create_named_tick_box("ID ",1," ");
Append(lblname_box2,deflt_grp);

Named_Tick_Box lblname_box3 = Create_named_tick_box("Name",1," ");
Append(lblname_box3,deflt_grp);

Vertical_Group deflt_grp2 = Create_vertical_group(-1); Set_border(deflt_grp ," Label : ");

Named_Tick_Box lblname_box4 = Create_named_tick_box("X ",0," ");
Append(lblname_box4,deflt_grp2);


Named_Tick_Box lblname_box5 = Create_named_tick_box("Y ",0," ");
Append(lblname_box5,deflt_grp2);


Named_Tick_Box lblname_box6 = Create_named_tick_box("Z ",1," ");
Append(lblname_box6,deflt_grp2);

Integer_Box decint_box4 = Create_integer_box("Num dec places",message);
Set_data(decint_box4,3);

Append(decint_box4 ,deflt_grp2);
Append(deflt_grp2,deflt_grp);

/*
Named_Tick_Box lblname_box7 = Create_named_tick_box("attribute",0," ");
Append(lblname_box7,deflt_grp);

Input_Box att_name = Create_input_box("att name",message);
Append(att_name,deflt_grp);
*/

Append(deflt_grp,vgroup);








// -------------- model -----------------------------------
Model_Box Mod_box1;
switch ("c") {

case "c" : {
Mod_box1 = Create_model_box("Model for Labels",message,CHECK_MODEL_CREATE);
} break;

case "e" : {
Mod_box1 = Create_model_box("Model for Labels",message,CHECK_MODEL_EXISTS);

} break;

case "me" : {
Mod_box1 = Create_model_box("Model for Labels",message,CHECK_MODEL_MUST_EXIST);
} break;

}

Append(Mod_box1,vgroup);


//--------------------------------------------------------------





// buttons along the bottom

Horizontal_Group bgroup = Create_button_group();

Button process = Create_button("&Label","count");

Button finish = Create_button("&Finish" ,"finish");

Append(process,bgroup);

Append(finish ,bgroup);

Append(message,vgroup);

Append(bgroup ,vgroup);

Append( vgroup ,panel);

// -----------------------------------------------------------


Text pptext;


Integer page;


Show_widget(panel);

Integer doit = 1;

while(doit) {

Integer id;

Text cmd;

Text msg;

Integer ret = Wait_on_widgets(id,cmd,msg);

if(cmd == "keystroke") continue;

switch(id) {

case Get_id(panel) : {



if(cmd == "Panel Quit") doit = 0;

} break;

case Get_id(finish) : {

if(cmd == "finish") doit = 0;

} break;






case Get_id(process) : {

Uid start_id = Get_next_uid();

// ----------------------- Validate tick boxes -------------------------------------

Integer tickbox2,tickbox3,tickbox4,tickbox5,tickbox6,tickbox7 ;

Validate(lblname_box2,tickbox2);
Validate(lblname_box3,tickbox3);
Validate(lblname_box4,tickbox4);
Validate(lblname_box5,tickbox5);
Validate(lblname_box6,tickbox6);

// --------------- Validate Textstyle boxes -------------------------------------------------

Textstyle_Data settextdata3;
Validate(text_data_box3,settextdata3);

// --------------- Validate Decimal boxes -------------------------------------------------
Integer decpl;

Validate(decint_box4,decpl );

// --------------- Validate Model boxes -------------------------------------------------

Model mod1 ;

Integer err = Validate(Mod_box1,GET_MODEL_CREATE,mod1);
if(err != MODEL_EXISTS) break;

// --------------- Get Elements -------------------------------------------------

Integer ierr;
Dynamic_Element elt;

ierr = Validate(source_box,elt);
if(ierr != TRUE) {

Set_data(message,"Invalid source choices");
break;
}
Integer no_items=0;
Element string;

// --------------- process Elements and create text -------------------------------------------------
Text user;
Get_user_name(user);

Get_number_of_items(elt,no_items);
for(Integer i=1;i<=no_items;i++) {

Get_item(elt,i,string);

Integer numpts=0;

Get_points(string,numpts);

Text strname;
Get_name(string,strname);

Text datetime;
Time(datetime);

for(Integer j=1;j<=numpts;j++) {

Real x1,y1,z1;

Get_data(string,j,x1,y1,z1);

Text vrtid;
Get_super_vertex_point_number (string,j,vrtid);

Text label_text;

if( tickbox2 == 1 ) {
label_text = vrtid;
}
if( tickbox3 == 1 ) {
if ( label_text == "" | label_text == " " ) {
label_text = strname ;
}else {
label_text = label_text + "\\n" + strname ;
}
}
if( tickbox4 == 1 ) {
if ( label_text == "" | label_text == " " ) {
label_text = To_text(x1,decpl);
}else {
label_text = label_text + "\\n" + To_text(x1,decpl) ;
}
}
if( tickbox5 == 1 ) {
if ( label_text == "" | label_text == " " ) {
label_text = To_text(y1,decpl);
}else {
label_text = label_text + "\\n" + To_text(y1,decpl) ;
}
}
if( tickbox6 == 1 ) {
if ( label_text == "" | label_text == " " ) {
label_text = To_text(z1,decpl);
}else {
Integer zerr = Is_null(z1);
if( zerr == 0 ) { label_text = label_text + "\\n" + To_text(z1,decpl) ; }
}
}


Element idelt = Create_text( label_text , x1,y1, 1, 1,0,1,1,0 ,0);

Set_text_textstyle_data(idelt,settextdata3);

Integer colrs;
Get_colour (settextdata3,colrs);

Set_colour(idelt,colrs);

Set_name(idelt,strname);

Set_attribute(idelt,"Created by",user); Set_attribute(idelt,"Created at",datetime);

Calc_extent(idelt);

Set_model(idelt,mod1);

} // for j
} // for i

Set_data(message, "Labels DONE! " );

Uid end_id = Get_last_uid();

Add_undo_range("Label Vertex BMs",start_id,end_id);

Null(elt);

} break;

}

}

}


void main()
//---------------------------------------------------------
//
//---------------------------------------------------------
{
manage_a_panel();
}
Dylan Revell
12d Support
Posts: 310
Joined: Thu Apr 05, 2007 2:46 pm

Post by Dylan Revell »

Once you run an info leader in a project, a file called Info_Leader_Create_Panel is created in the .project folder.

You can edit this in a text editor and change the default decimal places for results and other settings.

If you want to use this on all your projects you can copy this file into your User Library.

Dylan
Paul Wood
Posts: 59
Joined: Thu Jun 13, 2013 8:14 am

Post by Paul Wood »

Cheers Dylan

Info supplied was very helpful
John Fowler
Posts: 11
Joined: Tue Jun 11, 2013 12:22 pm

Post by John Fowler »

Dylan Revell wrote:In V9 you can run the Strings > Label Vertices option twice to get the x coord and y coord labelled.
Could you not just run the Strings => Label Vertices => x,y label mode once to achieve the same outcome?
Dylan Revell
12d Support
Posts: 310
Joined: Thu Apr 05, 2007 2:46 pm

Post by Dylan Revell »

Yep. But I prefer to have them one on top of the other.

Dylan
Scott Wadley
Posts: 86
Joined: Thu Jan 12, 2006 12:43 pm

Post by Scott Wadley »

Darren,

I compiled and used the macro you posted for ages.
But since moving to a later version of v10, it now writes everything on one line

eg. PNSS\n\n315899.351\n6262459.445\n62.365

I have recompiled it 10.0c1k but same issue occurs.

Any ideas on what has caused this ?

Regards,
Scott.
Michael Gunter
Posts: 1736
Joined: Fri Oct 21, 2005 8:47 am

Post by Michael Gunter »

"\\n" should be "\n", that can't have ever worked?
darren mckimm
Posts: 373
Joined: Fri Oct 21, 2005 9:24 am

Post by darren mckimm »

i have gone through many posts and have found the source of the source code.

it is Sam Cech of course and the link to this post is below. the title of the post is "
Putting xyz Co-ords on screen" in the design section of the forum.. the link below should get to it as i found it though the search section.

http://forums.12dmodel.com/viewtopic.ph ... ox3+vgroup

its three pages long and has additional info about SA co ords, etc.

mick, scott

i know the macro worked in V9, havent used in V10. may have to discuss the new errors with Master Sam to resolve.
i can read the code, but dont understand it much.

at least i have found the source for you all to devour and recreate a V10 / V11 macro.

daz
Matthew Monk
Posts: 3175
Joined: Fri Oct 21, 2005 2:46 pm

Post by Matthew Monk »

Re: newlines. There was a change somewhere between V9 and V10 with regards to how newlines were handled. Had to do with Unicode, multi-line text fields and file paths containing \n .
Scott Wadley
Posts: 86
Joined: Thu Jan 12, 2006 12:43 pm

Post by Scott Wadley »

Fixed.
Replaced \\n with \n and recompiled.

Thanks.
Post Reply