LISP doesn't work anymore

LISP doesn't work anymore

Sandervp
Advocate Advocate
1,544 Views
4 Replies
Message 1 of 5

LISP doesn't work anymore

Sandervp
Advocate
Advocate

Hello everybody,

 

I do have a lisp file which changes the defined width length of a Mtext to 0.0 if I use this.

By using the command "WD" I need to select the Mtext objects and after selecting those, I'll see "Width <0.0>:" in my command bar.

 

But the width doesn't change to 0.0 but keeps the same as before using the lisp.

I'm using AutoCad 2016, the lisp had worked but not anymore...

 

Who can help me with this problem?

 

Thank you

 

(defun c:WD (/ ss wd)
  ;; CHANGE WIDTH MTEXT TO 0.0
  

  (vl-load-com)
  (if (and (setq ss (ssget "_:L" '((0 . "MTEXT,MULTILEADER"))))
           (setq wd (initget 4)
                 wd (cond ((getdist "\nWidth <0.0>: "))
                          (0.)
                    )
           )
      )
    (progn
      (vlax-for x (setq ss (vla-get-activeselectionset
                             (cond (*AcadDoc*)
                                   ((setq *AcadDoc* (vla-get-activedocument
                                                      (vlax-get-acad-object)
                                                    )
                                    )
                                   )
                             )
                           )
                  )
        (vl-catch-all-apply
          (function vlax-put-property)
          (list x
                (cond ((eq (vla-get-objectname x) "AcDbMText") 'Width)
                      ((eq (vla-get-objectname x) "AcDbMLeader") 'TextWidth)
                )
                wd
          )
        )
      )
      (vla-delete ss)
    )
  )
  (princ)
)
0 Likes
Accepted solutions (1)
1,545 Views
4 Replies
Replies (4)
Message 2 of 5

dlanorh
Advisor
Advisor
The "width" being changed by the lisp is the text box width, not the text width.

I am not one of the robots you're looking for

0 Likes
Message 3 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Nothing obvious, it works in my 2016. Try this one on MTEXT to see if it works...

 

(defun c:MtextWidth (/ ss acDoc i e)

  (if (setq ss (ssget "_:L" '((0 . "MTEXT"))))    
      (repeat (setq i (sslength ss))
        (setq e (entget (ssname ss (setq i (1- i))))
              e (append e '((75 . 0)))
              e (subst '(41 . 0.0) (assoc 41 e) e)
        )
        (entmod e)
      )
  )
)

 

Better post some sample dwg where it's not working.

0 Likes
Message 4 of 5

Sandervp
Advocate
Advocate

Hello BeekeeCZ,

 

Thank you for your solution. Your code works.

 

But it is still strange why it doesn't works anymore in my AutoCad 2016. I used my lisp very often a day, till it doesn't works anymore. There is nothing changed on my AutoCad / AutoCad version. 

 

Greetings Sander

0 Likes
Message 5 of 5

Anonymous
Not applicable

Try checking your system variables by using the sysvarmonitor command. 

 

This is the system variable monitor and if you enable it...you will receive balloon notifications of any variables that have changed and what # to put them back for better functionality.

0 Likes