Error when loading a script with lisp

Error when loading a script with lisp

Anonymous
Not applicable
2,310 Views
16 Replies
Message 1 of 17

Error when loading a script with lisp

Anonymous
Not applicable

 

Hi, i wrote a little lisp that write script and the activite it. If i check everything , the script and the txt blocks everything is right. 

But i keep getting a error on the point that i activate the command to script. error is attached, tried diffrent way's but no luck. The command (putexcelplanlijst) is actived as End of a dialog after done dialog. 

 

 

 

 

(defun PUTEXCELPLANLIJST ( / dossval DWGprefix Externfolder script Drawings Drawing Files 
			  sf dossfile TextDoss)


  (setq DWGprefix (getvar "dwgprefix"))
  (setq Externfolder (strcat DWGprefix "\#Library-Do Not Edit#"))
  (setq TextDoss (strcat Externfolder "\\BinDossVal.txt"))



  (setq dossfile (open TextDoss  "R"))
  (setq  dossval (read-line dossfile))
  (close dossfile)





  (setq Drawings (GetValList1))
  (setq ThisDwg (strcat DWGprefix (getvar "dwgname")))
  (setq script (strcat Externfolder "\\BinOpenDWGforTitleblock.SCR"))

  (foreach x Drawings
    (setq Drawing (strcat DWGprefix x ".dwg"))
    (if (not(= Drawing  ThisDwg))
      (setq Files (cons Drawing Files))
      )
    )

  (if (> (length Files) 0)
	(progn
	  (setq sf (open script "w"))
	  (foreach dwg Files
	    (princ (strcat "\""dwg "\""))
	    (write-line "_.open" sf)
	    (write-line (strcat "\""dwg "\"") sf)
;;;	    (write-line "(load \"Dossier\")" sf)
;;;	    (write-line "c:DISTRIBUTEEXCELPLANNLIJST" sf)
	    (write-line "_.qsave" sf)
	    (write-line "_.close" sf)
	    )
;;;	  (write-line "Filedia" sf)
;;;	  (write-line "1" sf)
	  (close sf)
;;;	  (setvar "filedia" 0)
	  (command "script" "R:\5100-5199\5107 Vaneenoo Noirefontaine Hall 2\ACAD\#Library-Do Not Edit#\BinOpenDWGforTitleblock.SCR")
	  )
	(Alert (strcat "There is no dwg files in " path "!"))
	)
;;;
;;;        )
;;;    )
  (princ)
  )

 

 

 

 

 

 

 

0 Likes
Accepted solutions (2)
2,311 Views
16 Replies
Replies (16)
Message 2 of 17

Anonymous
Not applicable

I read previeus things about SDI, it's now on zero. 

Also when i do this command, after i get that error, my right mousclick is redefined from minimenu to repeat command (with right mousebutton). 

That is also not so good.

0 Likes
Message 3 of 17

hmsilva
Mentor
Mentor

Hi Subje,

try to add a backslash at

(setq Externfolder (strcat DWGprefix "\\#Library-Do Not Edit#"))

 

