Jump to content

Recommended Posts

Posted (edited)

Hi guys,

 

I hope you are well.

 

I need 2 little help.

 

One

 

I need a lisp to make a point with z value read from text:

 

  1. pick the text (33.33)
  2. convert this in millimetres 33330
  3. snap to the centre of the cross (this could be manual)
  4. make a point with 33.33 (in mm) as zvalue.

 

Two

 

I need a similar lisp that:

 

  1. pick the text (33.33)
  2. convert in millimetres 33330
  3. move only in z value by 33330 all the objects selected (33.33 text + rectangle + everything selected)

 

Many thanks

 

 

 

 

Annotazione 2020-02-04 194659.jpg

Edited by whosa
Posted

Quick answer having done this numerous times, if the insertion point of the text is at the X point then use the lisp attached.

 

If all the text is the same offset from the X point move all the text this amount so its now all on the X, run the lisp. You can move it back if you want.

 

To move the X or a block to Z its more complicated and needs a custom routine as it must use the text and then look for the corresponding X and other objects. The same applies if the text is random around the desirable point.

 

image.thumb.png.1b8a747d0399648106119408ae7eec04.png

text2xyz.lsp

Posted
5 hours ago, BIGAL said:

Quick answer having done this numerous times, if the insertion point of the text is at the X point then use the lisp attached.

 

If all the text is the same offset from the X point move all the text this amount so its now all on the X, run the lisp. You can move it back if you want.

 

To move the X or a block to Z its more complicated and needs a custom routine as it must use the text and then look for the corresponding X and other objects. The same applies if the text is random around the desirable point.

 

image.thumb.png.1b8a747d0399648106119408ae7eec04.png

text2xyz.lsp 728 B · 1 download

 

 

Many Thanks but this lisp doest't work on my case.

 

I would like to create a point with 33.33 as Zvalue. This Lisp should covert the text in z coordinates and give me the possibilities to shap the point created where I want.

 

 

test.dwg

Posted (edited)
(defun c:TEST (/ txt data z pt)
  (if (setq txt (car (entsel "\nSelect text: ")))
    (if (wcmatch (cdr (assoc 0 (setq data (entget txt)))) "*TEXT")
      (if (setq z (distof (cdr (assoc 1 data))))
        (if (setq pt (getpoint "\nPick a point: "))
          (command "_.point" (list (car pt) (cadr pt) z))
        )
        (prompt "\nSelected text is not a number.")
      )
      (prompt "\nSelected object is not a text or mtext.")
    )
  )
  (princ)
)

I found this and work quite well but when i snap the point I've created to some object the z value will change.

 

By the way this lisp don't convert the text value in millimeter. 

 

 

 

 

 

 

Edited by whosa
Posted

Two versions of the above, one using VL the other plain, take your pick. Point is inserted on the current layer.

 

(defun c:TEST1 (/ c_doc c_spc sel data z pt)
  (vl-load-com)
  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
  )
  (cond ( (and (setq sel (entsel "\nSelect Text : "))
               (wcmatch (cdr (assoc 0 (setq data (entget (car sel))))) "*TEXT")
          )
          (setq z (distof (cdr (assoc 1 data))))
          (cond ( (and z (setq pt (getpoint "\nSelect Point placement : ")))
                  (setq pt (reverse (cons z (cdr (reverse pt)))))
                  (vlax-invoke c_spc 'addpoint pt)
                )
                (t (alert "Selected text is not a number."))
          )
        )
        (t (alert "\nSelected object is not a text or mtext."))
  )
  (princ)
)

(defun c:TEST2 (/ sel data z pt)

  (cond ( (and (setq sel (entsel "\nSelect Text : "))
               (wcmatch (cdr (assoc 0 (setq data (entget (car sel))))) "*TEXT")
          )
          (setq z (distof (cdr (assoc 1 data))))
          (cond ( (and z (setq pt (getpoint "\nSelect Point placement : ")))
                  (setq pt (reverse (cons z (cdr (reverse pt)))))
                  (command "_.point" pt)
                )
                (t (alert "Selected text is not a number."))
          )
        )
        (t (alert "\nSelected object is not a text or mtext."))
  )
  (princ)
)

 

  • Like 1
Posted (edited)

@dlanorh TEST1 work very well. Thanks a lot. It is possible to convet the value on the tex (in meter in my case) to millimiter?

 

 

I solve the TWO question (move object only in Z - z value write on text). This is my first "Lisp" unsing and merging 2 lisp already made but I have the same problem to convert 33.33m to 33330mm @BIGAL

 

I don't understand how to tell: add z variable * 1000

(defun c:movez ( / ss txt data z)
  (if (and (setq ss (ssget ":L")))
  (if (setq txt (car (entsel "\nSelect text: ")))
    (if (wcmatch (cdr (assoc 0 (setq data (entget txt)))) "*TEXT")
      (if (setq z (distof (cdr (assoc 1 data))))
    (command "_.MOVE" ss "" "_none" '(0 0 0) "_none" (list 0 0 z)))
	)
   )
   )
  (princ)
)

 

 

Edited by whosa
Posted

Fixed. I read how multiply value ans seems to work well:

 

ONE

 

(defun c:t2p (/ c_doc c_spc sel data z pt)
  (vl-load-com)
  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
  )
  (cond ( (and (setq sel (entsel "\nSelect Text : "))
               (wcmatch (cdr (assoc 0 (setq data (entget (car sel))))) "*TEXT")
          )
          (setq z (distof (cdr (assoc 1 data))))
          (cond ( (and z (setq pt (getpoint "\nSelect Point placement : ")))
                  (setq pt (reverse (cons (* z 1000) (cdr (reverse pt)))))
                  (vlax-invoke c_spc 'addpoint pt)
                )
                (t (alert "Selected text is not a number."))
          )
        )
        (t (alert "\nSelected object is not a text or mtext."))
  )
  (princ)
)

TWO

 

(defun c:t2o ( / ss txt data z)
  (if (and (setq ss (ssget ":L")))
  (if (setq txt (car (entsel "\nSelect text: ")))
    (if (wcmatch (cdr (assoc 0 (setq data (entget txt)))) "*TEXT")
      (if (setq z (distof (cdr (assoc 1 data))))
    (command "_.MOVE" ss "" "_none" '(0 0 0) "_none" (list 0 0 (* z 1000))))
	)
   )
   
   )
  (princ)
)

 

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