kalai Posted July 19, 2011 Posted July 19, 2011 Hi (command "open" "c:\\a.dwg" "") doesnot work? help me. Quote
kalai Posted July 19, 2011 Author Posted July 19, 2011 Now i could open the drawing but how to make it active and work on it. Quote
Tharwat Posted July 19, 2011 Posted July 19, 2011 Like this .. (vla-activate (vla-open......... Quote
BlackBox Posted July 19, 2011 Posted July 19, 2011 FWIW - Just be aware that when you change document namespaces (using vla-activate...) your code will stop working, unless your code is run from a separate namespace (outside of the ActiveDocument prior to vla-activate...). HTH Quote
Tharwat Posted July 19, 2011 Posted July 19, 2011 FWIW - Just be aware that when you change document namespaces (using vla-activate...) your code will stop working, unless your code is run from a separate namespace (outside of the ActiveDocument prior to vla-activate...). HTH Yes , I used to load my routines too much directly from the Vlide and when I run the vla-open with vla-activate , I can not do anything except shutting down the Vlide and released that the document it self keep on loading for a while . Thanks. Quote
kalai Posted July 19, 2011 Author Posted July 19, 2011 this is the code i could get (defun c:old (/ cd vgad vgao vgd) (vl-load-com) (setq vgao (vlax-get-acad-object)) (setq vgad (vla-get-activedocument vgao)) (setq vgd (vla-get-documents vgao)) (setq cd "D:/YBI/Drawing/Layout/global/Master/YBI.dwg") (if (= 0 (getvar "SDI")) (vla-activate (vla-open vgd cd)) ; if sdi = 0 (vla-sendcommand vgad (strcat "(command \"_open\")\n" cd "\n")); if sdi = 1 ) ; if (princ) ) But i doesnot end. now the drawing is opened.but i am not able to work. i am getting fatal errror could anyone help Quote
Tharwat Posted July 19, 2011 Posted July 19, 2011 Try it this way . (defun c:old nil (vl-load-com) (if (= 0 (getvar "SDI")) (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) "D:\\YBI\\Drawing\\Layout\\global\\Master\\YBI.dwg" :vlax-false ) ) ) (princ) ) Tharwat Quote
Lee Mac Posted July 19, 2011 Posted July 19, 2011 This is what I use to open pretty much everything. Quote
Ahankhah Posted May 26, 2012 Posted May 26, 2012 Lee, I have a question about your code, so I copied it here: ;;------------------------=={ Open }==------------------------;; ;; ;; ;; Uses the 'Open' method of the Shell Object to open the ;; ;; specified file or folder. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; target - file, folder or ShellSpecialFolderConstants enum ;; ;;------------------------------------------------------------;; ;; Returns: T if successful, else nil ;; ;;------------------------------------------------------------;; (defun LM:Open ( target / shell result ) (if (and (or (eq 'INT (type target)) (setq target (findfile target)) ) (setq shell (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application")) ) (progn (setq result (vl-catch-all-apply 'vlax-invoke (list shell 'open target))) (vlax-release-object shell) (not (vl-catch-all-error-p result)) ) ) ) (vl-load-com) As I understand, the active drawing after the line including: (setq result (vl-catch-all-apply 'vlax-invoke (list shell 'open target))) will be the opened file, so the following lines: (vlax-release-object shell) (not (vl-catch-all-error-p result)) can't be done, for forgetting shell and result values. ..., or I am wrong? Quote
BlackBox Posted May 26, 2012 Posted May 26, 2012 Ahankhah, As I am new to this method of open a drawing also (I typically use the Document's Collection + Activate Method), if I understand correctly, Lee is employing the Shell.Application Object to open the drawing outside of AutoCAD (think double click in Windows Explorer), which allows for the code to release the Object within the Document that called. This code itself is quite brilliant in that way. I am still attempting to determine if I am able to properly use this methodology, as we have 3+ version years (and vertical/non-vertical flavors of each) installed at any given time. HTH Quote
Ahankhah Posted May 27, 2012 Posted May 27, 2012 RenderMan, Thank you very much for your suggestion. I is very useful. Quote
BlackBox Posted May 27, 2012 Posted May 27, 2012 RenderMan,Thank you very much for your suggestion. I is very useful. Happy to help. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.