SunnyTurtle 发表于 2022-7-5 19:57:48

overwrite _open

Hi Guys
This Code worked in some form on my last computer i have attempted to fix it. it appears that i cannot overwrite the "_open" function is there a variable for this.
;        variables set(setq tilemodevar (getvar "tilemode"))(setq varCPROFILE (getvar "CPROFILE"))(setq varFILEDIA (getvar "FILEDIA"));        close windows(COMMAND "EXTERNALREFERENCESCLOSE")(COMMAND "LAYERCLOSE")(COMMAND "PROPERTIESCLOSE")(COMMAND "ADCCLOSE");        Open drawing from vault(if (= varCPROFILE "profile_name")(progn(defun c:_open ()   (command"_vltopen"""   ) ;_ end of command ) ;_ end of progn );_ end of if (command "_open")   );_ end of defun;        autocad variables unset(setvar "FILEDIA" FILEDIAvar)
I use this to overwrite _open so when i am in a particular profile and press ctrl+O it used _vltopen

BIGAL 发表于 2022-7-5 20:21:02

Check out Undefine and Redefine look at help pretty self explaining

SunnyTurtle 发表于 2022-7-5 20:42:40

I have fixed it with the undefine and redefine commands as BIGAL suggested
Thanks BIGAL you legend
Work to the extent i need it to.
Startup File

; vault open(command "redefine" "open")(command "undefine" "open")(defun c:open () (progn   (load "VLT_DWG_OPEN.lsp")   ))
VLT_DWG_OPEN.lsp

;        variables set(setq tilemodevar (getvar "tilemode"))(setq varCPROFILE (getvar "CPROFILE"))(setq varFILEDIA (getvar "FILEDIA"))    ;        close windows(COMMAND "EXTERNALREFERENCESCLOSE")(COMMAND "LAYERCLOSE")(COMMAND "PROPERTIESCLOSE")(COMMAND "ADCCLOSE");        Open drawing from vault(if (= varCPROFILE "vaultprofile") (progn   (command "redefine" "open")   (command "undefine" "open")   (Defun vltautoopen ()   (command"_vltopen"""   ) ;_ end of command   ) ;_ end of Defun   (vltautoopen) ) ;_ end of progn (command "redefine" "_open")) ;_ end of if;        autocad variables unset(setvar "FILEDIA" FILEDIAvar)
 
getting this error but it still works

_open Unknown command "OPEN".Press F1 for help.1

BIGAL 发表于 2022-7-5 20:47:01

Not sure if you need the redefine and then define one after each other.

SunnyTurtle 发表于 2022-7-5 20:59:35

 
i was having problems when testing because i think it was failing on the "undefine" if it was already undefined. but i am not sure if that was a problem.
页: [1]
查看完整版本: overwrite _open