Jump to content

Can I load a routine by another one and use it within it?


Recommended Posts

Posted

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

Posted

Hmmm... never done this before, but maybe:

 

(defun C:Loading ()
 (load "C:\\Documents and Settings\\user\\My Documents\\FYP\\spring.fas" )
 (c:spring)
(princ))

Guest kruuger
Posted

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

Posted

Hello...

 

Thanks to you both ( Lee Mac & kruuger ) for your fast reply...

 

yes it worked for me...

 

It was my pleasure

Posted

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

 

}}

Posted

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)

Posted
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))

Posted

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

Posted

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

Posted
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 :thumbsup:

Posted
Nice idea Alan - didn't think of that :thumbsup:

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.

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