daiharv Posted December 21, 2006 Share Posted December 21, 2006 (edited) 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 October 24, 2011 by SLW210 Add CODE TAGS!! Quote Link to comment Share on other sites More sharing options...
ASMI Posted December 21, 2006 Share Posted December 21, 2006 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) Quote Link to comment Share on other sites More sharing options...
eldon Posted December 21, 2006 Share Posted December 21, 2006 If you want coordinates to three decimal places, don't forget to alter the "2" in the second line to "3" Quote Link to comment Share on other sites More sharing options...
ASMI Posted December 21, 2006 Share Posted December 21, 2006 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 Quote Link to comment Share on other sites More sharing options...
eldon Posted December 21, 2006 Share Posted December 21, 2006 Nice way of combining the Ordinate dimensions. 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. Quote Link to comment Share on other sites More sharing options...
ASMI Posted December 21, 2006 Share Posted December 21, 2006 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 Quote Link to comment Share on other sites More sharing options...
eldon Posted December 21, 2006 Share Posted December 21, 2006 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 Quote Link to comment Share on other sites More sharing options...
ASMI Posted December 21, 2006 Share Posted December 21, 2006 >eldon Thanks for kind words. It only my small hobby. Quote Link to comment Share on other sites More sharing options...
obihal Posted October 24, 2011 Share Posted October 24, 2011 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 <: ") Quote Link to comment Share on other sites More sharing options...
Dormant Posted October 25, 2011 Share Posted October 25, 2011 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?? Quote Link to comment Share on other sites More sharing options...
eldon Posted October 25, 2011 Share Posted October 25, 2011 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 Quote Link to comment Share on other sites More sharing options...
pBe Posted October 25, 2011 Share Posted October 25, 2011 (rtos(* dFlc(car fPt))2 dDec) TO (rtos(* dFlc(car fPt))2 [b]3[/b]) Oops, didnt see yopur post there eldon Quote Link to comment Share on other sites More sharing options...
Dormant Posted October 25, 2011 Share Posted October 25, 2011 thanks both work great Quote Link to comment Share on other sites More sharing options...
obihal Posted October 25, 2011 Share Posted October 25, 2011 (edited) 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 October 25, 2011 by obihal Quote Link to comment Share on other sites More sharing options...
Dormant Posted October 26, 2011 Share Posted October 26, 2011 type "ordi" at command prompt to run. Make sure it was successfully loaded Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.