How to: Label Coordinate in AutoCAD

I had this question several times: can we automatically label our coordinate in AutoCAD? If you are Civil3D user, then you most likely will suggest them to use C3D. But can AutoCAD actually do it? YES!

I saw many people use AutoLISP to do that task. It works great. But sometimes you may want to have your own labeling symbol and format. So, why not using field?


Creating a reference object

First, we need to create an object as a reference point. It can be a point, a circle, or any symbol you want it to appear. I use this symbol.

reference object

I prefer to use point or circle. We can easily use the point position or circle center.

Creating an Attribute Definition

After we have the reference object, we need to define an attribute definition. You can activate it by clicking it on your ribbon, home tab, block panel.

attdef

Or simply type ATTDEF then [enter].

Let’s define our attribute. Give the attribute tag, prompt like below. In default field, type ‘X Y = ‘ then click insert field.

define attribute

Change the field category to objects, and in field names, select object. Click select object button to define the object type. Select the circle, don’t select anything else!

field category

AutoCAD will list all available properties. Select center (or if you use point, select position). Because I only use it in 2D drawings, I don’t need it to display Z value. I turn it off. Change the format if necessary.Click OK.

define property

Click OK again to close the define attribute dialog box. Place your attribute definition in desired location.

Optional: Define Adjustable Leader

If you don’t want to have leader in your coordinate label, you can skip this step.

I add a line that will be used as leader.

leader line

Create the Block

Now we can define the block. Click create from ribbon, block panel.

create block

Select all the objects, and define the center as insertion point. Activate Open in Block Editor on lower left of this dialog. We are going to add some ‘dynamic’ functionality. Click OK.

AutoCAD will show the edit attribute dialog. We don’t want to modify it as it is updated automatically. Just click OK.

Add the Control Grip

What we want to do is adding a grip control, so we can modify the text (and optionally leader) placement. In block authoring palette, activate the point parameter.

point parameter

Now place it where you want the grip appear.

point parameter placement

Now activate the stretch action.

Select the point parameter, create the stretch frame like below, and select the line and attribute definition. [Enter] to end it.

cross polygon

Now we are done! Save this block and close block editor.

Using the Label

How we can use the label? Just insert the block, and click on the point you want to show the coordinate. After you have one of the block in your drawing, you can copy it and place it on several points you wanted.

Because we add a control grip, we can move the text and leader position!

control grip

Because we use field, if you move your points, the value will be automatically updated! Very cool, isn’t it?

Why Attribute Definition? Why not Just Use Text?

You might ask this: why not just use text with field? I know we can insert field within text, single or multiline. But it doesn’t work. You may want to try it by yourself.

