Marko,
Just curious here, why is your code different than MP's? To me, it looks like you are repeating the dvb code twice.
Still getting the darn Syntax error.
Hopefully I am missing something here. For me to get the "ZALL" routine to work.
1. VBaid
2. Create new module
3. Paste the mode in the module
4. Debug / Compile ACADProject
5. Save out module to Zooms.dvb
6. In AutoCAD, Run "zall"
Works.
When I close out of AutoCAD completely and open a new session. I run the "zall" routine and can not get it to work without doing the above steps.
I hope I copied it fine...
It gives me this error :
Command: ZALL
Initializing VBA System...
Syntax Error
Here is what I've used :
(defun _LoadedDVBs ( / i pjx rst )
(repeat
(setq i
(vlax-get
(setq pjx
(vlax-get
(vlax-get (vlax-get-acad-object) 'vbe)
'VBProjects
)
)
'count
)
)
(setq
rst (cons (vlax-get (vlax-invoke pjx 'item i) 'filename) rst)
i (1- i)
)
)
(reverse rst)
)
(defun C:ZAll ( / fn )
(if
(null
(vl-some
(function (lambda (s) (eq "ZOOMS" (strcase (vl-filename-base s)))))
(_LoadedDVBs)
)
)
(progn
(setq fn (open (strcat (getvar 'tempprefix) "zooms.dvb") "w"))
(write-line "Sub ZoomExtentsInAllLayouts( )" fn)
(write-line "" fn)
(write-line " Dim layout As AcadLayout, _" fn)
(write-line " restore As AcadLayout" fn)
(write-line " " fn)
(write-line " With ThisDrawing" fn)
(write-line " " fn)
(write-line " Set restore = .ActiveLayout" fn)
(write-line " " fn)
(write-line " For Each layout In .Layouts" fn)
(write-line " .ActiveLayout = layout" fn)
(write-line " If 1 = CInt(.GetVariable(\"TILEMODE\")) Or _" fn)
(write-line " 1 = CInt(.GetVariable(\"CVPORT\")) Then" fn)
(write-line " Application.ZoomExtents" fn)
(write-line " Else" fn)
(write-line " .MSpace = False" fn)
(write-line " Application.ZoomExtents" fn)
(write-line " .MSpace = True" fn)
(write-line " End If" fn)
(write-line " Next layout" fn)
(write-line " " fn)
(write-line " If restore.Name <> .ActiveLayout.Name Then .ActiveLayout = restore" fn)
(write-line " " fn)
(write-line " End With" fn)
(write-line "" fn)
(write-line "End Sub" fn)
(write-line "" fn)
(write-line "Sub ZoomExtentsInAllDocs( )" fn)
(write-line "" fn)
(write-line " Dim doc As AcadDocument, _" fn)
(write-line " restore As AcadDocument" fn)
(write-line " " fn)
(write-line " Set restore = ThisDrawing" fn)
(write-line " " fn)
(write-line " For Each doc In Documents" fn)
(write-line " doc.Activate" fn)
(write-line " Call ZoomExtentsInAllLayouts( )" fn)
(write-line " Next" fn)
(write-line " " fn)
(write-line " If restore.Name <> ThisDrawing.Name Then restore.Activate" fn)
(write-line "" fn)
(write-line "End Sub" fn)
(close fn)
(vl-catch-all-apply
'vla-loaddvb
;; mod to suit | replace with findfile algo | yada
(list (vlax-get-acad-object) (strcat (getvar 'tempprefix) "zooms.dvb"))
)
(if (findfile (strcat (getvar 'tempprefix) "zooms.dvb"))
(vl-file-delete (strcat (getvar 'tempprefix) "zooms.dvb"))
)
)
)
(vl-cmdf ".vbastmt" "ZoomExtentsInAllDocs")
(princ)
)
What is wrong, I can't see... Help, please...