lisp help closing current drawing

lisp help closing current drawing

Anonymous
Not applicable
1,187 Views
11 Replies
Message 1 of 12

lisp help closing current drawing

Anonymous
Not applicable

Hello ALL,

Below is the end of a lisp program I run to create an ACAD Electrical drawing package.

I am trying to close the current drawing and open the 1st drawing in the new project.

It will work fine but instead of closing the current drawing it opens the new drawing in a new window and the current drawing stays open and active.

 

I have tried closing the drawing in the lisp (command "close" "n" "y") but it will close both drawings no matter where i place it in the LISP.

 

Can anyone point me in the right direction as to how i can close the current and make the new drawing active?

 

thanks for any help you can give me!!!

 

Dennis

 

  ;--------------------------------------------------------------------------------------------------------------------------------------------------;
  ;WRAP UP PROGRAM AND END QUIETLY ;OPEN PROJECT AND SET TO CURRENT ;UPDATE PROJ WIDE SHEET #'S ;
  ;--------------------------------------------------------------------------------------------------------------------------------------------------;
 
 (close PROJECTFILE)                                                                                                                               ;closes project file
    
  (prompt "\nProject Creation Successful!")                                                                                             ;prompts good project created

   (c:wd_makeproj_current (strcat DWGDIR "/" JOBNUM " " CLIENTNAME " " machinetype ".wdp"))      ;makes new proj active

   (vla-open (vla-get-documents (vlax-get-acad-object)) (strcat DWGDIR"/"JOBNUM"_001.DWG"))         ;opens first drawing in project

   (c:ace_projwide_script  "NIL" "(c:shtnum)")                                                                                        ;changes sheet # to = dwg #

        
(PRINC)                                                                                                                                                 ;peace out have a good day

);defun main

(princ)
 

0 Likes
1,188 Views
11 Replies
Replies (11)
Message 2 of 12

Kent1Cooper
Consultant
Consultant

Try setting the SDI [Single-Drawing Interface] System Variable to 1.  That will at least close the current drawing in the process of opening another.  You will probably need that (c:ace_... part done separately, since as far as I know, an AutoLISP routine can't start in one drawing and continue in another, but I'm not completely sure, if because of that setting it's closing the drawing it starts in.

Kent Cooper, AIA
0 Likes
Message 3 of 12

Anonymous
Not applicable

I tried that 1 also but it returns with something to the effect of cannot execute command in SDI mode

 

but thanks for the help

 

Dennis

0 Likes
Message 4 of 12

Anonymous
Not applicable

i also have in my ACADDOC.LSP a routine that closes and saves (CAS.LSP) the current drawing when a new drawing opens up and that is not working in this situation either.

0 Likes
Message 5 of 12

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

I tried that 1 also but it returns with something to the effect of cannot execute command in SDI mode

....


Does it say which command?  If it's (vla-open), might it work if you use (command "_.open" ...) instead?  If it's the (c:ace_...) thing, can you build in setting SDI back to 0 before it runs that?

Kent Cooper, AIA
0 Likes
Message 6 of 12

Anonymous
Not applicable

it does not say which command.

i will try the _.open and see if that works

i tried SDI=1 and SDI=0 all over in that part of the LISP with no luck

 

Thanks

 

Dennis

 

0 Likes
Message 7 of 12

Anonymous
Not applicable

the (_.open) will only work in the SDI=1 mode.

As my ACADE has issues running in the SDI=1 mode I cannot run in that mode at all it freezes my ACADE.

 

Thanks

 

Dennis

0 Likes
Message 8 of 12

Anonymous
Not applicable

when I put the SDI=1 and SDI=0 arond the vla open like this

 

 (close PROJECTFILE)                                                               
  (prompt "\nProject Creation Successful!")
   (c:wd_makeproj_current (strcat DWGDIR "/" JOBNUM " " CLIENTNAME " " machinetype ".wdp"))
    (setvar "sdi" 1)
     (vla-open (vla-get-documents (vlax-get-acad-object)) (strcat DWGDIR"/"JOBNUM"_001.DWG"))        
    (setvar "sdi" 0)
   (c:ace_projwide_script  "NIL" "(c:shtnum)")                                
(PRINC)                                                                           
);defun main
(princ)

 

this is the error I get.

"Project Creation Successful!; error: Automation Error. Method not available in SDI mode"

 

This error is what comes up most of the time no matter where i put it in this part of the lisp.

 

Thanks

 

Dennis

0 Likes
Message 9 of 12

Anonymous
Not applicable

Look into sysyem variable LISPINIT

 

LISPINIT

Determines whether the LISP environment is re-initialized when a new drawing is created or opened. When set to 1, the LISP environment is re-initialized when opening or creating a new drawing. When set to 0, the LISP environment is saved and used in the new drawing.

 

Type:     Integer

Saved:     In the registry

Range:     0 (Off = Does not re-initialize LISP), 1 (On = Re-initializes LISP)

Default:     1

 

** sys var sdi must be in single drawing

 

@ command prompt  (setvar "lispinit" 0)

(setq a "test")

then close and launch a drawing

! a

"test"

 

hth

Southie

 

 

0 Likes
Message 10 of 12

Anonymous
Not applicable

** sys var sdi must be in single drawing

 

I wish i could try this but I cannot run in SDI=1 mode.

 

It freezes my AutoCAD Electrical program upon certian commands.

 

Thanks

 

Dennis

0 Likes
Message 11 of 12

Anonymous
Not applicable

At the end of function set both sys vars back to what they were.

0 Likes
Message 12 of 12

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

when I put the SDI=1 and SDI=0 arond the vla open like this

....                                                               

  (prompt "\nProject Creation Successful!")
   (c:wd_makeproj_current (strcat DWGDIR "/" JOBNUM " " CLIENTNAME " " machinetype ".wdp"))
    (setvar "sdi" 1)
     (vla-open (vla-get-documents (vlax-get-acad-object)) (strcat DWGDIR"/"JOBNUM"_001.DWG"))        
    (setvar "sdi" 0)
   (c:ace_projwide_script  "NIL" "(c:shtnum)")

....

this is the error I get.

"Project Creation Successful!; error: Automation Error. Method not available in SDI mode"

....


IF you were already in SDI=1 before you started that, it might be a problem in the (c:wd_...) part, which we haven't seen.  If NOT, it looks like it could only be the (vla-open) function, because if that succeeded, and if the routine could continue to work in the new drawing, then you'd be back in SDI=0 before the (c:ace_...) part could react in that way.  Have you tried setting SDI to 1 and running a (vla-open) function like that in isolation, to see whether that's the source of the error?  Presumably you would get the same error message without the "Project Creation Successful!" before it.  If you do, that's the issue, not that I know whether you can do anything about it....

 

Another check for (vla-open) being the issue:  Does it, despite the error message, get as far as opening the new drawing, even if it doesn't do the subsequent action?

Kent Cooper, AIA
0 Likes