mhy3sx Posted November 3, 2023 Posted November 3, 2023 (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 November 7, 2023 by mhy3sx Quote
j2lstaples Posted November 3, 2023 Posted November 3, 2023 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. Quote
mhy3sx Posted November 3, 2023 Author Posted November 3, 2023 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 Quote
lido Posted November 4, 2023 Posted November 4, 2023 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. Quote
mhy3sx Posted November 4, 2023 Author Posted November 4, 2023 Hi Lido. How to change the scale of the mleader if MLEADERSCALE not supported? Thanks Quote
lido Posted November 6, 2023 Posted November 6, 2023 @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) ) Quote
mhy3sx Posted November 7, 2023 Author Posted November 7, 2023 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) ) Quote
lido Posted November 7, 2023 Posted November 7, 2023 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)) Quote
mhy3sx Posted November 7, 2023 Author Posted November 7, 2023 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 Quote
mhy3sx Posted November 17, 2023 Author Posted November 17, 2023 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 Quote
lido Posted November 17, 2023 Posted November 17, 2023 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. Quote
Recommended Posts
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.