DryWater Posted April 4, 2009 Posted April 4, 2009 Hello everybody... Can I load a routine by another one and use it within it? I tried to do so but all my tries failed... I wrote something like this: {{ (defun C:Loading () (load "C:\\Documents and Settings\\user\\My Documents\\FYP\\spring.fas" ) (command "spring" ) ) }} when I load the (spring.fas) I can use it by typing "spring" in the AutoCAD command window... while this code successfully loads the file but the command "spring" is considered as unkown comman... why is this? Can anybody help me please? I need it for my final year project thank you all... Quote
Lee Mac Posted April 4, 2009 Posted April 4, 2009 Hmmm... never done this before, but maybe: (defun C:Loading () (load "C:\\Documents and Settings\\user\\My Documents\\FYP\\spring.fas" ) (c:spring) (princ)) Quote
Guest kruuger Posted April 4, 2009 Posted April 4, 2009 Hello I think you can't use "command" command. This is not autocad command so autocad will not recognize it. Try This (defun C:Loading () (load "C:\\Documents and Settings\\user\\My Documents\\FYP\\spring.fas" ) (C:spring) ) Quote
DryWater Posted April 4, 2009 Author Posted April 4, 2009 Hello... Thanks to you both ( Lee Mac & kruuger ) for your fast reply... yes it worked for me... It was my pleasure Quote
DryWater Posted April 4, 2009 Author Posted April 4, 2009 Hi again... the routine that i load "spring.fas" starts with typing "spring"... after it starts I need to enter either a keyword "E" or "C" then some numbers... your suggested solution worked for me only in the first command ( which is "spring" ) then it does not work for the rest... am i doing something wrong or there is another way to do this? my new code is: {{ (defun C:Loading () (load "K:/spring.fas" ) (c:spring) (c:E) (princ)) }} Quote
CarlB Posted April 4, 2009 Posted April 4, 2009 I posted some replies to your questions in another forum then see you've progressed further in this one... If in "spring" you want to feed it data when it's called rather than be prompted, you need to revise "spring" to not be a "command" function. More like (defun spring (var1 var2)) etc.... then call it with (spring dat1 dat2) Quote
Lee Mac Posted April 4, 2009 Posted April 4, 2009 Hi again... the routine that i load "spring.fas" starts with typing "spring"... after it starts I need to enter either a keyword "E" or "C" then some numbers... your suggested solution worked for me only in the first command ( which is "spring" ) then it does not work for the rest... am i doing something wrong or there is another way to do this? my new code is: {{ (defun C:Loading () (load "K:/spring.fas" ) (c:spring) (c:E) (princ)) }} Well I suppose you could try: (defun C:Loading () (load "K:/spring.fas" ) (c:spring) (command "E") (princ)) Quote
DryWater Posted April 4, 2009 Author Posted April 4, 2009 Hi all, CarlB I guess you know that *.fas files are compiled machine code that cannot be modified unless you have the original *.lsp file, therefore my problem is that i have a .fas file that i need and i cant modify... this file once initialized waits for further inputs from the user... my aim is to write a code that uses "spring.fas" to generate the drawing without interfering with the user... therefore, is there is anyway to do this? Lee Mac I tried this but didnt work for me Thank you all for you effort Quote
alanjt Posted April 7, 2009 Posted April 7, 2009 there's always a way this will create a temp .scr file and load it; nothing special. (defun c:Test (/ #File #Open) (if (not c:Spring) (load "Spring.fas") ) ;_ if (setq #File (vl-filename-mktemp "" "" ".scr") #Open (open #File "w") ) ;_ setq (write-line "spring e" #Open) (close #Open) (vl-cmdf "_.script" #File) (princ) ) ;_ defun Quote
Lee Mac Posted April 7, 2009 Posted April 7, 2009 there's always a way this will create a temp .scr file and load it; nothing special. (defun c:Test (/ #File #Open) (if (not c:Spring) (load "Spring.fas") ) ;_ if (setq #File (vl-filename-mktemp "" "" ".scr") #Open (open #File "w") ) ;_ setq (write-line "spring e" #Open) (close #Open) (vl-cmdf "_.script" #File) (princ) ) ;_ defun Nice idea Alan - didn't think of that Quote
alanjt Posted April 7, 2009 Posted April 7, 2009 Nice idea Alan - didn't think of that thanks i thought of this a while back when a guy wanted a way to combine txt2mtxt and textmask. i try and keep it in the back of my mind for such occasions. 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.