(defun GetMyDocumentsDir()
(vlax-invoke-method
(vlax-get-property
(vlax-create-object "wscript.shell")
'SpecialFolders) 'Item "MyDocuments")
)
;;Call:(GetMyDocumentsDir)
;;(BF:mkslid sldname 400 300)
;;; (SetScreenSize 400 300)
(defun SetScreenSize (Width height / doc oldsize doc w1 h1 dw dh)
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq oldsize (getvar "SCREENSIZE"))
(setq W1 (vla-get-width doc))
(setq H1 (vla-get-Height doc))
(setq dw (- w1 (car oldsize)))
(setq dh (- h1 (cadr oldsize)))
(vla-put-width doc (+ dw width))
(vla-put-height doc (+ dh height))
)
(defun c:test()
(SetScreenSize 400 300)
(command "zoom" "e")
(princ)
)
It could be that the window is still updating before running zoom extents. I.e. the extents is calculated on the previous sized window, and the new size only occurs after the zoom does.
You need to remember that you're inside Windows. A change to a GUI item's properties is handled as an event call. Simply because you sent the event doesn't mean it's going to happen immediately. If you resized the window in C#/VB/C++ you'd usually need to force the event to complete using something like Update / Refresh before you can rely on the resize to have completed.
Since you're doing this through ActiveX you could try to invoke the application's Update method: http://entercad.ru/acadauto.en/index.html?page=idh_update.htm
The link is about VB ? I can't understand.The link is pointing to the old VBA-ActiveX help documentation (which isn't available in ACad anymore).
The link is about VB ? I can't understand.The link is pointing to the old VBA-ActiveX help documentation (which isn't available in ACad anymore).
All those vla/vlax functions are using the ActiveX objects - which are those in that link. You're already using some of those inside your SetScreenSize function - the Width and Height properties of the Document object.
The Application object is what you get from the vlax-get-acad-object. And then to invoke the Update method on it - one of 3 ways:Code - Auto/Visual Lisp: [Select]
(vl-load-com)
(defun GetMyDocumentsDir()
(vlax-invoke-method
(vlax-get-property
(vlax-create-object "wscript.shell")
'SpecialFolders) 'Item "MyDocuments")
)
;;Call:(GetMyDocumentsDir)
;;(BF:mkslid sldname 400 300)
;;; (SetScreenSize 400 300)
(defun SetScreenSize (Width height / doc oldsize doc w1 h1 dw dh)
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq oldsize (getvar "SCREENSIZE"))
(setq W1 (vla-get-width doc))
(setq H1 (vla-get-Height doc))
(setq dw (- w1 (car oldsize)))
(setq dh (- h1 (cadr oldsize)))
(vla-put-width doc (+ dw width))
(vla-put-height doc (+ dh height))
(vla-Update(vlax-get-acad-object))
(vla-zoomextents (vlax-get-acad-object))
)
(defun c:test()
(SetScreenSize 400 300)
(princ)
)
There is no way to solve ?Seems not. At least not the way you're thinking to do it. It doesn't seem as if the Update actually forces the resize to complete immediately. Unfortunately there's nothing else (I can think of) which is exposed through ActiveX so you can call it from Lisp.
This version works for me.
not sure if it will work in Ac2015.
(command "_.zoom" "_e" "._mslide" "testlid")
into , how to do? (vla-sendcommand doc "zoom e ")
(vla-sendcommand doc "mslide 11")
But I want addOh! So you're trying to make a slide at the relevant proportions. You're probably looking to make a block-library?Code: [Select](command "_.zoom" "_e" "._mslide" "testlid")
into , how to do?
I try to do it ,but I always fail.
Try something like thisCode - Auto/Visual Lisp: [Select]
Try something like this
emk2012,
A side note.
The recommended aspect ratio for Slide files is 3:2