keeping the modeless box working in other dwgs

Started by andrew, December 09, 2009, 10:28:28 AM

Previous topic - Next topic

Kerry


Andrew, what is the name of YOUR drawing. Did you use it in the statement ?

be sure to run (vl-load-com) before the statement to ensure that the ActiveX server is loaded.
Perfection is not optional.
My other home is TheSwamp

andrew

Quote from: Kerry Brown on December 21, 2009, 12:57:02 PM

Andrew, what is the name of YOUR drawing. Did you use it in the statement ?

be sure to run (vl-load-com) before the statement to ensure that the ActiveX server is loaded.


(defun c:od-toolbox_Form2_BlockView1_OnDblClicked (/)
(if (Setq opfile (dcl_DWGList_GetFileName od-toolbox_Form1_DwgList1))
(vlax-invoke-method (vla-get-Documents (vlax-get-acad-object)) "Open" opfile)
        )
(vla-Activate (vla-item (vla-get-documents (vlax-get-acad-object)) opfile))
(princ)
)

Kerry

is opFile a fully qualified pathed fileName ??

This is WHY I asked about YOUR dwg Name.

The (vla-item on the Documents collection expects a document name NOT a qualified File Name.

ie
expects "abd.dwg"
not "C:/Folder/SubFolder/abc.dwg"


ALSO :
Note that once the document is Active the lisp you called from will no longer be in scope
( as it is run in the precious document namespace, not the newly active document)


Try these samples (2 different methods ) :


Code (autolisp) Select


(vl-load-com)
;;;------------------

(setq QualifiedFileName "J:/123-100")

;; assume Multi Document Interface

(setq oDoc (vlax-invoke-method (vla-get-Documents (vlax-get-acad-object)) "Open" QualifiedFileName))
(vla-Activate  oDoc)


;;;------------------

(setq QualifiedFileName "J:/123-101")

;; assume Multi Document Interface

(vlax-invoke-method (vla-get-Documents (vlax-get-acad-object)) "Open" QualifiedFileName)

(setq DocumentName (strcat (vl-filename-base QualifiedFileName) ".dwg"))

(vla-Activate (vla-item (vla-get-documents (vlax-get-acad-object)) DocumentName))

;; -> (setvar "clayer" "ST50") ;This will NOT run in newly active document

;;;------------------


Perfection is not optional.
My other home is TheSwamp

BazzaCAD

I used to use a lot of the VLA-* function to try to open\close & set active DWG's, but it never worked very good.
Because like Kerry pointed out, once the DWG is opened, nothing after that can keep running.
Then I converted some of these functions to VBA, & you know how that went, no more VBA.
So Fred was kind enough to post some .NET code for me that's working great now.
http://www.opendcl.com/forum/index.php?topic=956.0
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

andrew

Quote from: BazzaCAD on December 22, 2009, 04:53:33 PM
I used to use a lot of the VLA-* function to try to open\close & set active DWG's, but it never worked very good.
Because like Kerry pointed out, once the DWG is opened, nothing after that can keep running.
Then I converted some of these functions to VBA, & you know how that went, no more VBA.
So Fred was kind enough to post some .NET code for me that's working great now.
http://www.opendcl.com/forum/index.php?topic=956.0

uggg one code language to learn at a time lol

thanks for the tip ill keep this in mind after i get more comfortable with odcl coding

happy holidays