Jump to content

Label Co-ordintes


daiharv

Recommended Posts

I'm using AutoCAD 2007.

 

I have the lsp below for labeling co-oredinates.

 

Unfortunately in one drawing I've recieved the points are lebelled in metres, but drawn in mm.

 

It would make my life much easier if the lsp below could be amended to take this into account. So rather than give co-ord of 949846.00,2474211.00, I would like it read as 949.846,2474.211.

 

Unfortunatly I not good enough to amend the lsp.

 

Are any of you abel to amend it?

 

Many thanks.

 

(defun c:lblpt () 
  (setq precis 2);;set decimal places here 
  (while 
    (setq pt (getpoint "\nSelect point to label: ")) 
    (setq Xval (car pt) Yval (cadr pt)) 
    (setq Xtxt (rtos Xval 2 precis)) 
    (setq Ytxt (rtos Yval 2 precis)) 
    (command "text" pt "" "0" Xtxt) 
    (command "text" "" ytxt) 
  );while 
(princ) 
)
(prompt
 "\nType lblpt to run command."
)
(princ)

Edited by SLW210
Add CODE TAGS!!
Link to comment
Share on other sites

Divide coordinates to 1000.

(defun c:lblpt () 
(setq precis 2);;set decimal places here 
(while 
(setq pt (getpoint "\nSelect point to label: ")) 
(setq Xval (/(car pt)1000) Yval (/(cadr pt)1000)) 
(setq Xtxt (rtos Xval 2 precis)) 
(setq Ytxt (rtos Yval 2 precis)) 
(command "text" pt "" "0" Xtxt) 
(command "text" "" ytxt) 
);while 
(princ) 
)
(prompt
"\nType lblpt to run command."
)
(princ)

Link to comment
Share on other sites

May be standard DIMORDINATE with text override better... It can move after picking point

 

(defun c:ordi(/ fPt oldEcho *error*) 

 (defun *error*(msg) 
     (setvar "CMDECHO" oldEcho) 
   (princ) 
   ); end of *error* 
 
 (setq oldEcho(getvar "CMDECHO")) 
 (setvar "CMDECHO" 0)
 (while t
 (if 
   (setq fPt(getpoint "\nSpecify point or Esc to Quit > ")) 
   (progn 
     (command "_.dimordinate" fPt "_t" 
         (strcat 
      "X=" (rtos(car fPt)2(getvar "DIMDEC")) 
      "\\X" 
      "Y=" (rtos(cadr fPt)2(getvar "DIMDEC")) 
      ); end strcat 
         pause 
         ); end command 
     ); end progn 
   ); end if
   ); end while
   (setvar "CMDECHO" oldEcho) 
 (princ) 
 ); end of c:ordi 

ordi.gif

Link to comment
Share on other sites

Nice way of combining the Ordinate dimensions. :D

 

Perhaps the DIMLFAC could be incorporated, giving the scaling factor required for the coordinates.

 

I think I can do that myself, but daiharv could probably do with a hand.:unsure:

Link to comment
Share on other sites

Perhaps the DIMLFAC could be incorporated, giving the scaling factor required for the coordinates.

 

Yes, now DIMSCALE, DIMLFAC and DIMDEC are works.

 

(defun c:ordi(/ fPt oldEcho dFlc dDec *error*) 

 (defun *error*(msg) 
     (setvar "CMDECHO" oldEcho) 
   (princ) 
   ); end of *error* 

 (princ(strcat "DIMSCALE="(rtos
		     (getvar "DIMSCALE"))" "
	"DIMLFAC="(rtos
		    (setq dFlc
		     (getvar "DIMLFAC")))" "
	"DIMDEC="(rtos
		   (setq dDec
		    (getvar "DIMDEC")))" "
 ); end strcat
); end princ	
 (setq oldEcho(getvar "CMDECHO")) 
 (setvar "CMDECHO" 0)
 (while t
 (if 
   (setq fPt(getpoint "\nSpecify point or Esc to Quit > ")) 
   (progn 
     (command "_.dimordinate" fPt "_t" 
         (strcat 
      "X=" (rtos(* dFlc(car fPt))2 dDec) 
      "\\X" 
      "Y=" (rtos(* dFlc(cadr fPt))2 dDec) 
      ); end strcat 
         pause 
         ); end command 
     ); end progn 
   ); end if
   ); end while
   (setvar "CMDECHO" oldEcho) 
 (princ) 
 ); end of c:ordi

Link to comment
Share on other sites

Thank you very much ASMI.

 

It is now a much more elegant solution to labelling coordinates using the dimensioning facilities of AutoCAD. I must add on a header where I got it from :D

