Since you are looking for a specific Tab Name, might as well create one file with drawing names that layouts matches the Target Tab name. Use ONE file name throughout the script , use "a" instead of "w"
like so: [Filename is Layoutlist.txt]
d:\dwgpath\Onedrawing.dwg
d:\dwgpath\Anotherdrawing.dwg
d:\otherdwgpath\Someotherdrawing.dwg
sample code
Code:
(defun
LayoutFind (name / fn fp)
(vl-load-com)
(if (and name
(not (member (strcase name) (mapcar 'strcase (layoutlist))))
)
(progn
(setq
fn (strcat (getenv "temp") "\\" "layoutlist.txt")
fp (open fn "a")
)
(princ (strcat "\n" (getvar 'dwgprefix)(getvar 'Dwgname)) fp)
(close fp)
)
)
)
USAGE:
_.open "C:\Folderpath\sample1.dwg" (layoutfind "TargetTab") _.save _close
then throw this line at the very end of the script
Code:
(startapp "notepad" (strcat (getenv "temp") "\\" "layoutlist.txt"))
If you still want to use your original approach
Code:
(setq fn (strcat (getenv "temp") "\\" (getvar 'Dwgname))
fp (open fn "w")
)