Run Lisp on Multiple Drawings

Run Lisp on Multiple Drawings

Travis.Biddle
Advocate Advocate
3,243 Views
25 Replies
Message 1 of 26

Run Lisp on Multiple Drawings

Travis.Biddle
Advocate
Advocate
I want to run a certain lisp (importmb.lsp) on multiple drawings (hundreds of drawings at times). I have downloaded ScriptPro as this seemed to be what I needed, but I can not figure out how to get it to run the lisp through script. Based on research, this is what my script file is, which I assume is the problem. (load "C:\\support\\importmb.lsp") importmb quit y I load the script into ScriptPro, select which drawings I want to run it on, it opens AutoCAD, but then nothing happens. Any help will be greatly appreciated.
0 Likes
3,244 Views
25 Replies
Replies (25)
Message 2 of 26

maratovich
Advisor
Advisor

 

Maybe this is useful to you - AutoRunLisp 

 

 

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 3 of 26

pendean
Community Legend
Community Legend
Any reason why your LISP would not be autoloaded in all sessions of AutoCAD, thus avoiding a manual load?

SCRIPT would look something like this:

importmb
qsave
close
0 Likes
Message 4 of 26

pbejse
Mentor
Mentor

@Travis.Biddle wrote:
 (load "C:\\support\\importmb.lsp") importmb quit y I load the script into ScriptPro, 

 

Post that puppy in here so we can have a look, perhaps use a different approach and forego the use of scriptpro altogether.

 

 

 

0 Likes
Message 5 of 26

Travis.Biddle
Advocate
Advocate

It is loaded.  I just added the path as a test to see if thats why it wasnt working.

0 Likes
Message 6 of 26

Travis.Biddle
Advocate
Advocate

When I run the script with Scriptpro, it opens cad but does not open any drawings.

 

0 Likes
Message 7 of 26

Travis.Biddle
Advocate
Advocate

Here is the lisp that I want to run on multiple drawings.  Im sure there are much better ways to execute what im doing here, but I'm self taught and it works great LOL

 

(defun C:importMB ()
(command "zoom" "extents")
(removeOG) ;runs program to erase MB drawing if one was previously inserted
(COMMAND "PURGE" "B" "" "N") ;purge blocks
(COMMAND "PURGE" "B" "" "N") ;purge blocks
(nilvar) ;calls subroutine to nil variables
(setq 1stosmode (getvar "osmode")) ;gets current object snaps
(setvar "osmode" 0) ;sets no object snaps
(getpanelnumber) ;calls subroutine to get panel number
(command "_tilemode" "1") ;switches to model space
(insertMB) ;calls subroutine to insert MB drawing
(getmbinfo) ;calls subroutine to get MB info
(copyscalebox) ;calls subroutine to copy scalebox to TM panel
(changedims-importmb)
(command "_tilemode" "0") ;switches to paper space
(changembinfo) ;calls subroutine to change MB titleblock info
(scaleviewports) ;calls subroutine to scaleviewports
;(changedims-importmb) ;calls subroutine to revise dimension styles based on scale factor
(command "qsave")
(command "zoom" "extents")
;(command "close")

)

(defun nilvar ()
(setq pnlno nil ss1 nil titleblock nil attributes nil projno nil) ;sets variables to nil
(setq bracetype nil braceto nil noreqd nil l nil x nil braceload nil) ;
(setq deadmanload nil panelnumber nil bracetype2 nil braceto2 nil) ;
(setq noreqd2 nil l2 nil x2 nil braceload2 nil deadmanload2 nil) ;
(setq major nil lowerminor nil upperminor nil msbl nil msbr nil) ;
(setq msbl nil msbr nil lmsbl nil lmsbr nil rmsbl nil rmsbr nil) ;
(setq sd nil cgx nil cgy nil cly nil p nil area nil volume nil) ;
(setq weight nil checkedby nil drawnby nil date nil title nil) ;
(setq jobnumber nil sheet nil scalefactor nil) ;
)

