trevorc Posted October 19, 2009 Posted October 19, 2009 I am sorry if this has been covered on another post, i have tried for a while to find a function or a lisp to suit. I need to be able to Select a point and have the Z value added Next to this point. Thanks in Advance Quote
David Bethel Posted October 19, 2009 Posted October 19, 2009 I'm sure it has been done before as well but couldn't find it either. So here's a down and dirty snipet: [b][color=BLACK]([/color][/b]defun c:lz [b][color=FUCHSIA]([/color][/b]/ pp[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq pp [b][color=NAVY]([/color][/b]getpoint [color=#2f4f4f]"\nPick Point: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]entmake [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]cons 0 [color=#2f4f4f]"TEXT"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 1 [b][color=GREEN]([/color][/b]rtos [b][color=BLUE]([/color][/b]caddr pp[b][color=BLUE])[/color][/b] 2 8[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 6 [color=#2f4f4f]"BYLAYER"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 7 [b][color=GREEN]([/color][/b]getvar [color=#2f4f4f]"TEXTSTYLE"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 8 [b][color=GREEN]([/color][/b]getvar [color=#2f4f4f]"CLAYER"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 10 [b][color=GREEN]([/color][/b]polar pp 0.0 [b][color=BLUE]([/color][/b]getvar [color=#2f4f4f]"TEXTSIZE"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 11 [b][color=GREEN]([/color][/b]polar pp 0.0 [b][color=BLUE]([/color][/b]getvar [color=#2f4f4f]"TEXTSIZE"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 39 1e-8[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 40 [b][color=GREEN]([/color][/b]getvar [color=#2f4f4f]"TEXTSIZE"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 41 1.0[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 50 0.0[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 51 0.0[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 62 256[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 71 0[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 72 0[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 73 0[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 210 [b][color=GREEN]([/color][/b]list 0 0 1[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote
trevorc Posted October 19, 2009 Author Posted October 19, 2009 David, That works a treat, adapting this function to only display the Y value would also help us greatly. I should have done this for my original request. I apologise as i dont have much knowledge of VBA or Lisp routines, can the routine be adapted to display the Y value only as well? I have looked at the routine and honestly dont know what to change to do this! Many Thanks in Advance Trevor Quote
David Bethel Posted October 19, 2009 Posted October 19, 2009 Try changing the (cons 1 line... to this: (cons 1 (strcat (rtos cadr pp 2 "," (rtos (caddr pp) 2 )) -David Quote
David Bethel Posted October 19, 2009 Posted October 19, 2009 After reading you post a 2nd time, I'm a bit confused. Display the Y only as well doesn't quite make sense? Do want 2 programs, 1 for Y, 1 for Z? Or 1 that displays both ( that's what i responded with ) -David Quote
trevorc Posted March 30, 2010 Author Posted March 30, 2010 Hi David, I would like to apologise due to not getting back to you. We had major software problems which took some time to resolve and this Lsp routine got pushed way down my work list. Your responces to this has been greatly appreciated Autocad lsp routines is certainly an area i need to learn as it would benifit me greatly. We are working with Point Cloud information and when Drafting Floor Plans and Elevations you need to put Level Values in certain features or at a certain distance. For Elevations our Y value corrseponds to our Z value so we would need the ability to Start a command, Enter in The text Size, Enter in the Offset Value (distance horizontaly and Up that the text is placed in relation to the point selected), A Cross added to the drawing at the Location you have picked, & z or y value placed next to the cross. Ideally this command would continue letting the opperator select multiple points to creat a Cross & Text Value for, using the Text Height & offsets previously entered. Is this to complex to be done? Thanks in advance for your time and responce. Regards Trevor Quote
Lee Mac Posted March 30, 2010 Posted March 30, 2010 (edited) Hope you don't mind David, here's my variation on it: (defun c:ptlab (/ Text _PromptWithDefault _Cross Pt) ;; Lee Mac ~ 30.03.10 (defun Text (pt hgt str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 40 hgt) (cons 7 (getvar 'TEXTSTYLE)) (cons 1 str)))) (defun _PromptWithDefault (f arg d) (cond ((apply f arg)) (d))) (defun _Cross (p h / l) (setq l (sqrt (* 0.5 h h))) (mapcar (function (lambda (p1 p2) (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2))))) (list (polar p (/ pi 4.) l) (polar p (/ (* 3 pi) 4.) l)) (list (polar p (/ (* 5 pi) 4.) l) (polar p (/ (* 7 pi) 4.) l)))) (setq *tHgt* (cond (*tHgt*) ((getvar 'TEXTSIZE))) *thOff* (cond (*thOff*) (1.0)) *tvOff* (cond (*tvOff*) (1.0))) (mapcar (function set) '(*tHgt* *thOff* *tvOff*) (mapcar (function _PromptWithDefault) '(getdist getdist getdist) (list (list (strcat "\nSpecify Text Height <" (rtos *tHgt*) "> : ")) (list (strcat "\nSpecify Horizontal Text Offset <" (rtos *thOff*) "> : ")) (list (strcat "\nSpecify Vertical Text Offset <" (rtos *tvOff*) "> : "))) (list *tHgt* *thOff* *tvOff*))) (while (setq pt (getpoint "\nPick Point to Label <Exit> : ")) (_Cross (setq pt (trans pt 1 0)) *tHgt*) (Text (polar (polar pt 0. *thOff*) (/ pi 2.) *tvOff*) *tHgt* (strcat (rtos (cadr pt)) "," (rtos (caddr pt))))) (princ)) Edited July 3, 2022 by Lee Mac Quote
trevorc Posted March 30, 2010 Author Posted March 30, 2010 Lee, That works a treat, is it diffuclt for it to ask you the size of cross as well? If this is straight forward i would need 2 seperate lsp routines one only highlighting the Z value and another only highlighting the Y value. Or alternativly the routine asking which you would require. The routine as it looks runs like a dream and will be massivly benifical. With regards to learning LSP Routines, is there any training manuals you would recomend or where would you suggest the best place to start? many many thanks for your quick responce and your help. Regards Trevor Quote
Lee Mac Posted March 30, 2010 Posted March 30, 2010 (edited) Sure Trevor, try this: (defun c:ptlab (/ Text _PromptWithDefault _Cross Pt pos) ;; Lee Mac ~ 30.03.10 (defun Text (pt hgt str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 40 hgt) (cons 7 (getvar 'TEXTSTYLE)) (cons 1 str)))) (defun _PromptWithDefault (f arg d) (cond ((apply f arg)) (d))) (defun _Cross (p h / l) (setq l (sqrt (* 0.5 h h))) (mapcar (function (lambda (p1 p2) (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2))))) (list (polar p (/ pi 4.) l) (polar p (/ (* 3 pi) 4.) l)) (list (polar p (/ (* 5 pi) 4.) l) (polar p (/ (* 7 pi) 4.) l)))) (setq *Coord* (cond (*Coord*) ("Y")) *tHgt* (cond (*tHgt* ) ((getvar 'TEXTSIZE))) *thOff* (cond (*thOff*) (1.0)) *tvOff* (cond (*tvOff*) (1.0)) *cSze* (cond (*cSze* ) ((getvar 'TEXTSIZE)))) (setq pos '(("X" . 0) ("Y" . 1) ("Z" . 2))) (initget "X Y Z") (mapcar (function set) '(*Coord* *tHgt* *thOff* *tvOff* *cSze*) (mapcar (function _PromptWithDefault) '(getkword getdist getdist getdist getdist ) (list (list (strcat "\nSpecify Coord to Label [X/Y/Z] <" *Coord* "> : ")) (list (strcat "\nSpecify Text Height <" (rtos *tHgt*) "> : ")) (list (strcat "\nSpecify Horizontal Text Offset <" (rtos *thOff*) "> : ")) (list (strcat "\nSpecify Vertical Text Offset <" (rtos *tvOff*) "> : ")) (list (strcat "\nSpecify Cross Height <" (rtos *cSze*) "> : "))) (list *Coord* *tHgt* *thOff* *tvOff* *cSze*))) (while (setq pt (getpoint "\nPick Point to Label <Exit> : ")) (_Cross (setq pt (trans pt 1 0)) *cSze*) (Text (polar (polar pt 0. *thOff*) (/ pi 2.) *tvOff*) *tHgt* (rtos (nth (cdr (assoc *Coord* pos)) pt)))) (princ)) Edited July 3, 2022 by Lee Mac 1 Quote
trevorc Posted May 4, 2010 Author Posted May 4, 2010 Lee, We have been using the Lsp routine now for a good while and it has helped 10 times over. One thing that could also help is being able to nominate the decimal place that the lsp uses. At the moment it is set to 4 decimal places. On checking the Autocad settings is set to 3 decimal places and somehow being overwritted by the lsp. Would it be much to be able to nominate how many decimal places that the lsp is to use? Alternativly if it was to use the Units set up within the drawing it always would be using the correct decimal placing. Thanks in advance. Trev Quote
trevorc Posted May 4, 2010 Author Posted May 4, 2010 Lee, Previous to my additional request above, i had thanked you for your help with the above LSP routine, I dont know why it didnt appear on the forum or what has happened! Quote
Lee Mac Posted May 4, 2010 Posted May 4, 2010 Not a problem Trevor - happy to help. As for the precision, the latest code should use the settings of LUPREC on your system - I'm not sure as to why it would override it. Quote
alanjt Posted May 4, 2010 Posted May 4, 2010 This thread may be of interest to you. If I was at work, I'd just post my blocks, but I've posted an example and a video on creation procedure. Quote
Martin Power Posted January 21, 2014 Posted January 21, 2014 Hi Lee. Thanks for the LSP you made for Trevor, it have helped me alot! I have a question about it. Is it possible to change it so I can select several points and have the value printed out just like it's doing right now? I've tried to figure out what part that control this but I'm fairly new to LSP so thought I ask instead. Thanks in advance, Martin Quote
sivapathasunderam Posted July 21, 2015 Posted July 21, 2015 Please modify the Lisp for option with selection set this is one by one have to pick points add option for select points thanks Quote
whosa Posted February 15, 2016 Posted February 15, 2016 Hi, is possible to change the scale of the z value. I have the drawing in mimmimiters but I would like to convert the z in meters. Thanks Quote
BIGAL Posted July 1, 2022 Posted July 1, 2022 If you copied the text as above with the [color=RED]([/color][/b][b][ it will not work it needs all of the display coding removed. Explain again what you want and a up to date version can probably be found. Quote
Lee Mac Posted July 3, 2022 Posted July 3, 2022 I have updated my earlier posts to remove the BBCode formatting exposed by the new forum software - this is some very old code though! 1 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.