careca Posted October 18, 2012 Share Posted October 18, 2012 Hi all. I have found this script by Lee Mac, which adds x/y coordinates to a selection of points. I wonder what needs to be done to display the z-value of the points only. Though I had a try, I have not yet managed to understand this mapcar-thing. Probably an easy thing to update the script below, any hints would be highly appreciated. Thanks in advance. (defun c:txtpt (/ Make_MText i ss ent) ; Lee Mac ~ 21.01.10 (defun Make_MText (pt str) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 10 pt) (cons 1 str)))) (if (setq i -1 ss (ssget '((0 . "POINT")))) (while (setq ent (ssname ss (setq i (1+ i)))) (Make_MText (cdr (assoc 10 (entget ent))) (apply (function strcat) (mapcar (function strcat) '("X = " "\nY = ") (mapcar (function rtos) (cdr (assoc 10 (entget ent))))))) )) (princ)) Quote Link to comment Share on other sites More sharing options...
pBe Posted October 18, 2012 Share Posted October 18, 2012 (Make_MText (cdr (assoc 10 (entget ent))) (strcat "Z = " (rtos (last (cdr (assoc 10 (entget ent)))))) ) Quote Link to comment Share on other sites More sharing options...
careca Posted October 18, 2012 Author Share Posted October 18, 2012 great - many thanks. as simple as i imagined it to be. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 18, 2012 Share Posted October 18, 2012 Another example (setq ent (car (entsel))) (setq xyz (assoc 10 (entget ent))) (princ (car xyz)) (setq ans (getstring "press any key look at command line")) (princ (cadr xyz)) (setq ans (getstring "press any key look at command line")) (princ (caddr xyz)) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 18, 2012 Share Posted October 18, 2012 Thanks pBe If I were to rewrite the function today, I'd probably use something like: (defun c:zpt ( / i p s ) (if (setq s (ssget '((0 . "POINT")))) (repeat (setq i (sslength s)) (setq p (assoc 10 (entget (ssname s (setq i (1- i)))))) (entmake (list '(000 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 1 (strcat "Z = " (rtos (cadddr p)))) p ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
pBe Posted October 18, 2012 Share Posted October 18, 2012 Thanks pBe If I were to rewrite the function today, I'd probably use something like: You my good man have the right to re-right. Quote Link to comment Share on other sites More sharing options...
Maximum GSP Posted June 20, 2016 Share Posted June 20, 2016 Thanks pBe If I were to rewrite the function today, I'd probably use something like: (defun c:zpt ( / i p s ) (if (setq s (ssget '((0 . "POINT")))) (repeat (setq i (sslength s)) (setq p (assoc 10 (entget (ssname s (setq i (1- i)))))) (entmake (list '(000 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 1 (strcat "Z = " (rtos (cadddr p)))) p ) ) ) ) (princ) ) Very nice, but i have one other question too : I wish to place a specified block (with Z automatic attribute) on every selected blocks in my drawing, how can i do that ? I try to change your code, but... And i have to do that with a separated block (with specified name), not with the attributes of all my blocks, so i can change all "texts" in one step Quote Link to comment Share on other sites More sharing options...
halam Posted June 20, 2016 Share Posted June 20, 2016 I use a dynamic block in combination with a lisp for reading out X,Y AND Z The purpose for dimensioning. Maybe it is in the direction of what you are looking for.. http://www.theswamp.org/index.php?topic=27506.0;all DNH.lsp dyn-level.dwg Quote Link to comment Share on other sites More sharing options...
Maximum GSP Posted June 20, 2016 Share Posted June 20, 2016 Z auto.dwgIt can be, but i have some error messages when i try to execute your lisp (DNH command ?), old version for autocad for you (2015 C3D for me) ? I just want to put the blocks (just one of the two blocks) on every selected blocks in my drawing, if i can replace it in your lisp ... Quote Link to comment Share on other sites More sharing options...
halam Posted June 20, 2016 Share Posted June 20, 2016 Maybe this explanes the use. DNH : insert block choose appearance and use with vis state of this block In this case choose Z to read Z-value (1,2,3 is a format) next => DNHm : put in value Z (meters as units) DNHmm : put in value Z (millimeters as units) Z auto back.dwg Quote Link to comment Share on other sites More sharing options...
Maximum GSP Posted June 20, 2016 Share Posted June 20, 2016 Sorry but i have a problem, here is my command bar after try DNH : Commande: DNH-insert Commande inconnue "-INSERT". Appuyez sur F1 pour obtenir de l'aide. Commande: dyn-level.dwg Commande inconnue "DWG". Appuyez sur F1 pour obtenir de l'aide. Commande: 0,0 Commande inconnue "0,0". Appuyez sur F1 pour obtenir de l'aide. Commande: 1 Commande inconnue "1". Appuyez sur F1 pour obtenir de l'aide. Commande: 1 Commande inconnue "1". Appuyez sur F1 pour obtenir de l'aide. Commande: 0 Commande inconnue "0". Appuyez sur F1 pour obtenir de l'aide. Commande: erase Commande inconnue "ERASE". Appuyez sur F1 pour obtenir de l'aide. Commande: Commande: DNH Commande inconnue "DNH". Appuyez sur F1 pour obtenir de l'aide. Commande: -insert Commande inconnue "-INSERT". Appuyez sur F1 pour obtenir de l'aide. Commande: dyn-xyz-file.dwg Commande inconnue "DWG". Appuyez sur F1 pour obtenir de l'aide. Commande: 0,0 Commande inconnue "0,0". Appuyez sur F1 pour obtenir de l'aide. Commande: 1 Commande inconnue "1". Appuyez sur F1 pour obtenir de l'aide. Commande: 1 Commande inconnue "1". Appuyez sur F1 pour obtenir de l'aide. Commande: 0 Commande inconnue "0". Appuyez sur F1 pour obtenir de l'aide. Commande: erase Commande inconnue "ERASE". Appuyez sur F1 pour obtenir de l'aide. Commande: Commande: DNH Commande inconnue "DNH". Appuyez sur F1 pour obtenir de l'aide. Commande: Insert blockdefenitie? Y/N : y Inserting block Dyn-LEVEL-TR .. Insertion maatvoering: X_dim_DNH_mCommande inconnue "INSERT". Appuyez sur F1 pour obtenir de l'aide. Commande inconnue "DYN-LEVEL-TR". Appuyez sur F1 pour obtenir de l'aide. Commande inconnue "DNH". Appuyez sur F1 pour obtenir de l'aide. 1 0 Commande inconnue "DNH". Appuyez sur F1 pour obtenir de l'aide. Commande inconnue "DNH". Appuyez sur F1 pour obtenir de l'aide. Named UCS: *Not Named* Enter or give point for elavation 0.0: Commande inconnue "UCS". Appuyez sur F1 pour obtenir de l'aide. Commande inconnue "DNH". Appuyez sur F1 pour obtenir de l'aide. Commande inconnue "REDRAW". Appuyez sur F1 pour obtenir de l'aide. Choix des objets: 1 trouvé(s) Choix des objets: 1 trouvé(s), 2 au total Choix des objets: Commande: *Annuler* This stops after selection of the blocks and hit enter on my keyboard. Is it possible to simply use my block to label pre-selected blocks ? (Pre-selected to use selectsimilar) Quote Link to comment Share on other sites More sharing options...
halam Posted June 20, 2016 Share Posted June 20, 2016 You need to have dyn-level.dwg i a support directory first May need some more tweaking as well.. Undo the line inserting dyn-xyz.dwg as well. Why don't you use a field in a dynamic block to read the Z-value? dyn-xyz as example dyn-xyz-file.dwg Quote Link to comment Share on other sites More sharing options...
Maximum GSP Posted June 20, 2016 Share Posted June 20, 2016 Ok, but i have many colleagues, i can't do this on every computers when a problem appears... Thanks for your help, but can i just use my block in any random dwg ? Can i change your code for this ? Thanks again My block use a field, in a dynamic block, and in one block so i can change everything in just some clics. I have to many blocks to use fields in erevy... Quote Link to comment Share on other sites More sharing options...
halam Posted June 20, 2016 Share Posted June 20, 2016 You can make it stable and robust to work in your office environments. Make it a .vlx to make it non-readable and easier to load and revise. You need to have a global (support) library for more reasons, don't you think? Quote Link to comment Share on other sites More sharing options...
Maximum GSP Posted June 20, 2016 Share Posted June 20, 2016 (edited) Why don't you use a field in a dynamic block to read the Z-value? My block "Z" use a field, in a dynamic block, with just one Z possibility, and in one block so i can change everything in just some clics. I have to many blocks to use fields in everyone... So i have to : - Select blocks i want to label - Launch the macro/lisp/vlx... - Every selected block take the "Z" block for label, inserted on every block insertion point. Thanks for your help, and sorry for my translations Edited June 20, 2016 by Maximum GSP Quote Link to comment Share on other sites More sharing options...
halam Posted June 26, 2016 Share Posted June 26, 2016 (Make_MText (cdr (assoc 10 (entget ent))) (strcat "Z = " (rtos (last (cdr (assoc 10 (entget ent)))))) ) I'm wondering why c:txtpt or c:zpt creates mtext objects in style 'standard' and not in my current style applied (annotative) Probably it is something in the entmake list definitions missing.. ? thanks for any improvement or idea. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 27, 2016 Share Posted June 27, 2016 Add (cons 7 (getvar 'textstyle)) to the entmake list to generate the text using the current text style. Quote Link to comment Share on other sites More sharing options...
Maximum GSP Posted June 27, 2016 Share Posted June 27, 2016 Ok thanks ! Quote Link to comment Share on other sites More sharing options...
halam Posted June 27, 2016 Share Posted June 27, 2016 (edited) Ok. Thanks ! Great ! What line should be added to set 'annotative' on? Need to get this correctly in somewhere i think. Current text style: "NLCS-ISO" Text height: 125.0 Annotative: Yes (defun LM:isAnnotative ( style / obj xdt ) (and (setq obj (tblobjname "STYLE" style)) (setq xdt (cadr (assoc -3 (entget obj '("AcadAnnotative"))))) (= 1 (cdr (assoc 1070 (reverse xdt)))) ) ) Edited June 27, 2016 by halam Quote Link to comment Share on other sites More sharing options...
sudam Posted February 13, 2019 Share Posted February 13, 2019 On 5/4/2010 at 10:13 PM, alanjt said: 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. On 10/18/2012 at 6:39 AM, careca said: Hi all. I have found this script by Lee Mac, which adds x/y coordinates to a selection of points. I wonder what needs to be done to display the z-value of the points only. Though I had a try, I have not yet managed to understand this mapcar-thing. Probably an easy thing to update the script below, any hints would be highly appreciated. Thanks in advance. (defun c:txtpt (/ Make_MText i ss ent) ; Lee Mac ~ 21.01.10 (defun Make_MText (pt str) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 10 pt) (cons 1 str)))) (if (setq i -1 ss (ssget '((0 . "POINT")))) (while (setq ent (ssname ss (setq i (1+ i)))) (Make_MText (cdr (assoc 10 (entget ent))) (apply (function strcat) (mapcar (function strcat) '("X = " "\nY = ") (mapcar (function rtos) (cdr (assoc 10 (entget ent))))))) )) (princ)) its not working properly , pls upload as LISP format On 6/20/2016 at 7:46 PM, Maximum GSP said: My block "Z" use a field, in a dynamic block, with just one Z possibility, and in one block so i can change everything in just some clics. I have to many blocks to use fields in everyone... So i have to : - Select blocks i want to label - Launch the macro/lisp/vlx... - Every selected block take the "Z" block for label, inserted on every block insertion point. Thanks for your help, and sorry for my translations 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.