(I didn't test the code...)

 

Henrique

EESignature

0 Likes
Message 4 of 17

Anonymous
Not applicable

Hi henrique,

 

Everything good? So i did that change, put some princs in it but still the same error. Maybe it's something with the options of my cad? 

 

below commandline + revised code

 

to be honest this morning the script worked (the open en close part cause i was still building it), but this afternoon i was getting the same error.

 

Command: DOSSIER
Command:
R:\5100-5199\5107 Vaneenoo Noirefontaine Hall 2\ACAD\\#Library-Do Not Edit#
R:\5100-5199\5107 Vaneenoo Noirefontaine Hall 2\ACAD\\#Library-Do Not Edit#\BinDossVal.txt
R:\5100-5199\5107 Vaneenoo Noirefontaine Hall 2\ACAD\\#Library-Do Not Edit#\BinOpenDWGforTitleblock.SCR
R:\5100-5199\5107 Vaneenoo Noirefontaine Hall 2\ACAD\\#Library-Do Not Edit#\BinOpenDWGforTitleblock.SCR
Command:
Command: 

 

 

 

 

(defun PUTEXCELPLANLIJST ( / dossval DWGprefix Externfolder script Drawings Drawing Files 
			  sf dossfile TextDoss)


  (setq DWGprefix (getvar "dwgprefix"))
  (setq Externfolder (strcat DWGprefix "\\#Library-Do Not Edit#"))
  (princ (strcat "\n" Externfolder))
  (setq TextDoss (strcat Externfolder "\\BinDossVal.txt"))
  (princ (strcat "\n" TextDoss))

  (setq dossfile (open TextDoss  "R"))
  (setq  dossval (read-line dossfile))
  (close dossfile)


  (if (= GetValList1 nil)
    (setq Drawings(GetFiles))
    (setq Drawings (GetValList1))
    )
 
  (setq ThisDwg (strcat DWGprefix (getvar "dwgname")))
  (setq script (strcat Externfolder "\\BinOpenDWGforTitleblock.SCR"))
  (princ (strcat "\n" script))


  (foreach x Drawings
    (setq Drawing (strcat DWGprefix x ".dwg"))
   
    (if (not(= Drawing ThisDwg))
      (setq Files (cons Drawing Files))
      )
    )
 

  (if (> (length Files) 0)
	(progn
	  (setq sf (open script "w"))
	  (foreach dwg Files
	    (write-line "_.open" sf)
	    (write-line (strcat "\""dwg "\"") sf)
;;;	    (write-line "(load \"Dossier\")" sf)
;;;	    (write-line "c:DISTRIBUTEEXCELPLANNLIJST" sf)
	    (write-line "_.qsave" sf)
	    (write-line "_.close" sf)
	    )
;;;	  (write-line "Filedia" sf)
;;;	  (write-line "1" sf)
	  (close sf)
	  (princ (strcat "\n" script))
	  (command "script" "R:\5100-5199\5107 Vaneenoo Noirefontaine Hall 2\ACAD\#Library-Do Not Edit#\BinOpenDWGforTitleblock.SCR")
	  )
	(Alert (strcat "No script found !"))
	)
;;;
;;;        )
;;;    )
  (princ)
  ); Defun

 

0 Likes
Message 5 of 17

hmsilva
Mentor
Mentor

@Anonymous wrote:

Hi henrique,

Everything good? So i did that change, put some princs in it but still the same error. Maybe it's something with the options of my cad? 


Hi Subje,

yes, everything good, thank you!

 

Can you post the 'GetValList1' function?

 

Henrique

EESignature

0 Likes
Message 6 of 17

Anonymous
Not applicable

here's is the vallist1 + some other linked Values's + The function i want to load in the script as last. any option i need to check, perhaps options that has impact on loading scripts? it's also on my server so does it isn't in a trusted folder? this morning i could open multiple drawings with the script, but i  realised i need to close dialog first so i did a rebuild. 

 

 

Getvaluelist1

 

(defun GetValList1 ( /  files Lines List1 filesL a First LinesL)

  (setq files (GetFiles))

  (setq Lines (Getlines))
  (setq LinesL (length Lines))

  (setq filesL (length files))
 

  

  (if (/= LinesL nil)
    (repeat filesL
      (setq First (car files))
      (if (member First Lines)
	(setq files (cdr files))
	(progn
	  (setq List1 (cons First List1))
	  (setq files (cdr files))
	  )
	)
      )
    (progn
      (setq List1 files)
    )
    )
  List1
  );Defun

 Get lines

 

(defun Getlines ( / DWGprefix Externfolder TxtfileDir file Txtline Listtxt)

  (setq DWGprefix (getvar "dwgprefix"))
  (setq Externfolder (strcat DWGprefix "\\#Library-Do Not Edit#"))
  (setq TxtfileDir (strcat  Externfolder "\\BinDWGforPLANLIJST.txt" ))

  (if (findfile TxtfileDir)
    (progn
      ;; set and open file for reading
      (setq file (open  TxtfileDir  "R"))
      ;; each time you issue 'read-line' on a file, it will go to the next line,
      ;; so as long as it will allow me to read-line the file, it will define the value
      ;; to a variable...
      (while (setq Txtline (read-line file))
	;; value set as #Line, now I'll append it to a list eg. (list "A" "B" "C")
	(setq Listtxt (cons Txtline Listtxt))
	) ;_ while
      ;; close file
      (close file)
      ;; since I have to append from the front, my list is in reverse, so I just rearrange it.
      (setq Listtxt (reverse Listtxt))
      )
    nil
    )
) ;_ defun

 

