Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Edit object then add strike-through dimention.

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ramoneramone
247 Views, 4 Replies

Edit object then add strike-through dimention.

Hi dear.

First edit object, then add strike-through old text of dimension, conclude new text and old text.

 

(defun c:strikedim ()
(setq ent_name (car(entsel "select dim")))
(setq ss (entget ent_name))
(setq text (cdr (assoc 42 ss)))
(setq text_old (strcat "\\K" (rtos text)))
(setq text_new (strcat "<>" " " text_old))
(command "dimedit" "e" text_new ent_name "")
)
4 REPLIES 4
Message 2 of 5
EnM4st3r
in reply to: ramoneramone

like this?

 

(defun c:strikedim (/ correctent-p textent text dimdata dimdata-1 dimdata-13 dimdata-14)
  (defun correctent-p (ent /)
    (if ent
      (and  (= (cdr (assoc 0 (entget (car ent)))) "MTEXT")
            (if (= (type (car (nth 3 ent))) 'ENAME)
              (= (cdr (assoc 0 (entget (car (nth 3 ent))))) "DIMENSION")
              nil
            )
      )
      nil
    )
  )
  (while (not (correctent-p textent))
    (setq textent (nentsel "\nSelect the Dimension text: "))
  )
  (setq text (vla-get-textstring (vlax-ename->vla-object (car textent)))
        dimdata (entget (car (nth 3 textent))) ;save original dimension data
        dimdata-13 (append '(13) (getpoint "\nFirst Dimension Point: ")) 
        dimdata-14 (append '(14) (getpoint "\nSecond Dimension Point: "))
        dimdata-1 (cons 1 (strcat "<> {\\K" text "}"))

        dimdata (subst dimdata-13 (assoc 13 dimdata) dimdata) ; replace with new data
        dimdata (subst dimdata-14 (assoc 14 dimdata) dimdata)
        dimdata (subst dimdata-1 (assoc 1 dimdata) dimdata)
    )
  (entmod dimdata)
  (princ)
  (princ)
)

 

 

 

Message 3 of 5
ramoneramone
in reply to: EnM4st3r

It is almost exactly as I imagined.
Would it be possible to make the dimensions change by drag and drop instead of using the get point function?
Message 4 of 5
EnM4st3r
in reply to: ramoneramone

i dont know how you would implement that into one lisp,
but I can just remove those steps so it literally just strikes the dimension:

(defun c:strikedim (/ correctent-p textent text dimdata dimdata-1)
  (defun correctent-p (ent /)
    (if ent
      (and  (= (cdr (assoc 0 (entget (car ent)))) "MTEXT")
            (if (= (type (car (nth 3 ent))) 'ENAME)
              (= (cdr (assoc 0 (entget (car (nth 3 ent))))) "DIMENSION")
              nil
            )
      )
      nil
    )
  )
  (while (not (correctent-p textent))
    (setq textent (nentsel "\nSelect the Dimension text: "))
  )
  (setq text (vla-get-textstring (vlax-ename->vla-object (car textent)))
        dimdata (entget (car (nth 3 textent))) ;save original dimension data
        dimdata-1 (cons 1 (strcat "<> {\\K" text "}")) ;set strike-text
        dimdata (subst dimdata-1 (assoc 1 dimdata) dimdata) ;apply strike-text
  )
  (entmod dimdata)
  (princ)
)

 

 

Message 5 of 5
ramoneramone
in reply to: ramoneramone

Thanks😀

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta