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
)