getfiles

 

(defun GetFiles ( / files file filelength filename filenamelst dcl_id ddiag)

  
  (setq DWGprefix (getvar "dwgprefix"))
  (setq files (vl-directory-files DWGprefix "*.dwg" ))
  (foreach x files
    (setq file x)
    (setq filelength (strlen file))
    (setq filelength (- filelength 4))
    (setq filename (substr file 1 filelength))
    (setq filenamelst (cons filename filenamelst))
    )
   )

 

(defun c:DISTRIBUTEEXCELPLANNLIJST ( / file Textblock Externfolder Activedoc DWGprefix Txtline Listtxt Blockname objs ss
				    Listtxt ListtxtL Li ListAttVal Att Attl Val itm blks)


  (setq Activedoc (vla-get-activedocument (vlax-get-acad-object)))
  (setq blks (vla-get-Blocks Activedoc))
  (setq DWGprefix (getvar "dwgprefix"))
  (setq Externfolder (strcat DWGprefix "\#Library-Do Not Edit#"))
  (setq Textblock (strcat Externfolder "\\BinTextExcelAviable.txt"))

  (setq file (open Textblock  "R"))
  (while (setq Txtline (read-line file))
      (setq Listtxt (cons Txtline Listtxt))
       
    )
  (close file)

  ;; since I have to append from the front, my list is in reverse, so I just rearrange it.
  (setq Listtxt (reverse Listtxt))


  (foreach x Listtxt
    (setq  Blockname (strcat x))
    (setq TextB (strcat Externfolder "\\" Blockname ".txt"))
    (setq fileB (open TextB "R"))
    (while (setq TxtBline (read-line fileB))
      (setq ListBtxt (cons TxtBline ListBtxt))
      )
    (close fileB)
    
    (setq ListAttVal nil)

    (setq ListBtxtL (/ (length ListBtxt) 2))
    (repeat ListBtxtL
      (setq Li (reverse(list (car ListBtxt) (cadr ListBtxt))))
      (Setq ListAttVal (cons Li ListAttVal))
      (setq ListBtxt (cdr (cdr ListBtxt)))
      )
		


    (foreach x ListAttVal
      (Setq Att (car x))
      (setq Attl  (strlen Att))
      (setq Attl  (- Attl 1 ))
      (setq Att (substr Att 1 Attl))

      (setq Val (cadr x))


      (if (tblsearch "block" Blockname)
      (progn
	(if (setq SS (ssget "_X" '((0 . "INSERT")(66  . 1))))
	  (vlax-for block (setq SetDoc (vla-get-ActiveSelectionSet Activedoc))
	    (if
	      (= (strcase (vlax-get-property block 'EffectiveName)) (strcase Blockname))
	      (progn

	  
		  (if  (setq itm (assoc
			       (strcase Att)
			       (mapcar(function(lambda (j)(list(vla-get-tagstring j)(vla-get-textstring j)j)))
				      (vlax-invoke block 'GetAttributes))))
		    (progn
		      (vla-put-textstring (last itm) Val)
		      )
		    
		  )
		  )
		  
		
		)
	      )
	    
	    )
	  )
	)

      )
      
    )
  (princ)
  )

 

0 Likes
Message 7 of 17

Anonymous
Not applicable

Henrique,

 

Just noticed when testing the-last made script in commandbar i notice that works without error. but when i run it in lisp i got a error.

gonna check if i can get here a workaround.

0 Likes
Message 8 of 17

hmsilva
Mentor
Mentor

Subje,

 

firstly, my apologies for misleading you in my first post...

you don't need to add an extra backslash at

(setq Externfolder (strcat DWGprefix "\#Library-Do Not Edit#"))

I did read the the code much too fast, sorry... Smiley Embarassed

 

I did test the code, without any error, i just did repace the hardcoded script path for

(command "script" script)

 

EDIT: I can't test the code in a server, because I'm at home, and with an oollddd laptop and an oolllddd AutoCAD...

 

Henrique

EESignature

0 Likes
Message 9 of 17

Anonymous
Not applicable
Accepted solution

Henrique

 

no prob it's never bad to test things out. either way you know if it's for good or not.

 

Ok Update, i read your answer and continued testing. it could be the server or the dialog. And with the server no luck i put everything in trusted and everything what isn't trusted can enter to now :D. 

 

So i went on the dialog then and made some changes after 20 times. 

first off all the command was in the progress of the action key, so if you look bollow it's changed to a dialog number (althought that dialogsettings is a bermuda for me) 

 

second of all i took that command out of my 999st subfunction and made another function. Also in that one i changed command to command-s.

And now it's seem to be working. Thanks for the answer. My lisp has quite grow since last time right ;). but problaby not very clean :p. still need a lot of testing. 

 

i m actually thinking that command-s was prob the only thing i needed 😄

 

Oh i m sitting at home also, but i m working with teamviewer. otherwise i need to change all my folders and options in my default pc at home. for personal use it's free. it's no product of my so if it's against the violations of this forum i can always delete it.

 

http://www.teamviewer.com/en/index.aspx?pid=google.tv_exact.s.int&gclid=CNP96dPu6cMCFWTMtAod-C0A2A

 

 

(defun c:DOSSIER ( / value3 name Name1 Name2 Name3 Name4 ddiag activedocument
		  acadobject dcl_id name@ name# string Projectnaam Remember)

;;;--- Set Active document 
  (setq acadobject (vlax-get-acad-object))
  (setq activedocument (vla-get-activedocument acadobject))

;;;--- Make list Name
  (setq name '("DOSSIERNUMMER" "PROJECTNAAM" "AFK ELEMENT" "BETREFT1" "BETREFT2" "AANNEMER" "ADRESAANNEMER1" "ADRESAANNEMER2"
		"STRAATBOUWPLAATS" "POSTCODE" "BOUWPLAATS" "PROVINCIE" "BOUWHEER" "BOUWHEERADRES1" "BOUWHEERADRES2" "ARCHITECT"
		"ARCHITECTADRES1" "ARCHITECTADRES2" "BEK TEKENAAR" "WAP TEKENAAR" "VELLINGK. BALK.KOLOM" "VELLINGK. WAND" 
		"KWALITEIT BETON" "GEBRUIKSDOMEIN" "OMGEVINGSKLASSE" "CONSISTENTIEKLASSE" "KORRELAFM NOM." "MIN. DEKKING"
         ));SETQ
  (setq ddiag 4)

  (while (> ddiag 2)
  
;;;--- Load the dcl file from disk into memory
  (if(not(setq dcl_id (load_dialog "DOSSIER.dcl")))
    (progn
      (alert "The DCL file could not be loaded!")
      (exit)
    );PROGN
    
;;;--- Else, the dcl file was loaded into memory
    (progn
      
;;;--- Load the definition inside the DCL file
      (if (not(new_dialog "DOSSIER" dcl_id))
        (progn
        (alert "The DOSSIER definition could not be loaded!")
          (exit)
        );PROGN
    
;;;--- Else, the definition was loaded
        (progn

;;;--- Put mode tile gray for excel data
	  (Foreach x name
	    (setq name@ (strcat x "@"))
	    (mode_tile name@ 1)
	    );FOREACH
	  
	  (mode_tile "OPMERKING" 1)
	  (mode_tile "SelectAll" 1)
	  (mode_tile "SelectNone" 0)
	  
	  (foreach x name
	    
	    (setq name# (strcat x "#"))
	    (action_tile name# "(CheckSelect) (ToggleRow1)  (ToggleRow2)  (ToggleRow3)  (ToggleRow4)  (ToggleRow5)
	     (ToggleRow6)  (ToggleRow7)  (ToggleRow8)  (ToggleRow9) (ToggleRow10) (ToggleRow11)")
	    )

	  (action_tile "Selectrow1" "(GetRow1) (CheckSelect)")
	  (action_tile "Selectrow2" "(GetRow2) (CheckSelect)")
	  (action_tile "Selectrow3" "(GetRow3) (CheckSelect)")
	  (action_tile "Selectrow4" "(GetRow4) (CheckSelect)")
	  (action_tile "Selectrow5" "(GetRow5) (CheckSelect)")
	  (action_tile "Selectrow6" "(GetRow6) (CheckSelect)")
	  (action_tile "Selectrow7" "(GetRow7) (CheckSelect)")
	  (action_tile "Selectrow8" "(GetRow8) (CheckSelect)")
	  (action_tile "Selectrow9" "(GetRow9) (CheckSelect)")
	  (action_tile "Selectrow10" "(GetRow10) (CheckSelect)")
	  (action_tile "Selectrow11" "(GetRow11) (CheckSelect)")



	  (if Remember
	    (progn
	      (foreach x Remember
		(setq Name1 (car x)) ;;name customprop
		(if
		  (= (cadr x) "None")
		  (setq Name2 "")
		  (setq Name2 (cadr x))
		  );; custompropvalue
		(if
		  (= (caddr x) "None")
		  (setq Name3 "")
		  (setq Name3 (caddr x)) ;;excel value
		  )
		(setq Name4 (strcat Name1 "@"));; name excel value
		(set_tile Name1 Name2)
		(Set_tile Name4 Name3)
		);foreach
	      );progn
	    );If

;;;--- If an action event occurs, do this function
	  (mode_tile "Projectnumber" 2)
	  
          (action_tile
	    "loadcustom"
	    "(CUSTOMPROPERTIES) (customClick)")
	  (action_tile "Deletecustom" "(Deletecustom) (CheckSelect)")
          (action_tile "Createcustom" "(Createcustom) (CheckSelect)")
	  (action_tile "loadexcel" "(GetExcel) (excelclick) (CheckSelect)")
          (action_tile "Getexcel" "(Setcustom) (Changeclick) (CheckSelect)")
	  (action_tile "Putexcel" "(ExtractCAD)")
	  (action_tile "Editexcel" "(PutExOn)")
          (action_tile "cancel" "(done_dialog 0)")
	  (action_tile "SelectAll" "(Toggleselectall)(CheckSelect)" )
	  (action_tile "SelectNone" "(ToggleselectNone)(CheckSelect)" )
	  (action_tile "SelectNone" "(ToggleselectNone)(CheckSelect)" )
	  (action_tile "hide" "(Hide)" )
	  (action_tile "GETDRAWING" "(teken)" )
	  
	  (action_tile "GETEXCELPLANLIJST" "(GETEXCELPLANLIJST)" )
	  (action_tile "PUTEXCELPLANLIJST" "(Getprojectnumber) (PUTEXCELPLANLIJST) (done_dialog 1)" )

	 
;;;--- Display the dialog box
          (setq ddiag(start_dialog))

	  (if (= ddiag 4)
	    (progn
	      (progn
		(setq string (getstring "\nPress anything if ready"))
		);progn
	      );Progn
	   );IF
	  	  
;;;--- Unload the dialog box
          (unload_dialog dcl_id)

;;;--- If the user pressed the Cancel button
          (if(= ddiag 0)
            (princ "\n DOSSIER cancelled!")
          );IF


	  (if(= ddiag 1)
            (Sillycommandforscript)
          );IF

	  
	  );PROGN
	);IF
      );PROGN
    );IF
    );while

;;;---Regenerate CAD
  (vla-regen activedocument 1)
  
;;;---Clean 5 times unused objects
  (repeat 5 (gc))
  (princ)
  );DEFUN

 

 

(defun PUTEXCELPLANLIJST ( / dossval DWGprefix Externfolder script Drawings Drawing Files 
			  sf dossfile TextDoss)


  (setq DWGprefix (getvar "dwgprefix"))
  (setq Externfolder (strcat DWGprefix "\#Library-Do Not Edit#"))
  (setq TextDoss (strcat Externfolder "\\BinDossVal.txt"))

  (setq dossfile (open TextDoss  "R"))
  (setq  dossval (read-line dossfile))
  (close dossfile)


  (if (= GetValList1 nil)
    (setq Drawings(GetFiles))
    (setq Drawings (GetValList1))
    )
 
  (setq ThisDwg (strcat DWGprefix (getvar "dwgname")))
  (setq script (strcat Externfolder "\\BinOpenDWGforTitleblock.SCR"))



  (foreach x Drawings
    (setq Drawing (strcat DWGprefix x ".dwg"))

   
    (if (not(= Drawing ThisDwg))
      (setq Files (cons Drawing Files))
      )
    )
 

  (if (> (length Files) 0)
	(progn
	  (setq sf (open script "w"))

	  (write-line "Filedia" sf)
	  (write-line "0" sf)
	  (foreach dwg Files
	    (write-line "_.open" sf)
	    (write-line (strcat "\""dwg "\"") sf)
	    (write-line "(load \"Dossier\")" sf)
	    (write-line "DISTRIBUTEEXCELPLANNLIJST" sf)
	    (write-line "_.qsave" sf)
	    (write-line "_.close" sf)
	    )
	  (write-line "Filedia" sf)
	  (write-line "1" sf)
	  (close sf)
	  
	  
	  )
	
	)
;;;
;;;        )
;;;    )
  (princ)
  ); Defun

 

(defun c:Sillycommandforscript (/ DWGprefix Externfolder script)

  (setq DWGprefix (getvar "dwgprefix"))
  (setq Externfolder (strcat DWGprefix "\#Library-Do Not Edit#"))
  (setq script (strcat Externfolder "\\BinOpenDWGforTitleblock.SCR"))
 
  (command-s "script" script )

  )

 

Message 10 of 17

hmsilva
Mentor
Mentor

Subje,

are you in AC2015?

My AutoCAD (at this old laptop) is very old, and does not recognize the 'command-s' function...

Glad you got it sorted!

 

EDIT: Subje, at home, I'm connected to my office network via VPN on my laptop and box, but this old laptop is only to test new codes and new software add-ons...

 

Henrique

EESignature

0 Likes
Message 11 of 17

Anonymous
Not applicable

Henrique 

 

yes i am. Got them both on my personal and workPC, and i once stumbled on that command-s thingie, but didn't had any problem later with that change.

well getting the VPN network at home is also one of my to-do's. 

 

Gonna let this open. Could be i will return. i had to admit, getting attributes from blocks was one of the thoughest function i wrote, excel was easier.

Thanks for support!

0 Likes
Message 12 of 17

hmsilva
Mentor
Mentor

You're welcome, Subje!
Keep on coding!

Henrique

EESignature

0 Likes
Message 13 of 17

Anonymous
Not applicable

Ok i stumbled on something else,

 

If i do the script i open every file, works fine, but after the script he returns another Dwg (one that was also open before excuting the lisp) . 

So to explain it better, i have 2 drawings open. Drawing1 / Drawing2. when i excute the lisp in drawing1 he overruns every drawing in the script and then goes to Drawing 2 instead of drawing1. is there a way, in lisp language to change file in MSI. 

 

thanks. 

0 Likes
Message 14 of 17

hmsilva
Mentor
Mentor

Hi Subje,

 

fully untested...

 What occurs to me is:

 

in your code add this lines

(setq *currdoc* (vla-get-activedocument (vlax-get-acad-object)))
(vl-propagate '*currdoc*)

 and at the script end, add

(vla-activate *currdoc*)

 

Hope this helps,
Henrique

 

 

EESignature

0 Likes
Message 15 of 17

Anonymous
Not applicable

hi Henrique,

 

tested it. In the lisp he doesn't go futher then the last close (see script below)

 

if i put the lines in commandbar, it works so i think it has problaby to do with my script, maybe that last close doesn't active that Dwg?

 

EDIT: I noticed he just doesn't do anything after that last "close" command. 

 

 

Filedia
0
_.open
"R:\5100-5199\5107 Vaneenoo Noirefontaine Hall 2\ACAD\5107_Noir Fontaine Hall 2_Wapening.dwg"
(load "Dossier")
(DISTRIBUTEEXCELPLANNLIJST)
_.qsave
_.close
_.open
"R:\5100-5199\5107 Vaneenoo Noirefontaine Hall 2\ACAD\5107_Noir Fontaine Hall 2_Kolommen3.dwg"
(load "Dossier")
(DISTRIBUTEEXCELPLANNLIJST)
_.qsave
_.close
_.open
"R:\5100-5199\5107 Vaneenoo Noirefontaine Hall 2\ACAD\5107_Noir Fontaine Hall 2_Fundering.dwg"
(load "Dossier")
(DISTRIBUTEEXCELPLANNLIJST)
_.qsave
_.close
(vla-activate *currdoc*)
(AlertEditedblocks)

 

0 Likes
Message 16 of 17

hmsilva
Mentor
Mentor

Hi Subje,

 

I did send you a code with another approach!

Did send it via PM, because it's a code that can only work in AC2015, and I dont have AC2015 to test it, so is untested...

 

Henrique

EESignature

0 Likes
Message 17 of 17

Anonymous
Not applicable
Accepted solution

we found a solution, for the followers:

 

i close the dwg and reopen it with scrip so i have directly acces again and i can keep coding. Lisp can't continue if you activate another drawing, you get a report "lisp can't reenter" or such as that su you will eventually need script or other codingprogram. 

 

(defun PUTEXCELPLANLIJST ( / dossval DWGprefix Externfolder script Drawings Drawing Files 
			  sf dossfile TextDoss ThisDwg Countblock CoFile Activefile AcFile
			  Lokaalfolder)

  (setq DWGprefix (getvar "dwgprefix"))
  (setq Externfolder (strcat DWGprefix "\#Library-Do Not Edit#"))
  (setq Countblock (strcat Externfolder "\\BinCountBlock.txt"))
  (setq ThisDwg (strcat DWGprefix (getvar "dwgname")))

  (setq dossval (get_tile "Projectnumber"))
    
  (setq Countblock (strcat Externfolder "\\BinCountBlock.txt"))
  (setq CoFile (open Countblock  "W"))
  (close CoFile)

  (setq Drawings (GetValList1))
  (setq script (strcat Externfolder "\\BinOpenDWGforTitleblock.SCR"))
  (foreach x Drawings
    (setq Drawing (strcat DWGprefix x ".dwg"))
    (if (not(= Drawing ThisDwg))
      (setq Files (cons Drawing Files))
      )
    )
;;; from here the script start writing...
  (if (> (length Files) 0)
	(progn
	  (setq sf (open script "w"))
	  (write-line "Filedia" sf)
	  (write-line "0" sf)
	  (write-line "_.qsave" sf)
	  (write-line "close" sf)
	  (foreach dwg Files
	    (write-line "_.open" sf)
	    (write-line (strcat "\""dwg "\"") sf)
	    (write-line "(load \"Dossier\")" sf)
	    (write-line "(DISTRIBUTEEXCELPLANNLIJST)" sf)
	    (write-line "_.qsave" sf)
	    (write-line "close" sf)
	    )

	  (write-line "_.open" sf)
	  (write-line (strcat "\"" ThisDwg "\"") sf)
	  (write-line "Filedia" sf)
	  (write-line "1" sf)
	  (foreach x Drawings
	    (setq Drawing (strcat DWGprefix x ".dwg"))
	    (if (= Drawing ThisDwg)
	    (write-line "(DISTRIBUTEEXCELPLANNLIJST)" sf)
	      )
	    )
	  (write-line "(AlertEditedblocks)" sf)
	  (write-line "_.qsave" sf)
	  (write-line "_.regen" sf)
	  (close sf)
	  )
	)
  (princ)
  )