CraneGuy Posted May 29, 2008 Posted May 29, 2008 Hi! I'm looking for a little help in creating a lisp routine. I'm looking to create a leader with both X & Y dimensions from a specific point. I found some code and modified it to show feet and inches. For some reason, I set the UCS to a point bottom center of the piece I'm dimensioning, but when I run the lisp routine and select the base point I don't get zero values. What I'm really looking for is a routine that will ask for the base point, then let me click points around the object until I'm done. This is the code I have now. Can anybody see why I don't get zero values at the base point, and if its possible for the routine to ask for the base point first? Your help is appreciated. By the way, I know nothing about programming! (defun C:xy (/ oldecho pt1 pt2 txtx txty ) (setq oldecho (getvar "cmdecho" )) (setvar "cmdecho" 0) (setq pt1 (getpoint "\nPick coordinate point: ")) (if pt1 (progn (setq pt2 (getpoint pt1 "\nPick text location: ")) (if pt2 (progn (setq txtx (strcat "W:" (rtos (car pt2) 4 3) " ")) (setq txty (strcat "H:" (rtos (cadr pt2) 4 3) "\n")) (command "leader" pt1 pt2 "Annotation" txtx txty "") ) ) ) ) (setvar "cmdecho" oldecho) (princ) ) Quote
lpseifert Posted May 29, 2008 Posted May 29, 2008 Try this, not extensively tested (defun C:xy (/ oldecho pt1 pt2 txtx txty ) (setq oldecho (getvar "cmdecho" )) (setvar "cmdecho" 0) (setq ptb (getpoint "Pick base point: ")) (command "ucs" "o" ptb) (setq pt1 T) (while (not (null pt1)) (setq pt1 (getpoint "\nPick coordinate point: ")) (if pt1 (progn (setq pt2 (getpoint pt1 "\nPick text location: ")) (if pt2 (progn (setq txtx (strcat "W:" (rtos (car pt1) 4 3) " ")) (setq txty (strcat "H:" (rtos (cadr pt1) 4 3) "\n")) (command "leader" pt1 pt2 "Annotation" txtx txty "") ) ) ) ) );while (setvar "cmdecho" oldecho) (princ) ) Quote
CraneGuy Posted May 29, 2008 Author Posted May 29, 2008 Thats exactly what I was looking for, thanks! It does exactly what I need, but I have a couple of questions about the formatting: Is there any way to enlarge the box around the text? I'm been messing with the code and it seems that it is either on or off. It looks like its touching the text. Can the routine be modified to show height first, then width? I found a routine elsewhere that stored the values as A1, A2 and it was a simple matter to switch them. Quote
lpseifert Posted May 30, 2008 Posted May 30, 2008 This will fix the H W swap, but as far as the box, that is probably setup in your dimension style. The code has no control over it. the size of the box is controlled by the DIMGAP variable; use a negative number to get a box; I used -0.1 and it looked fine on my computer, you may have to experiment to get it to look the way you want. I've added a few lines to set the dimgap. Since there is no error control you'll need to exit the routine by hitting enter, Esc will not reset the variables. (defun C:xy (/ oldecho pt1 pt2 txth txtw dg ) (setq oldecho (getvar "cmdecho" ) dg (getvar "dimgap") );setq (setvar "cmdecho" 0) (setvar "dimgap" -0.1) (setq ptb (getpoint "Pick base point: ")) (command "ucs" "o" ptb) (setq pt1 T) (while (not (null pt1)) (setq pt1 (getpoint "\nPick coordinate point: ")) (if pt1 (progn (setq pt2 (getpoint pt1 "\nPick text location: ")) (if pt2 (progn (setq txth (strcat "H:" (rtos (cadr pt1) 4 3) " ")) (setq txtw (strcat "W:" (rtos (car pt1) 4 3) "\n")) (command "leader" pt1 pt2 "Annotation" txth txtw "") ) ) ) ) );while (setvar "cmdecho" oldecho) (setvar "dimgap" dg) (princ) ) Quote
CraneGuy Posted May 30, 2008 Author Posted May 30, 2008 Again, thanks very much. Just what I was looking for. Quote
dortega4269 Posted June 6, 2014 Posted June 6, 2014 I created something similar using CraneGuy & lpseifert's lisp routines, just massaged the code a bit: Changes: -H: & W: were switched to x: & y: -Seperated x: & y: lisp (defun C:xy & (defun C:yx to produce an 'X' or 'Y' axis Ordinate Dimension -eliminated the box around text (setvar "dimgap" 0 -Set a default DimStyle (command "-dimstyle" -Added a layer search/layer creator (tblesearch "layer" -Set new layer to current layer (setvar "clayer" It works well and I wanted to display it for anyone else that may need something like this or to give others more ideas... BTW, I'm a n00b to lisp, I only used ideas I could find on the net and debugged it until it worked well together. ;;; ;;; ========================= X Ordinates for In-Wall =========================== ;;; (defun C:xy (/ oldecho pt1 pt2 txtx txty dg ) (setq oldecho (getvar "cmdecho" ) dg (getvar "dimgap") );setq (setvar "cmdecho" 0) (setvar "dimgap" 0) (setq ptb (getpoint "Pick base point: ")) (command "ucs" "o" ptb) (setq pt1 T) (while (not (null pt1)) (setq pt1 (getpoint "\nPick coordinate point: ")) (if pt1 (progn (setq pt2 (getpoint pt1 "\nPick text location: ")) (if pt2 (progn (setq txtx (strcat "y:" (rtos (cadr pt1) 4 3) " ")) (setq txty (strcat "x:" (rtos (car pt1) 4 3) "\n")) (command "-dimstyle" "r" "BLA 32 Ordinates") (if (null (tblsearch "layer" "B-DimXYOrdinates")) (command "-layer" "Make" "B-DimXYOrdinates" "C" "140" "" "L" "Continuous" "" "LW" ".25" "" "D" "B-DimXYOrdinates = Dimensional In-Wall Layout" "B-DimXYOrdinates" "") (setvar "clayer" "B-DimXYOrdinates") ) (command "leader" pt1 pt2 "Annotation" txty "") ) ) ) ) );while (setvar "cmdecho" oldecho) (setvar "dimgap" dg) (princ) ) ;;; ;;; ========================= Y Ordinates for In-Wall =========================== ;;; (defun C:yx (/ oldecho pt1 pt2 txtx txty dg ) (setq oldecho (getvar "cmdecho" ) dg (getvar "dimgap") );setq (setvar "cmdecho" 0) (setvar "dimgap" 0) (setq ptb (getpoint "Pick base point: ")) (command "ucs" "o" ptb) (setq pt1 T) (while (not (null pt1)) (setq pt1 (getpoint "\nPick coordinate point: ")) (if pt1 (progn (setq pt2 (getpoint pt1 "\nPick text location: ")) (if pt2 (progn (setq txtx (strcat "y:" (rtos (cadr pt1) 4 3) " ")) (setq txty (strcat "x:" (rtos (car pt1) 4 3) "\n")) (command "-dimstyle" "r" "BLA 32 Ordinates") (if (null (tblsearch "layer" "B-DimXYOrdinates")) (command "-layer" "Make" "B-DimXYOrdinates" "C" "140" "" "L" "Continuous" "" "LW" ".25" "" "D" "B-DimXYOrdinates = Dimensional In-Wall Layout" "B-DimXYOrdinates" "") (setvar "clayer" "B-DimXYOrdinates") ) (command "leader" pt1 pt2 "Annotation" txtx "") ) ) ) ) );while (setvar "cmdecho" oldecho) (setvar "dimgap" dg) (princ) ) Quote
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.