(defun getpanelnumber ()
(setq ss1 (ssget "x" '((0 . "insert") (66 . 1) (2 . "MB TB Info"))))
(IF
(and ss1
(setq titleblock (vlax-ename->vla-object (ssname ss1 0)))
(setq attributes (vlax-invoke titleblock 'getattributes))
)
(foreach att attributes
(if (= "PNUM" (vla-get-tagstring att))
(setq pnlno (vla-get-textstring att))
)
)
)
(setq mbpnlstring (strcat pnlno "MB"))
;(setq mbpnlstring (read mbpnlstring))
(setq ss1 nil)
)

(defun insertMB ()
(setq insertpt (list 0 -2400)) ;sets insert point of MB panel @ 0,-200'
(setq insertptKWO (list 0 0)) ;sets insert point of MB panel @ 0,-200'
(command "-insert" mbpnlstring insertptKWO "" "" "") ;inserts MB drawing
(command "-insert" mbpnlstring insertpt "" "" "") ;inserts MB drawing
(command "explode" "l" "") ;explodes MB drawing
(command "zoom" "e") ;zoom e
)

(defun getmbinfo ()
(setq ss1 (ssget "x" '((0 . "INSERT") (66 . 1) (2 . "MB Info Insert Block"))))
(IF
(and ss1
(setq titleblock (vlax-ename->vla-object (ssname ss1 0)))
(setq attributes (vlax-invoke titleblock 'getattributes))
)
(foreach att attributes
(if (= "BRACE_TYPE" (vla-get-tagstring att))
(setq bracetype (vla-get-textstring att))
)
(if (= "BRACE_TO" (vla-get-tagstring att))
(setq braceto (vla-get-textstring att))
)
(if (= "NO_REQD" (vla-get-tagstring att))
(setq noreqd (vla-get-textstring att))
)
(if (= "L" (vla-get-tagstring att))
(setq L (vla-get-textstring att))
)
(if (= "X" (vla-get-tagstring att))
(setq X (vla-get-textstring att))
)
(if (= "BRACE_LOAD" (vla-get-tagstring att))
(setq braceload (vla-get-textstring att))
)
(if (= "DEADMAN_LOAD" (vla-get-tagstring att))
(setq deadmanload (vla-get-textstring att))
)
;(if (= "PANEL_NUMBER" (vla-get-tagstring att))
; (setq panelnumber (vla-get-textstring att))
😉
(if (= "BRACE_TYPE2" (vla-get-tagstring att))
(setq bracetype2 (vla-get-textstring att))
)
(if (= "BRACE_TO2" (vla-get-tagstring att))
(setq braceto2 (vla-get-textstring att))
)
(if (= "NO_REQD2" (vla-get-tagstring att))
(setq noreqd2 (vla-get-textstring att))
)
(if (= "L2" (vla-get-tagstring att))
(setq L2 (vla-get-textstring att))
)
(if (= "X2" (vla-get-tagstring att))
(setq X2 (vla-get-textstring att))
)
(if (= "BRACE_LOAD2" (vla-get-tagstring att))
(setq braceload2 (vla-get-textstring att))
)
(if (= "DEADMAN_LOAD2" (vla-get-tagstring att))
(setq deadmanload2 (vla-get-textstring att))
)
(if (= "MAJOR" (vla-get-tagstring att))
(setq major (vla-get-textstring att))
)
(if (= "LOWER_MINOR" (vla-get-tagstring att))
(setq lowerminor (vla-get-textstring att))
)
(if (= "UPPER_MINOR" (vla-get-tagstring att))
(setq upperminor (vla-get-textstring att))
)
(if (= "MAJOR_SPREAD_BAR_LEFT" (vla-get-tagstring att))
(setq msbl (vla-get-textstring att))
)
(if (= "MAJOR_SPREAD_BAR_RIGHT" (vla-get-tagstring att))
(setq msbr (vla-get-textstring att))
)
(if (= "LEFT_MINOR_SPREADER_BAR_LEFT" (vla-get-tagstring att))
(setq lmsbl (vla-get-textstring att))
)
(if (= "LEFT_MINOR_SPREADER_BAR_RIGHT" (vla-get-tagstring att))
(setq lmsbr (vla-get-textstring att))
)
(if (= "RIGHT_MINOR_SPREADER_BAR_LEFT" (vla-get-tagstring att))
(setq rmsbl (vla-get-textstring att))
)
(if (= "RIGHT_MINOR_SPREADER_BAR_RIGHT" (vla-get-tagstring att))
(setq rmsbr (vla-get-textstring att))
)
(if (= "SPECIAL_DETAILS" (vla-get-tagstring att))
(setq sd (vla-get-textstring att))
)
(if (= "CGX" (vla-get-tagstring att))
(setq cgx (vla-get-textstring att))
)
(if (= "CGY" (vla-get-tagstring att))
(setq cgy (vla-get-textstring att))
)
(if (= "CLY" (vla-get-tagstring att))
(setq cly (vla-get-textstring att))
)
(if (= "P" (vla-get-tagstring att))
(setq p (vla-get-textstring att))
)
(if (= "AREA" (vla-get-tagstring att))
(setq area (vla-get-textstring att))
)
(if (= "VOLUME" (vla-get-tagstring att))
(setq volume (vla-get-textstring att))
)
(if (= "WEIGHT" (vla-get-tagstring att))
(setq weight (vla-get-textstring att))
)
(if (= "CHECKED_BY" (vla-get-tagstring att))
(setq checkedby (vla-get-textstring att))
)
(if (= "DRAWN_BY" (vla-get-tagstring att))
(setq drawnby (vla-get-textstring att))
)
(if (= "DATE" (vla-get-tagstring att))
(setq date (vla-get-textstring att))
)
(if (= "TITLE" (vla-get-tagstring att))
(setq title (vla-get-textstring att))
)
(if (= "JOB_NUMBER" (vla-get-tagstring att))
(setq jobnumber (vla-get-textstring att))
)
(if (= "SHEET" (vla-get-tagstring att))
(setq sheet (vla-get-textstring att))
)
(if (= "SCALEFACTOR" (vla-get-tagstring att))
(setq scalefactor (vla-get-textstring att))
)
)
)
(setq ss1 nil)
)

(defun copyscalebox ()
(command "layer" "t" "TMscalebox" "m" "TMscalebox" "p" "n" "TMscalebox" "c" 180 "" "")
(setq ss1 (ssget "x" '((0 . "LWPOLYLINE") (8 . "MBscalebox"))))
(command "copytolayer" ss1 "" "TMscalebox" insertpt (list 0 0))
)

(defun changembinfo ()
(setq Attpt1 (list -1 -1))
(setq attpt2 (list 18 12))
(command "._pspace")
(command "-attedit" "y" "MB TB Info" "Brace_Type" "*" "w" AttPT1 AttPT2 "V" "R" bracetype "n")
(command "-attedit" "y" "MB TB Info" "Brace_To" "*" "w" AttPT1 AttPT2 "V" "R" braceto "n")
(command "-attedit" "y" "MB TB Info" "No_reqd" "*" "w" AttPT1 AttPT2 "V" "R" noreqd "n")
(command "-attedit" "y" "MB TB Info" "l" "*" "w" AttPT1 AttPT2 "V" "R" l "n")
(command "-attedit" "y" "MB TB Info" "x" "*" "w" AttPT1 AttPT2 "V" "R" x "n")
(command "-attedit" "y" "MB TB Info" "Brace_load" "*" "w" AttPT1 AttPT2 "V" "R" braceload "n")
(command "-attedit" "y" "MB TB Info" "Dead_Load" "*" "w" AttPT1 AttPT2 "V" "R" deadmanload "n")
(command "-attedit" "y" "MB TB Info" "Brace_Type2" "*" "w" AttPT1 AttPT2 "V" "R" bracetype2 "n")
(command "-attedit" "y" "MB TB Info" "Brace_To2" "*" "w" AttPT1 AttPT2 "V" "R" BraceTO2 "n")
(command "-attedit" "y" "MB TB Info" "No_reqd2" "*" "w" AttPT1 AttPT2 "V" "R" NoReqd2 "n")
(command "-attedit" "y" "MB TB Info" "l2" "*" "w" AttPT1 AttPT2 "V" "R" l2 "n")
(command "-attedit" "y" "MB TB Info" "x2" "*" "w" AttPT1 AttPT2 "V" "R" x2 "n")
(command "-attedit" "y" "MB TB Info" "Brace_load2" "*" "w" AttPT1 AttPT2 "V" "R" BraceLoad2 "n")
(command "-attedit" "y" "MB TB Info" "Dead_Load2" "*" "w" AttPT1 AttPT2 "V" "R" DeadmanLoad2 "n")
(command "-attedit" "y" "MB TB Info" "MSL_MAJOR" "*" "w" AttPT1 AttPT2 "V" "R" MAJOR "n")
(command "-attedit" "y" "MB TB Info" "MSL_LMIN" "*" "w" AttPT1 AttPT2 "V" "R" LOWERMINOR "n")
(command "-attedit" "y" "MB TB Info" "MSL_UMIN" "*" "w" AttPT1 AttPT2 "V" "R" UPPERMINOR "n")
(command "-attedit" "y" "MB TB Info" "MSB_L" "*" "w" AttPT1 AttPT2 "V" "R" msbl "n")
(command "-attedit" "y" "MB TB Info" "MSB_R" "*" "w" AttPT1 AttPT2 "V" "R" msbr "n")
(command "-attedit" "y" "MB TB Info" "LMSB_L" "*" "w" AttPT1 AttPT2 "V" "R" lmsbl "n")
(command "-attedit" "y" "MB TB Info" "LMSB_R" "*" "w" AttPT1 AttPT2 "V" "R" lmsbr "n")
(command "-attedit" "y" "MB TB Info" "RMSB_L" "*" "w" AttPT1 AttPT2 "V" "R" rmsbl "n")
(command "-attedit" "y" "MB TB Info" "RMSB_R" "*" "w" AttPT1 AttPT2 "V" "R" rmsbr "n")
(command "-attedit" "y" "MB TB Info" "spec_details" "*" "w" AttPT1 AttPT2 "V" "R" sd "n")
(command "-attedit" "y" "MB TB Info" "cgx" "*" "w" AttPT1 AttPT2 "V" "R" CGX "n")
(command "-attedit" "y" "MB TB Info" "cgy" "*" "w" AttPT1 AttPT2 "V" "R" CGY "n")
(command "-attedit" "y" "MB TB Info" "cly" "*" "w" AttPT1 AttPT2 "V" "R" CLY "n")
(command "-attedit" "y" "MB TB Info" "p" "*" "w" AttPT1 AttPT2 "V" "R" P "n")
(command "-attedit" "y" "MB TB Info" "area" "*" "w" AttPT1 AttPT2 "V" "R" Area "n")
(command "-attedit" "y" "MB TB Info" "volume" "*" "w" AttPT1 AttPT2 "V" "R" Volume "n")
(command "-attedit" "y" "MB TB Info" "weight" "*" "w" AttPT1 AttPT2 "V" "R" Weight "n")
;(command "-attedit" "y" "MB TB Info" "MB_CHECK" "*" "w" AttPT1 AttPT2 "V" "R" checkedby "n")
(command "-attedit" "y" "MB TB Info" "MB_DRAWN" "*" "w" AttPT1 AttPT2 "V" "R" DrawnBy "n")
)

(defun scaleviewports ()
(command "_.mspace")
(command "cvport" 2)
;(command "zoom" "e")
(setq ss1 (ssget "x" '((0 . "LWPOLYLINE") (8 . "tmscalebox"))))
(command "zoom" "o" ss1 "")
(command "cvport" 3)
(setq ss2 (ssget "x" '((0 . "LWPOLYLINE") (8 . "mbscalebox"))))
(command "zoom" "o" ss2 "")
(command "_.pspace")
(command "layer" "t" "*" "f" "0" "")
)

(defun changedims-importmb ()
(setq sf (atof scalefactor)) ;set scale factor variable to real number from string value
(setq dth (* sf 0.098958)) ;set dimension text height
(setq asz (* sf 0.09375)) ;set arrow size
(setq offs (* sf 0.0625)) ;set offset distance from panel
(setq exten (* sf 0.104)) ;set extension of dim line
(command "style" "standard2" "" dth "1" "0" "n" "n" "n") ;changes text style height
(setvar "dimasz" asz) ;changes dimension arrow size
(setvar "dimexo" offs) ;changes dimension offset distance
(setvar "dimexe" exten) ;changes dimension extension distance
(setq ssdim (ssget "x" '((0 . "DIMENSION") (8 . "DIM")))) ;makes selection set of dimensions on dim layer
(command "dimstyle" "a" ssdim "") ;sets all changes to dimensions in selection set
;(command "style" "standard2" "" "5" "1" "0" "n" "n") ;sets text style height to 5" so future drawn sheets have normal text height
;(setvar "dimasz" 4.5) ;sets arrow size back to 6" for future sheets
)

(defun removeOG ()
(setq ss97 (ssget "x" '((0 . "insert") (2 . "CTLOGOPRELIMWINDOW")))) ;selection set for ct logo prelim window/watermark
(command "erase" ss97 "") ;erase selection set above
(command "layer" "t" "*" "") ; layer thaw all
(command "_tilemode" "1") ;switches to model space
(setq ss99 (ssget "x" '((0 . "LWPOLYLINE") (8 . "TMscalebox")))) ;selection set for Thermomass DWG scale box
(command "erase" ss99 "") ;erase selection set above
(setq ss98 (ssget "x" '((0 . "LWPOLYLINE,text,arc,mtext,line,point,insert,circle,spline") (8 . "MBscalebox,mbdwg,no plot,newmb0")))) ;selection set for Thermomass DWG scale box
(command "erase" ss98 "") ;eerase selection set above
(COMMAND "PURGE" "B" "" "N") ;purge blocks
(COMMAND "PURGE" "B" "" "N") ;purge blocks
)

 

 

 

 

0 Likes
Message 8 of 26

pendean
Community Legend
Community Legend
ScriptPro may be the problem: try another tool to confirm where the flaw resides, there are free-to-try solutions posted at the Autodesk App Store or Post #2 above https://apps.autodesk.com/ACD/en/List/Search?isAppSearch=True&searchboxstore=ACD&facet=&collection=&...
0 Likes
Message 9 of 26

pbejse
Mentor
Mentor

@Travis.Biddle wrote:

Here is the lisp that I want to run on multiple drawings.  Im sure there are much better ways to execute what im doing here, but I'm self taught and it works great LOL

 

(defun C:importMB ()..

)

 


That is one long code you got there @Travis.Biddle, you should've attached the lsp file instead 🙂

Let us have  a quick look at your code then we'll get back to you.

 

 

0 Likes
Message 10 of 26

Travis.Biddle
Advocate
Advocate

Thats a short one for me LOL.  Like I said, im self taught and sure I do things the long way most of the time.  

0 Likes
Message 11 of 26

SeeMSixty7
Advisor
Advisor

Script files will stop if they run into canceled command and or nil'd out expressions that are returned to the script file.

 

Here is some tips on creating a script file manually as well as updated yoru code to try and catch most of the errors causing yoru script to fail.

 

Good luck.

;;Sample of how your script file should look.
;;Easy enough to do a whole directory using 
;;DOS command
;;DIR *.DWG /s /b >myscript.scr
;; that DOSC command will create a file with all the files and paths
;;in the directory it is run from.
;;then you can simply edity it to look like something below
open "c:/temp/test1" (load "importmb") importmb ZOOM E close y
open "c:/temp/test2" (load "importmb") importmb ZOOM E close y
open "c:/temp/test3" (load "importmb") importmb ZOOM E close y

;;I updated your code to have some very crude error trapping.
;;A script file will stop if it has a canceled or nil'd command
;;this code kinda of make sure it doesn't ruin into that.
;;I also added some crude princ statements with numbers to let you
;;know how far your routine got before bombing out.

(defun C:importMB ()
	(princ ".")
(command "zoom" "extents")
(princ ".1")
(removeOG) ;runs program to erase MB drawing if one was previously inserted
(princ ".2")
(COMMAND "PURGE" "B" "" "N") ;purge blocks
(princ ".3")
(COMMAND "PURGE" "B" "" "N") ;purge blocks
(princ ".4")
(nilvar) ;calls subroutine to nil variables
(princ ".5")
(setq 1stosmode (getvar "osmode")) ;gets current object snaps
(princ ".6")
(setvar "osmode" 0) ;sets no object snaps
(princ ".7")
(getpanelnumber) ;calls subroutine to get panel number
(princ ".8")
(command "_tilemode" "1") ;switches to model space
(princ ".9")
(insertMB) ;calls subroutine to insert MB drawing
(princ ".0")
(getmbinfo);calls subroutine to get MB info
(princ ".11")
(copyscalebox) ;calls subroutine to copy scalebox to TM panel
(princ ".12")
(changedims-importmb)
(princ ".13")
(command "_tilemode" "0") ;switches to paper space
(princ ".14")
(changembinfo) ;calls subroutine to change MB titleblock info
(princ ".15")
(scaleviewports) ;calls subroutine to scaleviewports
(princ ".16")
;(changedims-importmb) ;calls subroutine to revise dimension styles based on scale factor
(princ ".17")
(command "qsave")
(princ ".18")
(command "zoom" "extents")
(princ ".19")
;(command "close")

)

(defun nilvar ()
(setq pnlno nil ss1 nil titleblock nil attributes nil projno nil) ;sets variables to nil
(setq bracetype nil braceto nil noreqd nil l nil x nil braceload nil) ;
(setq deadmanload nil panelnumber nil bracetype2 nil braceto2 nil) ;
(setq noreqd2 nil l2 nil x2 nil braceload2 nil deadmanload2 nil) ;
(setq major nil lowerminor nil upperminor nil msbl nil msbr nil) ;
(setq msbl nil msbr nil lmsbl nil lmsbr nil rmsbl nil rmsbr nil) ;
(setq sd nil cgx nil cgy nil cly nil p nil area nil volume nil) ;
(setq weight nil checkedby nil drawnby nil date nil title nil) ;
(setq jobnumber nil sheet nil scalefactor nil) ;
)

(defun getpanelnumber ()
	(setq ss1 (ssget "x" '((0 . "insert") (66 . 1) (2 . "MB TB Info"))))
	(IF
		(and ss1
		(setq titleblock (vlax-ename->vla-object (ssname ss1 0)))
		(setq attributes (vlax-invoke titleblock 'getattributes))
		)
		(foreach att attributes
			(if (= "PNUM" (vla-get-tagstring att))
				(setq pnlno (vla-get-textstring att))
			)
		)
	)
	(if pnlno
		(setq mbpnlstring (strcat pnlno "MB"))
	)
	;(setq mbpnlstring (read mbpnlstring))
(setq ss1 nil)
)

(defun insertMB ()
	(if (not mbpnlstring)
		(setq mbpnlstring "")
	)
	(setq insertpt (list 0 -2400)) ;sets insert point of MB panel @ 0,-200'
	(setq insertptKWO (list 0 0)) ;sets insert point of MB panel @ 0,-200'
	(if (or (tblsearch "BLOCK" mbpnlstring nil)
			(findfile (strcat mbpnlstring ".dwg"))
		)
		(progn
			(command "-insert" mbpnlstring insertptKWO "" "" "") ;inserts MB drawing
			(command "-insert" mbpnlstring insertpt "" "" "") ;inserts MB drawing
			(command "explode" "l" "") ;explodes MB drawing
		)
	)
	(command "zoom" "e") ;zoom e
)

(defun getmbinfo ()
(setq ss1 (ssget "x" '((0 . "INSERT") (66 . 1) (2 . "MB Info Insert Block"))))
(IF
(and ss1
(setq titleblock (vlax-ename->vla-object (ssname ss1 0)))
(setq attributes (vlax-invoke titleblock 'getattributes))
)
(foreach att attributes
(if (= "BRACE_TYPE" (vla-get-tagstring att))
(setq bracetype (vla-get-textstring att))
)
(if (= "BRACE_TO" (vla-get-tagstring att))
(setq braceto (vla-get-textstring att))
)
(if (= "NO_REQD" (vla-get-tagstring att))
(setq noreqd (vla-get-textstring att))
)
(if (= "L" (vla-get-tagstring att))
(setq L (vla-get-textstring att))
)
(if (= "X" (vla-get-tagstring att))
(setq X (vla-get-textstring att))
)
(if (= "BRACE_LOAD" (vla-get-tagstring att))
(setq braceload (vla-get-textstring att))
)
(if (= "DEADMAN_LOAD" (vla-get-tagstring att))
(setq deadmanload (vla-get-textstring att))
)
;(if (= "PANEL_NUMBER" (vla-get-tagstring att))
; (setq panelnumber (vla-get-textstring att))
:winking_face:
(if (= "BRACE_TYPE2" (vla-get-tagstring att))
(setq bracetype2 (vla-get-textstring att))
)
(if (= "BRACE_TO2" (vla-get-tagstring att))
(setq braceto2 (vla-get-textstring att))
)
(if (= "NO_REQD2" (vla-get-tagstring att))
(setq noreqd2 (vla-get-textstring att))
)
(if (= "L2" (vla-get-tagstring att))
(setq L2 (vla-get-textstring att))
)
(if (= "X2" (vla-get-tagstring att))
(setq X2 (vla-get-textstring att))
)
(if (= "BRACE_LOAD2" (vla-get-tagstring att))
(setq braceload2 (vla-get-textstring att))
)
(if (= "DEADMAN_LOAD2" (vla-get-tagstring att))
(setq deadmanload2 (vla-get-textstring att))
)
(if (= "MAJOR" (vla-get-tagstring att))
(setq major (vla-get-textstring att))
)
(if (= "LOWER_MINOR" (vla-get-tagstring att))
(setq lowerminor (vla-get-textstring att))
)
(if (= "UPPER_MINOR" (vla-get-tagstring att))
(setq upperminor (vla-get-textstring att))
)
(if (= "MAJOR_SPREAD_BAR_LEFT" (vla-get-tagstring att))
(setq msbl (vla-get-textstring att))
)
(if (= "MAJOR_SPREAD_BAR_RIGHT" (vla-get-tagstring att))
(setq msbr (vla-get-textstring att))
)
(if (= "LEFT_MINOR_SPREADER_BAR_LEFT" (vla-get-tagstring att))
(setq lmsbl (vla-get-textstring att))
)
(if (= "LEFT_MINOR_SPREADER_BAR_RIGHT" (vla-get-tagstring att))
(setq lmsbr (vla-get-textstring att))
)
(if (= "RIGHT_MINOR_SPREADER_BAR_LEFT" (vla-get-tagstring att))
(setq rmsbl (vla-get-textstring att))
)
(if (= "RIGHT_MINOR_SPREADER_BAR_RIGHT" (vla-get-tagstring att))
(setq rmsbr (vla-get-textstring att))
)
(if (= "SPECIAL_DETAILS" (vla-get-tagstring att))
(setq sd (vla-get-textstring att))
)
(if (= "CGX" (vla-get-tagstring att))
(setq cgx (vla-get-textstring att))
)
(if (= "CGY" (vla-get-tagstring att))
(setq cgy (vla-get-textstring att))
)
(if (= "CLY" (vla-get-tagstring att))
(setq cly (vla-get-textstring att))
)
(if (= "P" (vla-get-tagstring att))
(setq p (vla-get-textstring att))
)
(if (= "AREA" (vla-get-tagstring att))
(setq area (vla-get-textstring att))
)
(if (= "VOLUME" (vla-get-tagstring att))
(setq volume (vla-get-textstring att))
)
(if (= "WEIGHT" (vla-get-tagstring att))
(setq weight (vla-get-textstring att))
)
(if (= "CHECKED_BY" (vla-get-tagstring att))
(setq checkedby (vla-get-textstring att))
)
(if (= "DRAWN_BY" (vla-get-tagstring att))
(setq drawnby (vla-get-textstring att))
)
(if (= "DATE" (vla-get-tagstring att))
(setq date (vla-get-textstring att))
)
(if (= "TITLE" (vla-get-tagstring att))
(setq title (vla-get-textstring att))
)
(if (= "JOB_NUMBER" (vla-get-tagstring att))
(setq jobnumber (vla-get-textstring att))
)
(if (= "SHEET" (vla-get-tagstring att))
(setq sheet (vla-get-textstring att))
)
(if (= "SCALEFACTOR" (vla-get-tagstring att))
(setq scalefactor (vla-get-textstring att))
)
)
)
(setq ss1 nil)
)

(defun copyscalebox ()
(command "layer" "t" "TMscalebox" "m" "TMscalebox" "p" "n" "TMscalebox" "c" 180 "" "")
(setq ss1 (ssget "x" '((0 . "LWPOLYLINE") (8 . "MBscalebox"))))
(if ss1
	(command "copytolayer" ss1 "" "TMscalebox" insertpt (list 0 0))
)
)

(defun changembinfo ()
(setq Attpt1 (list -1 -1))
(setq attpt2 (list 18 12))
(command "._pspace")
	(if (ssget "X" '((0 . "insert") (1 . "MB TB Info")))
		(progn
			(command "-attedit" "y" "MB TB Info" "Brace_Type" "*" "w" AttPT1 AttPT2 "V" "R" bracetype "n")
			(command "-attedit" "y" "MB TB Info" "Brace_To" "*" "w" AttPT1 AttPT2 "V" "R" braceto "n")
			(command "-attedit" "y" "MB TB Info" "No_reqd" "*" "w" AttPT1 AttPT2 "V" "R" noreqd "n")
			(command "-attedit" "y" "MB TB Info" "l" "*" "w" AttPT1 AttPT2 "V" "R" l "n")
			(command "-attedit" "y" "MB TB Info" "x" "*" "w" AttPT1 AttPT2 "V" "R" x "n")
			(command "-attedit" "y" "MB TB Info" "Brace_load" "*" "w" AttPT1 AttPT2 "V" "R" braceload "n")
			(command "-attedit" "y" "MB TB Info" "Dead_Load" "*" "w" AttPT1 AttPT2 "V" "R" deadmanload "n")
			(command "-attedit" "y" "MB TB Info" "Brace_Type2" "*" "w" AttPT1 AttPT2 "V" "R" bracetype2 "n")
			(command "-attedit" "y" "MB TB Info" "Brace_To2" "*" "w" AttPT1 AttPT2 "V" "R" BraceTO2 "n")
			(command "-attedit" "y" "MB TB Info" "No_reqd2" "*" "w" AttPT1 AttPT2 "V" "R" NoReqd2 "n")
			(command "-attedit" "y" "MB TB Info" "l2" "*" "w" AttPT1 AttPT2 "V" "R" l2 "n")
			(command "-attedit" "y" "MB TB Info" "x2" "*" "w" AttPT1 AttPT2 "V" "R" x2 "n")
			(command "-attedit" "y" "MB TB Info" "Brace_load2" "*" "w" AttPT1 AttPT2 "V" "R" BraceLoad2 "n")
			(command "-attedit" "y" "MB TB Info" "Dead_Load2" "*" "w" AttPT1 AttPT2 "V" "R" DeadmanLoad2 "n")
			(command "-attedit" "y" "MB TB Info" "MSL_MAJOR" "*" "w" AttPT1 AttPT2 "V" "R" MAJOR "n")
			(command "-attedit" "y" "MB TB Info" "MSL_LMIN" "*" "w" AttPT1 AttPT2 "V" "R" LOWERMINOR "n")
			(command "-attedit" "y" "MB TB Info" "MSL_UMIN" "*" "w" AttPT1 AttPT2 "V" "R" UPPERMINOR "n")
			(command "-attedit" "y" "MB TB Info" "MSB_L" "*" "w" AttPT1 AttPT2 "V" "R" msbl "n")
			(command "-attedit" "y" "MB TB Info" "MSB_R" "*" "w" AttPT1 AttPT2 "V" "R" msbr "n")
			(command "-attedit" "y" "MB TB Info" "LMSB_L" "*" "w" AttPT1 AttPT2 "V" "R" lmsbl "n")
			(command "-attedit" "y" "MB TB Info" "LMSB_R" "*" "w" AttPT1 AttPT2 "V" "R" lmsbr "n")
			(command "-attedit" "y" "MB TB Info" "RMSB_L" "*" "w" AttPT1 AttPT2 "V" "R" rmsbl "n")
			(command "-attedit" "y" "MB TB Info" "RMSB_R" "*" "w" AttPT1 AttPT2 "V" "R" rmsbr "n")
			(command "-attedit" "y" "MB TB Info" "spec_details" "*" "w" AttPT1 AttPT2 "V" "R" sd "n")
			(command "-attedit" "y" "MB TB Info" "cgx" "*" "w" AttPT1 AttPT2 "V" "R" CGX "n")
			(command "-attedit" "y" "MB TB Info" "cgy" "*" "w" AttPT1 AttPT2 "V" "R" CGY "n")
			(command "-attedit" "y" "MB TB Info" "cly" "*" "w" AttPT1 AttPT2 "V" "R" CLY "n")
			(command "-attedit" "y" "MB TB Info" "p" "*" "w" AttPT1 AttPT2 "V" "R" P "n")
			(command "-attedit" "y" "MB TB Info" "area" "*" "w" AttPT1 AttPT2 "V" "R" Area "n")
			(command "-attedit" "y" "MB TB Info" "volume" "*" "w" AttPT1 AttPT2 "V" "R" Volume "n")
			(command "-attedit" "y" "MB TB Info" "weight" "*" "w" AttPT1 AttPT2 "V" "R" Weight "n")
			;(command "-attedit" "y" "MB TB Info" "MB_CHECK" "*" "w" AttPT1 AttPT2 "V" "R" checkedby "n")
			(command "-attedit" "y" "MB TB Info" "MB_DRAWN" "*" "w" AttPT1 AttPT2 "V" "R" DrawnBy "n")
		)
	)
)

(defun scaleviewports ()
(command "_.mspace")
(command "cvport" 2)
;(command "zoom" "e")
(setq ss1 (ssget "x" '((0 . "LWPOLYLINE") (8 . "tmscalebox"))))
(if ss1
	(progn
		(command "zoom" "o" ss1 "")
		(command "cvport" 3)
	)
)
(setq ss2 (ssget "x" '((0 . "LWPOLYLINE") (8 . "mbscalebox"))))
(if ss2
	(progn
		(command "zoom" "o" ss2 "")
		(command "_.pspace")
		(command "layer" "t" "*" "f" "0" "")
	)
)
)

(defun changedims-importmb ()
	(if (not scalefactor)
		(setq scalefactor "1.0")
	)
	(setq sf (atof scalefactor)) ;set scale factor variable to real number from string value
	(setq dth (* sf 0.098958)) ;set dimension text height
	(setq asz (* sf 0.09375)) ;set arrow size
	(setq offs (* sf 0.0625)) ;set offset distance from panel
	(setq exten (* sf 0.104)) ;set extension of dim line
	(command "style" "standard2" "" dth "1" "0" "n" "n" "n") ;changes text style height
	(setvar "dimasz" asz) ;changes dimension arrow size
	(setvar "dimexo" offs) ;changes dimension offset distance
	(setvar "dimexe" exten) ;changes dimension extension distance
	(setq ssdim (ssget "x" '((0 . "DIMENSION") (8 . "DIM")))) ;makes selection set of dimensions on dim layer
	(if ssdim
		(command "dimstyle" "a" ssdim "") ;sets all changes to dimensions in selection set
	)
	;(command "style" "standard2" "" "5" "1" "0" "n" "n") ;sets text style height to 5" so future drawn sheets have normal text height
	;(setvar "dimasz" 4.5) ;sets arrow size back to 6" for future sheets
)

(defun removeOG ()
(setq ss97 (ssget "x" '((0 . "insert") (2 . "CTLOGOPRELIMWINDOW")))) ;selection set for ct logo prelim window/watermark
(if ss97
	(command "erase" ss97 "") ;erase selection set above
)
(command "layer" "t" "*" "") ; layer thaw all
(command "_tilemode" "1") ;switches to model space
(setq ss99 (ssget "x" '((0 . "LWPOLYLINE") (8 . "TMscalebox")))) ;selection set for Thermomass DWG scale box
(if ss99
	(command "erase" ss99 "") ;erase selection set above
)
(setq ss98 (ssget "x" '((0 . "LWPOLYLINE,text,arc,mtext,line,point,insert,circle,spline") (8 . "MBscalebox,mbdwg,no plot,newmb0")))) ;selection set for Thermomass DWG scale box
(if ss98
	(command "erase" ss98 "") ;eerase selection set above
)
(COMMAND "PURGE" "B" "" "N") ;purge blocks
(COMMAND "PURGE" "B" "" "N") ;purge blocks
)

 

 

0 Likes
Message 12 of 26

Sea-Haven
Mentor
Mentor

I have been making scripts for years using the DOS method. Once you make the text file open it in Word, so you have only file names but word supports "end of line" ^p as a replaceable character so you can work backwards and forwards using ^p

 

replace ^p with ^p Open  will add open to the start of every line note space.

replace ^p with (load "importmb") importmb ZOOM E close y^p will add to end of every line

 

Ok do not save rather copy and paste to notepad this strips all the Word hidden characters from the file.

 

Hope this makes sense.

 

If you want a better way maybe look at Aeccoreconsole way faster as it does not open the dwg rather just runs on the database.

 

0 Likes
Message 13 of 26

Travis.Biddle
Advocate
Advocate

Also, after running the code command line shows this "Command: .19".19""  is this meaning that there is an error?  

0 Likes
Message 14 of 26

SeeMSixty7
Advisor
Advisor

I've grown to love Text Editors that support Column Editing. Awesome feature!

 

Then you just highlight the area start typing and it puts it in that column on every line.

 

 

0 Likes
Message 15 of 26

SeeMSixty7
Advisor
Advisor

If you see 19, that means it completed the routine without error. If you look at the code it will have the numbers in there. If you see the number it means you got to that step in the code. 19 is the last thing in your routine.

 

Good luck

0 Likes
Message 16 of 26

Travis.Biddle
Advocate
Advocate

so lets say I dont even want it to close the file, I removed the "close" section of the script, but it only opens the first panel  and then thats it, it doesnt move on to the next line of the script.  Here is the script I am using..

 

open "C:\Users\travbidd01\Box\AX Projects\S008995 Berkeley Electric Coop-Project Sparky\Travis Test\OLP1" importmb
open "C:\Users\travbidd01\Box\AX Projects\S008995 Berkeley Electric Coop-Project Sparky\Travis Test\OLP2" importmb
open "C:\Users\travbidd01\Box\AX Projects\S008995 Berkeley Electric Coop-Project Sparky\Travis Test\OLP3" importmb
open "C:\Users\travbidd01\Box\AX Projects\S008995 Berkeley Electric Coop-Project Sparky\Travis Test\OLP4" importmb

 

Everything works fine, if I could just get it to move to the next panel

0 Likes
Message 17 of 26

SeeMSixty7
Advisor
Advisor

Upload that drawing here and I'll take a look at it with your routine.

 

0 Likes
Message 18 of 26

Sea-Haven
Mentor
Mentor

Test this should open 4 dwgs if not use double backslash \\ sometimes spaces in directory names cause problems.

open "C:\Users\travbidd01\Box\AX Projects\S008995 Berkeley Electric Coop-Project Sparky\Travis Test\OLP1"
open "C:\Users\travbidd01\Box\AX Projects\S008995 Berkeley Electric Coop-Project Sparky\Travis Test\OLP2"
open "C:\Users\travbidd01\Box\AX Projects\S008995 Berkeley Electric Coop-Project Sparky\Travis Test\OLP3"
open "C:\Users\travbidd01\Box\AX Projects\S008995 Berkeley Electric Coop-Project Sparky\Travis Test\OLP4"

 

0 Likes
Message 19 of 26

chris_lee_3
Enthusiast
Enthusiast

The work around that I use to achieve a similar goal is to load the lisp into the startup briefcase. When the dwgs are opened the lisp automatically executes on each dwg. Others suggest using the publish command as the way to batch open the dwgs. It’s not as elegant as other solutions but it works for me. Also, Lee Mac has a script writing lisp that may be of help. http://www.lee-mac.com/scriptwriter.html

0 Likes
Message 20 of 26

Travis.Biddle
Advocate
Advocate

That may work.  Can I use a close command at the end of the lisp to get the drawings to close?  Also, I have tried the lee-mac, but it isnt closing the drawings.  It will run on the first drawing and then just stops, never going to the next drawing.  Any thooughts?

0 Likes