Jump to content

Recommended Posts

Posted

Hi

(command "open" "c:\\a.dwg"  "")

doesnot work?

help me.

Posted

Now i could open the drawing but how to make it active and work on it.

Posted

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

Posted
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.

Posted

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

Posted

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

  • 10 months later...
Posted

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?

Posted

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

Posted

RenderMan,

Thank you very much for your suggestion. I is very useful.

Posted
RenderMan,

Thank you very much for your suggestion. I is very useful.

 

Happy to help. :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...