January 30, 2012

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?

Advertisement

You might also interested to:

  1. Insert block without being asked to input value
  2. Using Multiple Hyperlinks with Block Attributes
  3. Showing Common AutoCAD Information in Title Block
  4. Reporting Multiple Coordinates in A Block using Attribute Extraction
  5. Using AutoLISP Program to label point coordinate

Search for more articles

Custom Search
About Edwin Prakoso

Application Engineer. Jakarta, Indonesia.
5+ years experience as CAD engineering application. Autodesk Revit Architecture 2010 certified professional, and certified CATIA part design specialist. Also have sufficient knowledge about AutoCAD, MicroStation, and Inventor.
If you're in Jakarta and need my assistance, email me at info @ cad-notes.com. Or mention me on twitter @cad_notes

  • Edwin Prakoso

    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.

  • Anonymous

    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?

  • Anonymous

    Brilliant!
    Haven't tried it yet but it's just what I was looking for.
    Much neater than ordinate dimensions.

  • Anonymous

    Brilliant!
    Haven't tried it yet but it's just what I was looking for.
    Much neater than ordinate dimensions.

  • http://www.blogger.com/profile/17111411452875625308 Edwin Prakoso

    to Anonymous:
    Thank you, glad you find it useful :)

  • Edwin Prakoso

    to Anonymous:
    Thank you, glad you find it useful :)

  • http://www.cad-notes.com EdwinPrakoso

    test

  • Luis Fernando

    VERY GOOG !!!!!!! I DID

  • Leeds1ManU0

    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)

  • http://www.cad-notes.com EdwinPrakoso

    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 :)

  • moahmmedturabuddin

    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.

  • http://www.cad-notes.com EdwinPrakoso

    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.

  • http://www.cad-notes.com EdwinPrakoso

    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.

  • Kely

    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!!!

  • http://www.cad-notes.com EdwinPrakoso

    Glad this is useful :) Please share this tip to everyone who might need it!

  • Hug

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

  • http://www.cad-notes.com EdwinPrakoso

    I’m not sure. I don’t have C3D so I can’t try it. You can get the information in an AutoCAD table btw. Is this close to what you are looking for? Reporting Multiple Coordinates

  • StuArchitect

    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?

  • http://www.cad-notes.com EdwinPrakoso

    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 :)

  • AJITH

    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

      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 ;)

      • AJITH

        THANK YOU FOR QUICK RESPONSE

        No…I tried REGEN & SAVE also..but it is not working :(

        • Edwin Prakoso

          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?

  • AJITH

    Thank You Edwin ..

    Now it is working.
    Thank You Very much. :)

    • Edwin Prakoso

      I’m glad you manage to solve this problem :)

  • http://products.construction.com/QuickLinks/caddetails Construction

    Great article. You really broke it down so it is very easy to follow along. Thanks a lot.

  • Matthew

    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.

    • http://cad-notes.com Edwin Prakoso

      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?

  • Ross Q.

    Thanks you so much for a very very useful Tips.

  • Jeffrey

    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.

    • http://cad-notes.com Edwin Prakoso

      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.

  • Shawki abo zeed

    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
    “\nPick 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
    “\nPick text location: “))
    (command “LEADER” PNT1 PTXT “” XCOORD YCOORD ZCOORD”")
    (command “SETVAR” “osmode” OSNAP)
    (princ)
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  • B.

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

    • http://cad-notes.com Edwin Prakoso

      B.,
      Is the properties palette also empty when you select other objects? Or only when following this tutorial? In which step do you have this problem?

  • Tom

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

    • http://cad-notes.com Edwin Prakoso

      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.

  • Ernesto Fraga

    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

    • http://cad-notes.com Edwin Prakoso

      Hi Ernesto,
      It should be no problem. The fields will recognize the coordinate in active UCS. You don’t need to use world UCS to make it work.

  • huang

    Hi, my block only shows positions XY in relation to world ucs but not to current ucs. How could I fix it? Thanks!

  • http://cad-notes.com Edwin Prakoso

    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.

  • Paul French

    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.

    • http://cad-notes.com Edwin Prakoso

      Paul,
      I suspect that you don’t use unique tag name. I found the same problem before. This article may explain why that happened.
      I’m glad you enjoy the tutorial :)

      • Paul French

        Thanks,

        That is exactly what was wrong, it works perfectly now.

        Thanks for your help.

  • Pingback: AutoLISP program for labeling coordinate | CAD Notes

  • Pingback: Mastering CAD » Blog Archive » Using AutoLISP Program to label point coordinate

  • Pingback: The best 100 AutoCAD productivity tips - the ultimate list | CAD Notes

  • Calum Nesbitt

    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

    • http://cad-notes.com Edwin Prakoso

      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…

  • Kara

    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?

    • http://cad-notes.com Edwin Prakoso

      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.

  • Afaque

    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

  • Rolando

    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!

    • http://cad-notes.com Edwin Prakoso

      Glad that you find it useful ;)
      You may also want to consider using AutoLISP program. I wrote this tutorial too, if you want to try it.

  • Rolando

    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.

    • http://cad-notes.com Edwin Prakoso

      It’s the downside of this method. It only works for current file, and only for WCS. If you’re working with XREF or UCS coordinate, AutoLISP works better.