Jump to content

Lisp modification request


MS13

Recommended Posts

I am using this to align texts and match elevations

 

Quote

(defun C:CH (/ e d s c v l -ch10)
  (defun -ch10 (e i v / d n)
    (setq d (cdr (assoc 10 (entget e))))
    (setq n
      (cond
        ( (= "X" i)(list v (cadr d)(caddr d)))
        ( (= "Y" i)(list (car d) v (caddr d)))
        ( (= "Z" i)(list (car d)(cadr d) v))
        (t v)
      )
    )
    (cd:ENT_SetDXF e 10 n)
  )
  (if
    (and
      (setq e (entsel "\Choose source text: "))
      (wcmatch (cdr (assoc 0 (setq d (entget (car e))))) "*TEXT")
    )
    (progn
      (redraw (car e) 3)
      (setq v (cdr (assoc 10 d)))
      (princ
        (strcat "\Change the coordinates of the insertion"
                " [X=" (cd:CON_Real2Str (car v) 2 nil)
                ", Y=" (cd:CON_Real2Str (cadr v) 2 nil)
                ", Z=" (cd:CON_Real2Str (caddr v) 2 nil)
                "]"
          
        )
      )
      (if
        (setq s (ssget ":L" '((0 . "*TEXT"))))
        (if
          (setq c
            (cd:USR_GetKeyWord
              "\Choose coordinate to change"
              '("X" "Y" "Z" "All" "End") "Z")
          )
          (if
            (= c "End")
            (princ "Choose ")
            (progn
              (setq l (cd:SSX_Convert s 0))
              (cd:SYS_UndoBegin)
              (foreach % l
                (cond
                  ( (= c "X")(-ch10 % c (car v)))
                  ( (= c "Y")(-ch10 % c (cadr v)))
                  ( (= c "Z")(-ch10 % c (caddr v)))
                  ( (= c "All")(-ch10 % "W" v))
                  (t nil)
                )
              )
              (cd:SYS_UndoEnd)
            )
          )
          (princ "\Cancelled. ")
        )
        (princ "\No choice. ")
      )   
    )
    (princ "\No choice. ")
  )
  (redraw (car e) 4)
  (princ)
)

 

In this lisp source could be only text or mtext. 

The thing is to add to this lisp a block as a source.

So text OR block would be a reference object

 

 

Link to comment
Share on other sites

  • 2 months later...

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