keeping the modeless box working in other dwgs

Started by andrew · 2009-12-09 18:28 UTC · 19 replies · SMF topic #1069

my project is a modeless box, i have a button that opens other dwgs.
is there another/better way to keep the box "working" or "loaded"  in other dwgs when they are opened via my project box, other then placing the lisp file call in my acaddoc.lsp
I think Kerry might be working on a tutorial on this topic.. (Kerry?)
In the meantime have a look at (vl-load-all) in the VLIDE help
Thanks

Ill keep a lookout for those tutorials

I'm working on it when I have time ... burning candles both ends at the moment ..

but, I'm nibling away at it.
Shall I do it? I'd use (vl-load-all ...), too.

Fred

Fred,
If you have or can make time, it would be great if you do it. :)

I'm learning palettes as I go 'because I've not programmed then before, so your first hand experience will help.

It's a big topic .... and bigger if we start looking at Seperate-Namespace VLX options ( which should be seperate tutorial )

I had thought that several small demo/tutorials would be best .. but your thoughts may differ.

Thanks
Kerry



author=Kerry Brown link=topic=1069.msg5607#msg5607 date=1260436099 wrote:
If you have or can make time, it would be great if you do it. :)


Can you keep a secret with you? I'm going to invent the 48-hours-day. I'm so close, but I afraid that I cannot make it!  :D

Seriously, because of the fact that I already use this I can easily copy and document it next night. I think it should be a easy solution just for understandig. The way the functionality is needed in each product is so specific, I'd prefer a simple solution - just like I would understand it.

I'm going to convert many old forms and even newer OpenDCL forms into palettes cause it's a great technology.
The start of the tutorial will be a ready palette which already works in the current drawing. I believe it would be the start of every palette form: make it happen in the current drawing and then manage it for the others.

I'd be glad to give the part of namespacing to anybody else because I do not understand this (yet). So I have the chance to extend my knowledge, too.

I think, andrew will sleep fitfully next night awaiting the tutorial  ;)

Fred
author=Fred Tomke link=topic=1069.msg5609#msg5609 date=1260437160 wrote:


I think, andrew will sleep fitfully next night awaiting the tutorial  ;)

Fred


hehe

anything to help the beginner odcl programer learn :)
Hi, Kerry and andrew, it took me a while. Please have a look {2} and - please - improve my English!

Fred
author=Fred Tomke link=topic=1069.msg5638#msg5638 date=1260540195 wrote:
Hi, Kerry and andrew, it took me a while. Please have a look {2} and - please - improve my English!

Fred


Amazing job Fred. Now I have to spend the next 2 hours reading this. :)

Thanks Fred .. I have it bookmarked for reading too. :)
Thanks Fred,
I also have it bookmarked for reading.

Fred,
nice work on the write up for the modeless form aside from not being able to get the nodocstate function not working everything else works nicely

would you happen to have a trick to get a dwg that was opened via odcl to be the active document?
author=andrew link=topic=1069.msg5803#msg5803 date=1261165912 wrote:
would you happen to have a trick to get a dwg that was opened via odcl to be the active document?


Try something like this...
(vla-Activate (vla-item (vla-get-documents (vlax-get-acad-object)) "MyDWG.dwg"))
Thanks Bazza for the reply

but i get an error with this
; error: Automation Error. Description was not provided.

i dont know what that means
do you know?


have a good holiday

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.
author=Kerry Brown link=topic=1069.msg5812#msg5812 date=1261429022 wrote:

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)
)
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 ) :




(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

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


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.
{2}
author=BazzaCAD link=topic=1069.msg5824#msg5824 date=1261529613 wrote:
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.
{2}


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