Jump to content

change 2 decimal places text to 3


leeksnroses

Recommended Posts

Hi,

I have about 300 pieces of single line text numbers at 2 decimal places. These have a Z value to 3 decimal places. My units are set to 3 decimal places. How do i change these to display to 3 decimal places without physically altering them manually, or is there a lisp routine to do it?

 

Thanks

Link to comment
Share on other sites

What kind of "pieces of text" are we talking about? Dimensions? Attributes? Are the Z values displayed for some points?

Please return with more info.

 

Welcome in the forum!

Link to comment
Share on other sites

They are just simple single line text. All points have the correct Z value. e.g didplayed as 32.45 on screen, with the properties Z value being 32.454. Need to change quite a few.

Thanks

Link to comment
Share on other sites

Here is a quick one:

(defun c:z2t()
 (setq l (entget (car (entsel))))
 (entmod (subst (cons 1 (rtos (car (reverse (assoc 10 l))))) (assoc 1 l) l))
 )

It will overwrite the content of the text with it's Z coord.

The program assumes that you select a text and it makes no checks. Enter the correct data if you wish correct output!

  • Like 1
Link to comment
Share on other sites

My two cents...

 

(defun c:TEST (/ ss layerLock layerItem layerTable oldString newString)
 (vl-load-com)
 (cond
   (*activeDoc*)
   ((setq *activeDoc* (vla-get-activedocument (vlax-get-acad-object)))))
 (if (setq ss (ssget '((0 . "TEXT"))))
   (progn
     (vlax-for x
               (setq ss (vla-get-activeselectionset *activeDoc*))
       (if
         (= :vlax-true
            (setq layerLock
                   (vla-get-lock
                     (setq layerItem
                            (vla-item
                              (cond
                                (layerTable)
                                ((setq layerTable
                                        (vla-get-layers
                                          *activeDoc*))))
                              (vla-get-layer x))))))
          (progn
            (setq layerLocked T)
            (vla-put-lock layerItem :vlax-false)))
       (if (/= (setq oldString (vla-get-textstring x))
               (setq newString
                      (last (vlax-safearray->list
                              (vlax-variant-value
                                (vla-get-textalignmentpoint x))))))
         (vla-put-textstring x newString)))
     (vla-delete ss)
     (if layerLocked
       (vla-put-lock layerItem layerLock))))
 (princ))

 

 

This could easily be done without manually selecting the text entities, provided all items needing to be updated were on a specified layer, etc. Food for thought...?

 

Hope this helps!

Edited by BlackBox
Limiting routine to TEXT only
Link to comment
Share on other sites

(defun c:Test (/ ss)
 (if (setq ss (ssget "_:L" '((0 . "TEXT"))))
   ((lambda (i / e l)
      (while (setq e (ssname ss (setq i (1+ i))))
        (entupd
          (cdr (assoc -1
                      (entmod (subst (cons 1 (rtos (last (assoc 10 (setq l (entget e)))) 2 3))
                                     (assoc 1 l)
                                     l
                              )
                      )
               )
          )
        )
      )
    )
     -1
   )
 )
 (princ)
)

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