Link to comment
Share on other sites

  • 4 years later...
May be standard DIMORDINATE with text override better... It can move after picking point

 

(defun c:ordi(/ fPt oldEcho *error*) 

 (defun *error*(msg) 
     (setvar "CMDECHO" oldEcho) 
   (princ) 
   ); end of *error* 
 
 (setq oldEcho(getvar "CMDECHO")) 
 (setvar "CMDECHO" 0)
 (while t
 (if 
   (setq fPt(getpoint "\nSpecify point or Esc to Quit > ")) 
   (progn 
     (command "_.dimordinate" fPt "_t" 
         (strcat 
      "X=" (rtos(car fPt)2(getvar "DIMDEC")) 
      "\\X" 
      "Y=" (rtos(cadr fPt)2(getvar "DIMDEC")) 
      ); end strcat 
         pause 
         ); end command 
     ); end progn 
   ); end if
   ); end while
   (setvar "CMDECHO" oldEcho) 
 (princ) 
 ); end of c:ordi 

 

i cant make this work. i appload the lsp then what :) Write ordi to command or this overwriting DIMORDINATE command. Using Autocad 2008. And new to lisps....

 

There is similar lsp at different topic. i can make it work by typing 31 thanks...

 

 

A leader lisp that does what you want ->

 

(defun c:31 (/ odt odg oecho oerr p1 p2 a1 a2 a)
 (setq    odt   (getvar "dimtad")
   odg   (getvar "dimgap")
   oecho (getvar "cmdecho")
 )
 (setq oerr *error*)
 (defun *error* (msg)
   (princ "\n ERROR!")
   (setvar "cmdecho" oecho)
   (setvar "dimtad" odt)
   (setvar "dimgap" odg)
   (setq *error* oerr)
   (command)
   (princ)
 )
 (setvar "cmdecho" 0)
 (setvar "dimtad" 0)
 (setvar "dimgap" -0.09)
 (while (setq p1 (getpoint "\n Point to identify: "))
   (setq p2 (getpoint p1 "\n Place annotation: ")
     a1 (rtos (nth 0 p1) 2 1)
     a2 (rtos (nth 1 p1) 2 1)
     a3 (rtos (nth 2 p1) 2 1)
     ;;a  (strcat a1 ", " a2 ", z=" a3)
     a  (strcat a1 ", " a2)
     ;;a  (strcat "x=" a1 "\\Py=" a2)
     ;;a  (strcat "x=" a1 "\\Py=" a2 "\\Pz=" a3)
     ;;a  (strcat "x = " a1 ", y = " a2)
   )
   ;(if (/= a3 "0.000")(setq a (strcat a1 ", " a2 ", z=" a3)))
   (command "leader" p1 p2 "" a "" ^c)
 )
 (setvar "cmdecho" oecho)
 (setvar "dimtad" odt)
 (setvar "dimgap" odg)
 (princ)
) ;_ end of defun

(prompt "\n To start ID Leader, type > 31 <: ")

Link to comment
Share on other sites

Yes, now DIMSCALE, DIMLFAC and DIMDEC are works.

 

(defun c:ordi(/ fPt oldEcho dFlc dDec *error*) 

(defun *error*(msg) 
(setvar "CMDECHO" oldEcho) 
(princ) 
); end of *error* 

(princ(strcat "DIMSCALE="(rtos
(getvar "DIMSCALE"))" "
"DIMLFAC="(rtos
(setq dFlc
(getvar "DIMLFAC")))" "
"DIMDEC="(rtos
(setq dDec
(getvar "DIMDEC")))" "
); end strcat
); end princ 
(setq oldEcho(getvar "CMDECHO")) 
(setvar "CMDECHO" 0)
(while t
(if 
(setq fPt(getpoint "\nSpecify point or Esc to Quit > ")) 
(progn 
(command "_.dimordinate" fPt "_t" 
(strcat 
"X=" (rtos(* dFlc(car fPt))2 dDec) 
"\\X" 
"Y=" (rtos(* dFlc(cadr fPt))2 dDec) 
); end strcat 
pause 
); end command 
); end progn 
); end if
); end while
(setvar "CMDECHO" oldEcho) 
(princ) 
); end of c:ordi

 

How do I incorporate this code with 3 decimel places??

Link to comment
Share on other sites

There are two ways to set up decimal places to three for this lisp.

 

First, set up the current dimension style so that the Primary Unit for Linear dimensions has three decimal places.

 

Second, set DIMDEC to 3.

 

Use one or the other :D

Link to comment
Share on other sites

How do I incorporate this code with 3 decimel places??

 

How did you make it work. i appload this lisp then i dont know what to do?

Edited by obihal
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...