Apparently the field will consider the reference point always at 0,0,0 when you create a block. It works if you don’t create a block from them, but I believe you want to use it as reusable content, aren’t you?

Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *

  1. Eliska says

    Hi Edwin,

    this information is great! However, I have a question.

    I received a drawing with hundreds of blocks with coordinates and need to export them to .txt file. Is there any way to name each one of them (eg. A01, A02, etc.), so I don’t have to manually re-write the exported file?

    Thank you very much!

    Eliska

    • says

      Hi Eliska,
      You can open the text file in Microsoft Excel and add the text there. Then you can save it to CSV or other text format. I think that is faster than modifying the drawing.
      You can also modify the attributes. But depends on your block, the best workaround may vary.

      • Eliska says

        Thank you, Edwin!

        I have found easy way how to export attributes coordinates straight to .txt file with names of blocks already. Express tools -> Export attributes.

        But the problem is, that I cannot see the block names in ACAD. Is there any way I can see name of the block in my .dwg?

        Thank you very much!

  2. Kevin Joyner says

    Edwin;

    I am trying to do something similiar to what has been explained above. I would like to create a block that contains a tag and an embedded field attribute for the purpose of calculating surface area of paver fields for landscaping material extraction.

    I can’t necessarily attached the wblock to an object as I would like to insert it into each drawing (unless the trick is to creat the block in my template) and multiple times for various pline shapes. I have created the block with the field attribute but can’t figure out how to be able to select the object it needs to calculate the surface area of for extraction.

    Where am I going wrong here?

    Thanks

    • says

      Hi Kevin,
      It’s not possible to use this block and fields for this purpose. You can’t select object after you place the block. Using LISP is the way to go.
      I’m sorry I can’t be more helpful.

  3. Alpla says

    Dear Edwin.

    That info is brilliant. Thank u a lot.

    However I want to add another idea.

    I do the same procedure in another order.

    1.- Make the circle with the crossing lines as you do.
    2.- I make a Block with that symbol.
    3.- I open the Block in order to edit it.
    4.- Only then I add the labels (as you do) and the leading line (the line connecting the symbol with the label)
    5.- I add the “point” and so on (as you do in the chapter “Add the Control Grip”)

    The difference is that I make the “labels” and the “leader line” after making the Block and inside the block editor.

    The result is a little bit different: the label and the text are really attached to each other, so whenever I move them, they move together.

    In your way I have to move the text and the leader separately.

    Best Regards

  4. Imran Shaik says

    HI,
    Edwin Prakoso
    This is imran, I have one doubt, i have more then 400 Co-ordinates to provide coordinate's, for this i can't do 400 time copy paste (coordinate point block), is there any easy way to use measure cmnd or any other cmnd. to provide in small of time all coordinate's

    thanks in advance

  5. Bailey says

    This is great thanks. I am trying to move the decimal point so that instead of it being after the 6th number I want it after the 6th, is this possible? thanks

  6. Gandhi says

    HI,
    This is Gandhi, I have one doubt, i have 50 Co-ordinates in excel if i appload the excel co-ordinates area marked in circle for single Query or lisp is it possible to do…

  7. JR says

    Hi, Edwin, yes acad is very weak in labeling both in xyz of points and bearings and dist in lines. what are the way to fix this short coming?
    JR (jr_chia@yahoo.com)

  8. Chris says

    Edwin,
    This has been very useful for me but there is one thing I would like to do but can't work out:
    My drawing is set up in millimetres and I can't change that for the purposes of how we set our drawings up, but I would like to show the co-ordinates in metres. Is there a way to automatically convert the values?

  9. TN says

    Hi Edwin, Your instruction is great!
     I followed your instruction to create a block with coordinate value, it works. I have a situation where about 50 point that I need to label with xy coordinate. I like your method, but I don't want to keep hitting "insert" and "enter" too many times; can I somehow copy this block to the rest of the locations that I want to label and have it display at the right coordinates?

    Also, is there an easier way than copy and paste to put this coordinate on the chart after the xy coordinates are label at the right locations?

    Thank you in advance.

  10. Rolando says

    Great! I have not checked this one yet but will do.. In the mean time, i attached the coordinate label blocks (discussed above) as an xref to a drawing, it shows fine but when i plot it, the coordinates shows zero values.. i have tried fieldeval but it still shows the same.. do you know why by any chance?.. thanks a lot.

  11. Rolando says

    This is really helpful for ever changing design, i created 2 attributes for x and y. i added the flip parameter as well as it needs to be on the other side sometimes.. thanks edwin!

  12. Afaque says

    Hi Edwin

    Your Block works perfectly, but I need your help in getting a label display (i.e) 1,2,3 …. or A, B, C……. in incremental or decremental order with the block when I copy the same block number of time in a same DWG. I need it because when I extract date to excel I get a column which shows 1 or A and the value.

    Please advise

    Thanks for Understanding

    Regards

  13. Kara says

    Love the post. I've created my with 2 attibute definitions to show the Y/X values, stacked. After selecting the object, point and position, I click the "Additional Format". The "Thousands number separator" is grey out. I've like to be able to show the northing/easting as ie. 6,123,123.00 and 423,123.00. Can you help?

    • says

      Kara,

      I think this is another stacking problem. I don't know how you can even make it works. Just like Calum said, all I see is ####.

      I think you need to create separate attributes.

  14. Calum Nesbitt says

    Works excellently for single line text but would like to have the X Y and Z coordinates to appear stacked as a multiline text (MTEXT) Have tried selecting field at ATTDEF stage then defining multiline in the same dialog box but ultimate result is single line of '##############' characters???

    Look forward to your reply

    • says

      Calum,
      I notice after I tried it. I haven't been able to solve it.
      Just curious, why don't you try to create three separate attributes and arrange the position to make them look stacked?
      It works, maybe require more works, but I don't think it's a big problem. We only create the block once anyway…

  15. Paul French says

    Thanks for your very helpful tutorial.

    It has all worked perfectly, I have even managed to create two attributes that show the x and y separately.

    The only problem I’m having is with the adjustable leader.

    Within my block i have created a rectangle around the attributes and attached this to the circle (object) using a leader.

    When following your guidelines i can get the leader and rectangle to move perfectly but the attributes move independently and end up elsewhere on the drawing.

    Is there anything simple I am doing wrong?

    Thanks again.

  16. says

    Ernesto and Huang,

    Apologies for my previous reply. You guys are right, it doesn't work if you move your UCS, it will always refer to 0,0. I can't find any option to correct this problem.

    You may need to reference the drawing in another drawing that using world UCS. Then you can use it there.

  17. Ernesto Fraga says

    It works for me perfectly.

    I use two attdef instead of one. (one for the "x" axis and one for the "y" axis)

    I improve the block with the dynamic block (streching and rotating) to fit in the drawing better.

    Thanks for the tip.

    One doubt. I have my "0,0" not in the original ucs and i can´t move the entire draw. Exist any solution, maybe a function that solve this?.

    Thanks.

    Ernesto Fraga

    Montevideo – Uruguay

  18. Tom says

    Thanks for the lesson. Is there anyway that I can get this to identify northing and easting instead of xy?

    Thanks again

    • says

      Tom,
      In this tutorial we are using point coordinate, so we can't get northing and easting. However, you can identify northing and easting if your object is line. It is not as easy as point, but yes, you can have it.

  19. B. says

    I am facing some errors with the tutorial whenever i select an object the property list panel is just empty.

    Can anyone help?

  20. Shawki abo zeed says

    You can also use outolisp to work 3D coord by save this file to ( xyz.lsp)

    and at your aoutcad file writ ( APPLOAD) and load xyz.lsp from your folder

    at aoutocad comand writ ( xyz) insert your point then lisp will write XYZ point

    now save this file at your PC ( XYZ.lsp)

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    (defun C:XYZ (/ OSNAP PNT1 P1X P1Y P1Z P STDX STDY STDZ XCOORD YCOORD ZCOORD PTXT )

    (setvar "ORTHOMODE" 1)

    (setq OSNAP (getvar "OSMODE"))

    (command "setvar" "osmode" "0")

    (prompt "NOTE!!! Coords. & leader drawn per current dimstyle; precision per UNITS… ")

    (setq PNT1 (getpoint

    "
    Pick coordinate point: "))

    (setq P1X (car pnt1))

    (setq P1Y (cadr pnt1))

    (setq P1Z (caddr pnt1))

    (setq P (getvar "LUPREC"))

    (setq STDX (rtos P1X 2 P))

    (setq STDY (rtos P1Y 2 P))

    (setq STDZ (rtos P1Z 2 P))

    (setq XCOORD (strcat "X " STDX ))

    (setq YCOORD (strcat "Y " STDY ))

    (setq ZCOORD (strcat "Z " STDZ ))

    (setq PTXT (getpoint

    "
    Pick text location: "))

    (command "LEADER" PNT1 PTXT "" XCOORD YCOORD ZCOORD"")

    (command "SETVAR" "osmode" OSNAP)

    (princ)

    )

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  21. Jeffrey says

    Hey Edwin,

    I followed all instructions or maybe I missed some "but the line/leader doesn't follow whenever I move the text. It's locked/fixed in the position when I made it." Any tip on this? Thanks.

    • says

      Jeffrey,
      There are 2 possibilities that crossed my mind. It can be the leader is not inside the stretch boundary or you don't select the line as the object to be stretch. If you still have problem, please upload your file, or email me as attachment so I can take a look.

  22. Matthew says

    What I'm trying to do is to have the drafter pick a "point" in layout space and if it's on top of a viewport, it will pull that "point" from model space and display the coordinate for that point, keeping a live relationship between the two. Maybe not 100% live, so that if your point moved you'd have to erase the block & redo it, but that's okay. As long as we know 100% that the coordinates are correct… its' a start.

    • says

      I don't think that's possible. Why not placing it in your model? You can use annotative blocks to control the block sizes. Or is there anything else that makes you want to use it in layout space?

  23. AJITH says

    thank you …

    But i m little confused. I am just copy pasted a small part of your solution

    "Using the Label

    How we can use the label? Just insert the block, and click on the point you want to show the coordinate. After you have one of the block in your drawing, you can copy it and place it on several points you wanted.

    Because we add a control grip, we can move the text and leader position!"

    I have a doubt in this part. In this sentence u mentioned that after inserting one block then we can copy it and place it on several points we wanted.

    This is not working.

    I copied the block and pasted it in several areas in that drawing,but the coordinate values is not changing.

    do we need to insert the block everytime ?

    I need a solution such that if i copy paste or move the block,the co ordinate values will have to change.

    is it possible?

    • Edwin Prakoso says

      Hi Ajith,

      AutoCAD fields don't update in real time. But it will be updated when you save or plot the file.

      If you want to force update it before saving/plotting, you can REGEN the drawing, then the fields will be updated ;)

        • Edwin Prakoso says

          Try to type UPDATEFIELD and select the fields you want to update. You can type ALL if you want to update all fields in your drawing.
          If it works, it's probably the FIELDEVAL system variable has changed. Type FIELDEVAL [enter] and change the value to 31.
          If it doesn't work, are you sure you created the block correctly?

  24. says

    I suspect this is something about object selection for your action. Can you send me the file, so I can take a look? Send the file to my email. You can find my email in about page.
    I'm sorry that I don't write my email address here. It's to avoid spam bot mining my email address :)

  25. StuArchitect says

    This is great, i followed it and even tried my own twist… i am an architect so i wanted to use it for Northings & Eastings, so i added a second attribute, so one shows Y coordiante (northing) and the other the X coordinate (easting), but when i move the leader the first attribute moves, but in completly strange way, and the second attribute does not move at all. any ideas?

  26. Hug says

    Great article…. Can I get all this information in a autocad C3d table?
    Can I also add station & offset for each point too?

  27. Kely says

    Its great!!! and you explain it very well, and it also work to other version of autocad like Autocad Map 3d. i found it very useful. thanks a lot!!!

  28. says

    I don't really get you. Let me make this clear first: you want to label your piles manually, and don't want to use TCOUNT?
    You can use text or block attributes. I suggest you to use the last one because you can create a report using data extraction later.

    Btw, please don't use capital letters in your whole comments. Some people might find it offensive.

  29. says

    Hi Turab,
    Are you trying to create a report by counting your blocks? Have you
    tried using Data Extraction? I have posted several tutorial how to use
    it, you may want to check them out.

  30. moahmmedturabuddin says

    i WAS SEARCHING FOR SOMETHING LIKE THIS AND ATLAST FOUND IT. THANK YOU VERY MUCH. I NEED ONE MORE HELP FROM YOU SIR. BEING A PILING DRAFTSMAN I NEED TO LABEL PILES ACCORDINGLY LIKE 1,2,3,4 AND SO ON. I NEED A COMMAND WHICH CAN HELP ME IN REDUCING MY WORK. I USE TCOUNT, BUT, I NEED A COMMAND WHERE I CAN MANUALLY LABEL THE PILES WIH NUMBERS. YOUR HELP WOULD BE HIGHLY APPRECIATED. THANKD AND REGADS – TURAB.

  31. says

    Yes. Fields are not updated instantly. But don't worry, they will be updated when you save, plot, or regen. So whenever you want to have a hardcopy (plot), you can't get it wrong. And your partners will see the updated values after you save and close your file.
    So it is semi automatic :)

  32. Leeds1ManU0 says

    I couldn't work out why the xy values weren't changing when I moved the blocks. I eventually found out that the blocks did update after a regen. (See FIELDEVAL variable in help for an explanation) Thank you, the XY picker is very useful! (BTW I'm using LT2010)

  33. Anonymous says

    Nice little tip, maybe this is possible to use in another way like for example for level indication. If you move your ucs to level zero and make a block like you describe without the X coord and only the Y coord. This could work don't you think?

  34. Edwin Prakoso says

    Thank you, glad you found it useful :)I believe you mean to display the level elevation in elevation/section view like in this post. Yes it could work :) But I think it's easier if we just use ordinate dimension.

Trackbacks