jamesfui Posted December 16, 2011 Posted December 16, 2011 (edited) hi.. need help on creating lsp that can: > load & unload *.arx file which is located on specified folder! example; ``````` [size=2](defun c:arxload()[/size] [size=2](command "load" "[/size][size=2]c:\documents & settings\user\addons\mditab17.arx[/size][size=2]")(princ))[/size] [size=2](defun c:arxunload()[/size] [size=2](command "unload" "[/size][size=2]c:\documents & settings\user\addons\mditab17.arx[/size][size=2]")(princ))[/size] thanks Edited December 16, 2011 by SLW210 Quote
Lee Mac Posted December 16, 2011 Posted December 16, 2011 Use the arxload / arxunload functions, e.g.: (arxload "C:/YourFolder/YourFile.arx" nil) (arxunload "YourFile" nil) Quote
BlackBox Posted December 16, 2011 Posted December 16, 2011 Welcome to CADTutor! First, I'd suggest that you NOT define custom commands using the same name as that of a protected symbol (LISP function). Second, give this a try: (defun c:MDITAB () ((lambda (arxList mdi path) (princ (strcat "\rMDITAB: " (cond ((member mdi arxList) (arxunload mdi) "UNLOADED ") ((arxload (strcat path mdi)) "LOADED "))))) (arx) "mditab17.arx" "c:\\documents & settings\\user\\addons\\") (princ)) Quote
jamesfui Posted December 16, 2011 Author Posted December 16, 2011 wow!!! i can't believe that it is you (Lee Mac) who is the first one to reply my first post!!! it sure is my pleasure!! i was so happy, cz i'm currently using your created lsp to help on my drafting work... and it really is very very handy/useful! that save time & effort too.... thks a lot Actually i got plenty of issue(post) on autolisp since i started it when i feel the power lsp routines can do so much for me in autocad. that's why i join this forum just today to seek more understanding/experience on autolisp! Will sure try it out asap when i go back to office! thanks again!!!! hAPPy Quote
jamesfui Posted December 16, 2011 Author Posted December 16, 2011 thanks for the welcome! Feel really great to get another suggestion from you! i'm new to autolisp but it sure gives me the interest to learn deeper in it... Will sure try it out!!! thanks a lot Mr. RenderMan Quote
SLW210 Posted December 16, 2011 Posted December 16, 2011 Please read the CODE POSTING GUIDELINES I fixed it for you this time. Quote
jamesfui Posted December 16, 2011 Author Posted December 16, 2011 thanks! i already read the guidelines you posted... now i understand =) will sure keep in mind on my next post! thanks ya! Quote
Lee Mac Posted December 16, 2011 Posted December 16, 2011 wow!!! i can't believe that it is you (Lee Mac) who is the first one to reply my first post!!! it sure is my pleasure!! i was so happy, cz i'm currently using your created lsp to help on my drafting work... and it really is very very handy/useful! that save time & effort too.... thks a lot Thanks - I'm flattered that my reputation precedes me. Thanks for using my programs, I hope they can assist you in your work. First, I'd suggest that you NOT define custom commands using the same name as that of a protected symbol (LISP function). A good point to raise, however for clarification, note that the defined symbol in this case is "c:arxload", not the protected arxload symbol Quote
BlackBox Posted December 16, 2011 Posted December 16, 2011 You're very welcome ; I too am a student of Lee's so-to-speak. Quote
BlackBox Posted December 16, 2011 Posted December 16, 2011 A good point to raise, however for clarification, note that the defined symbol in this case is "c:arxload", not the protected arxload symbol Cheers, Lee - on both counts! LoL Quote
Lee Mac Posted December 16, 2011 Posted December 16, 2011 I too am a student of Lee's so-to-speak. Well... I think you've long overtaken me with your .NET studies Quote
BlackBox Posted December 16, 2011 Posted December 16, 2011 Well... I think you've long overtaken me with your .NET studies That is kind of you to say, my friend. It's funny you mention .NET as I've just written a LispFunction Method "NETLOAD" for LISP that accepts a single argument, a valid file path to DLL, as String (just for fun). LoL Quote
BlackBox Posted December 16, 2011 Posted December 16, 2011 Welcome to CADTutor! First, I'd suggest that you NOT define custom commands using the same name as that of a protected symbol (LISP function). Second, give this a try: FWIW - I keep both the 32-Bit, and 64-Bit MDITAB .ARX files in the same directory (I just renamed the ones for 64-Bit as noted in the code below), and use this **shell to filter for which one to load across multiple AutoCAD versions, and operating systems: ** I actually do not use this command, rather I use a System Variable Reactor to perform the same function automagically. [color=black] [/color](defun c:MdiTab (/ 64Bit-p) ;; © RenderMan, 2011 (vl-load-com) (defun 64Bit-p () ;; © RenderMan, 2011 ;; Returns T if version is 64-Bit ;; Example: (64bit-p) (if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) T nil)) ((lambda (key sdi / mditab flag) (if (and sdi (setq mditab (cond ((vl-string-search "17" key) ; 2007, 2008, 2009 (if (64Bit-p) "mditab17x64.arx" "mditab17.arx")) ((vl-string-search "18" key) ; 2010, 2011, 2012 (if (64Bit-p) "mditab18x64.arx" "mditab18.arx")))) (setq flag (findfile mditab)) (not (vl-position mditab (arx)))) (and (arxload mditab) (princ "\rMDITAB: LOADED ")) (cond (flag (and (arxunload mditab) (princ "\rMDITAB: UNLOADED "))) (mditabs (prompt (strcat "\n** \"" mditab "\" cannot be found ** "))) (sdi (prompt "\n** This AutoCAD version not supported ** ")) ((prompt "\n** Command not allowed in SDI mode ** "))))) (vlax-product-key) (= 0 (getvar 'sdi))) (princ)) HTH Quote
jamesfui Posted December 17, 2011 Author Posted December 17, 2011 Yep! it sure works alrighty... thanks a lot LeeMac!! be sure to help too on my next post later k Quote
jamesfui Posted December 17, 2011 Author Posted December 17, 2011 the second suggestion from RenderMan works fine too! thanks ya Quote
N_461 Posted October 24, 2012 Posted October 24, 2012 Hey boys, not sure how old this thread is, dates not showing up ... BUT I just ran this (32 vs 64 code) and I get the incompatable string in my face? Im running 2010 Cad, Win7 64 am i not doing something here? Quote
N_461 Posted October 24, 2012 Posted October 24, 2012 **add: just wanting to add into my acaddoc.lsp Quote
BlackBox Posted October 24, 2012 Posted October 24, 2012 Hey boys, not sure how old this thread is, dates not showing up ... BUT I just ran this (32 vs 64 code) and I get the incompatable string in my face?Im running 2010 Cad, Win7 64 am i not doing something here? Which code specifically? Also, if you're able to determine... What line throws the error when you step through in VLIDE? 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.