Jump to content

Multiple Points -> add z-value as label


careca

Recommended Posts

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))

Link to comment
Share on other sites

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • halam

    6

  • Maximum GSP

    6

  • CADWORKER

    3

  • pBe

    2

Top Posters In This Topic

Posted Images

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))

Link to comment
Share on other sites

Thanks pBe :thumbsup:

 

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)
)

Link to comment
Share on other sites

  • 3 years later...
Thanks pBe :thumbsup:

 

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

Link to comment
Share on other sites

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 ... :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by Maximum GSP
Link to comment
Share on other sites

(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.

Link to comment
Share on other sites

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))))
   )

)

Knipsel.JPG

Edited by halam
Link to comment
Share on other sites

  • 2 years later...
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.

 

AttBlock.gif

 

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 ;)

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...