Jump to content

Recommended Posts

Posted (edited)

Hi I use this lisp command. In Autocad works fine but now I am working with ZWCAD and is not working and gives me this error

 

Error: An error has occurred inside the *error* function ZWCAD setvar reject: MLEADERSCALE nil

 

Any ideas?

 

 

 

(defun c:MLP (/ oldcmd oldcmls oldlay oldmls *error*)
(defun *error* (msg)
(setvar 'cmleaderstyle oldcmls)
(setvar 'clayer oldlay)
(setvar 'mleaderscale oldmls)
(setvar "cmdecho" oldcmd)
(princ msg)
(princ)
)
(setq oldcmd (getvar 'cmdecho)
     oldcmls (getvar 'cmleaderstyle)
  oldlay (getvar 'clayer)
  oldmls (getvar 'mleaderscale)
)	  

(setvar "cmdecho" 0)
(setvar "cmleaderstyle" "TopoCad")
(if 
 (not (tblsearch "LAYER" "MLP"))
 (command "_layer" "_m" "MLP" "_c" "7" "" "")
)
(setvar 'clayer "MLP")
(setq scl (getvar "useri1"))
(setvar "mleaderscale" (* scl 0.001))


(initcommandversion 2)
(princ "\n Select first point: ")
(command "mleader")
(while (> (logand (getvar "CMDACTIVE") 0) 1)
(command pause )
) 

(setvar 'cmleaderstyle oldcmls)
(setvar 'clayer oldlay)
(setvar 'mleaderscale oldmls)
(setvar "cmdecho" oldcmd)
(princ)
;layer 0
(mapcar 'setvar '("clayer" "cecolor" "celtype" "celweight")  (list "0" "BYLAYER" "BYLAYER" -1))
(princ)
)

 

 

Thanks

Edited by mhy3sx
Posted

you did not define what "uservari1" is? This is a user defined variable that persists across all drawings. Your lisp routine is defaulting to the value of 0 for this var. 

 

Posted

 Hi j2lstaples. This is the scale lisp. I use it for all lisp files .  As I said jn Autocad the MLP code works fine but in ZWCAD

 

Error: An error has occurred inside the *error* function ZWCAD setvar reject: MLEADERSCALE nil

 

Any ideas?

 

( DEFUN C:SETSC ()
  (setvar "OSMODE" 13)
  (setq cursc (getvar "useri1" ))
  (princ "\nSet Scale 1:")(princ cursc)
  (setq newsc (getint "\nThe new scale is 1:"))
  (setvar "useri1" newsc)
  (princ newsc)
  (princ)
)

 

Thanks

 

 

Posted

1. Variable MLEADERSCALE is not defined under ZWCAD 2024. Do not use it!

2. In order to use "TopoCad" as a value of the variable "CMLEADERSTYLE", first of all define it with the command "MLEADERSTYLE".

3. Same thing for "Ενδείξεις" layer name.

Posted

Hi Lido. How to change the scale of the mleader if  MLEADERSCALE not supported?

 

Thanks

Posted

@mhy3sx

Try this:

;;Change MLEADER scale
;;Example (mlscale "Standard" 2.0)
(defun mlscale (st newScale)
 (vla-put-scalefactor (vla-item (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "ACAD_MLEADERSTYLE") st) newScale)
 (princ)
)

 

Posted

Hi lido. I try this but is not working.

 

(defun c:test (/ oldcmd oldcmls oldlay oldmls *error*)
(if 
 (not (tblsearch "LAYER" "MLP"))
 (command "_layer" "_m" "MLP" "_c" "7" "" "")
)
(setvar "cmdecho" 0)
(setvar "cmleaderstyle" "TopoCad")
(setvar 'clayer "MLP")
(setq scl (getvar "useri1"))
(vla-put-scalefactor (vla-item (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "ACAD_MLEADERSTYLE") (* scl 0.001)))
(command "mleader")
;layer 0
(mapcar 'setvar '("clayer" "cecolor" "celtype" "celweight")  (list "0" "BYLAYER" "BYLAYER" -1))
(princ)
)

 

Posted

Replace:

(vla-put-scalefactor (vla-item (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "ACAD_MLEADERSTYLE") (* scl 0.001)))

with:

 (vla-put-scalefactor (vla-item (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "ACAD_MLEADERSTYLE") "TopoCad") (* scl 0.001))

 

Posted

Hi lido, I did the change, but the new code works with different way than the code in post1.

The new code scale all the leaders in the drawing, and I don't want this.

Is any other way to fix the code in post 1

 

 

 

(defun c:test (/ oldcmd oldcmls oldlay oldmls *error*)
(if 
 (not (tblsearch "LAYER" "MLP"))
 (command "_layer" "_m" "MLP" "_c" "7" "" "")
)
(setvar "cmdecho" 0)
(setvar "cmleaderstyle" "TopoCad")
(setvar 'clayer "MLP")
(setq scl (getvar "useri1"))
(vla-put-scalefactor (vla-item (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "ACAD_MLEADERSTYLE") "TopoCad") (* scl 0.001))
(command "mleader")
;layer 0
(mapcar 'setvar '("clayer" "cecolor" "celtype" "celweight")  (list "0" "BYLAYER" "BYLAYER" -1))
(princ)
)

 

 

Thanks

  • 2 weeks later...
Posted

Hi the new version of the code when i change the scale of the drawing scale all the leaders in the drawing. Is any way to change the scale only to the insert  leader.

 

For example  I am working a drawing and I have scale 1:50 and 1:100. When for 1:50 insert the leaders I want , and change the drawing scale toy 1:100 to insert leaders again , the leaders for 1:50 change. I want to insert the leader for the current scale, but not change the other leaders in the drawing

 

(defun c:test (/ oldcmd oldcmls oldlay oldmls *error*)
(if 
 (not (tblsearch "LAYER" "MLP"))
 (command "_layer" "_m" "MLP" "_c" "7" "" "")
)
(setvar "cmdecho" 0)
(setvar "cmleaderstyle" "TopoCad")
(setvar 'clayer "MLP")
(setq scl (getvar "useri1"))
(vla-put-scalefactor (vla-item (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "ACAD_MLEADERSTYLE") "TopoCad") (* scl 0.001))
(command "mleader")
;layer 0
(mapcar 'setvar '("clayer" "cecolor" "celtype" "celweight")  (list "0" "BYLAYER" "BYLAYER" -1))
(princ)
)

 

Thanks

Posted

According to my knowledge, what you want cannot be done under ZWCAD. I suggest you to open a ticket on the ZWCAD website to report the error.

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