Philmobile Posted June 10, 2011 Posted June 10, 2011 Hi, First post here, hope you can help. It's been quarter of a century since I last wrote any lisp routines (that's so long ago I've forgotten most of everything I learnt!) but I did try to write a lisp routine which would extract the z data from a 3D point and then write the z data value at the node of the point I'd picked. This is where I've got to: (defun C:Zxtract (/ pt0 z lev) (setq pt0 (getpoint (COMMAND "id" "nod")) z (caddr pt0) lev (rtos z 2 2) ) (COMMAND "text" "s" "standard" pt0 "2.5" "0" lev) ) And this is what comes up on the screen when I run the command Zxtract after the command prompt: Command: zxtract bad argument type: point: nilof Even though the above message comes up, I can still pick the point; and picking an arbitrary point gives me the following on the command line: X = 5.773 Y = 6.179 Z = 1.000 What I want is for the z value to be written on the screen with a text height of 2.5. It's nowhere to be seen! Can anyone help? I have 7,600 points with z values and I'm NOT doing it longhand!!! Many thanks in advance Phil Quote
Lee Mac Posted June 10, 2011 Posted June 10, 2011 Hi Phil, Your error is because the command function will return nil, and getpoint requires a string: (getpoint "\nSpecify Point: ") Hence you could use something like: (defun c:test ( / pt z ) (while (setq pt (getpoint "\nPick Point: ")) (setq z (caddr (trans pt 1 0)) z (rtos z 2 2) ) (command "_.-text" "_s" "standard" "_non" pt "2.5" "0" z) ) (princ) ) Note that that above will only work if the Standard TextStyle has zero height, since otherwise the height prompt will not appear. But if you are using AutoCAD Point Entities, you could collect a SelectionSet of these and process the lot in one go. Quote
Tharwat Posted June 10, 2011 Posted June 10, 2011 Welcome to the forum .. Something like this .... ? (defun c:test (/ p ) (if (setq p (getpoint "\n Specify Point :")) (command "_.text" "_style" "Standard" p "2.5" "0" (rtos (caddr p) 2)) (princ) ) (princ) ) Tharwat Quote
Philmobile Posted June 10, 2011 Author Posted June 10, 2011 Many thanks for the help. Much appreciated. Lee Mac said: But if you are using AutoCAD Point Entities, you could collect a SelectionSet of these and process the lot in one go. That's got to be my next step then - working out how to create a selection set...since I have so many of them to pick! Quote
Lee Mac Posted June 10, 2011 Posted June 10, 2011 Philmobile said: That's got to be my next step then - working out how to create a selection set...since I have so many of them to pick! Maybe something like this: (defun c:test ( / ss i pt nrm uca ) (setq nrm (trans '(0. 0. 1.) 1 0 t) uca (angle '(0. 0. 0.) (trans (getvar 'UCSXDIR) 0 nrm t)) ) (if (setq ss (ssget '((0 . "POINT")))) (repeat (setq i (sslength ss)) (setq pt (cdr (assoc 10 (entget (ssname ss (setq i (1- i))))))) (entmake (list (cons 0 "TEXT") (cons 10 (trans pt 0 nrm)) (cons 40 2.5) (cons 1 (rtos (last pt) 2 2)) (cons 50 uca) (cons 210 nrm) ) ) ) ) (princ) ) The above will also account for all UCS/Views. Quote
Philmobile Posted June 10, 2011 Author Posted June 10, 2011 Tharwat said: Welcome to the forum .. Thanks. Writing routines is coming back to me; only slowly...very slowly. Quote
David Bethel Posted June 10, 2011 Posted June 10, 2011 I was always weak on the (osnap) call. esp about "nod" value But I would think that you want the text centered on the point, not to drop the trailing or leading zeros. [b][color=BLACK]([/color][/b]defun c:zval [b][color=FUCHSIA]([/color][/b]/ pt[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setvar [color=#2f4f4f]"DIMZIN"[/color] 0[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setvar [color=#2f4f4f]"SNAPMODE"[/color] 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]setq pt [b][color=MAROON]([/color][/b]getpoint [color=#2f4f4f]"\nPick Point: "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq pt [b][color=MAROON]([/color][/b]osnap pt [color=#2f4f4f]"end,nod"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]prin1 pt[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]entmake [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons 0 [color=#2f4f4f]"TEXT"[/color][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 1 [b][color=BLUE]([/color][/b]rtos [b][color=RED]([/color][/b]nth 2 pt[b][color=RED])[/color][/b] 2 2[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 6 [color=#2f4f4f]"BYLAYER"[/color][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 7 [color=#2f4f4f]"STANDARD"[/color][b][color=GREEN])[/color][/b] [color=#8b4513]; [b][color=GREEN]([/color][/b]cons 8 [color=#2f4f4f]"0"[/color][b][color=GREEN])[/color][/b][/color] [b][color=GREEN]([/color][/b]cons 10 pt[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 11 pt[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 39 0.0[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 40 2.5[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 41 1.0[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 50 0.0[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 51 0.0[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 62 256[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 71 0[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 72 4[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 73 0[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 210 [b][color=BLUE]([/color][/b]list 0.0 0.0 1.0[b][color=BLUE])[/color][/b][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] You can uncomment the (cons 8 "0") line if you need a specific layer. Same with 39 62 etc HTH -David Quote
Philmobile Posted June 10, 2011 Author Posted June 10, 2011 Lee Mac said: Maybe something like this: That looks nothing like anything in the R12 Lisp routines book I am working from! That would have taken me hours to work out. It works, very well. Thank you. Quote
Lee Mac Posted June 10, 2011 Posted June 10, 2011 You're very welcome Phil If you need anything explained, just shout 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.