TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Brick_top on December 07, 2011, 04:23:03 AM

Title: How to set a document active?
Post by: Brick_top on December 07, 2011, 04:23:03 AM
Hi... thread title says it.

I would like to set a document active in this case a dwg using autolisp.

thanks!
Title: Re: How to set a document active?
Post by: Tharwat on December 07, 2011, 05:32:52 AM
Code: [Select]
(if (setq filename (vla-open (vla-get-Documents (vlax-get-acad-object))
                         "put here the complete path of your file"
                         :vlax-false
               )
    )
  (vla-activate filename)
)
Title: Re: How to set a document active?
Post by: Brick_top on December 07, 2011, 05:48:32 AM
thanks a lot!  :-)
Title: Re: How to set a document active?
Post by: Tharwat on December 07, 2011, 05:50:01 AM
thanks a lot!  :-)

You're welcome .  :-)
Title: Re: How to set a document active?
Post by: Brick_top on December 07, 2011, 06:00:00 AM
I forgot to mention the file I want to set active is already opened.

do you know how to do it in this case?
Title: Re: How to set a document active?
Post by: Kerry on December 07, 2011, 06:34:39 AM

If the drawing is named "Drawing111.dwg"


Code - Auto/Visual Lisp: [Select]


but keep in mind that your lisp is loaded into the previous document ( the one prior to the change)
Title: Re: How to set a document active?
Post by: Brick_top on December 07, 2011, 06:42:26 AM
Thanks a lot Kerry,

I know the lisp file will not be loaded into the new active drawing.

Thanks again.
Title: Re: How to set a document active?
Post by: Lee Mac on December 07, 2011, 06:46:36 AM
I would advise against having the VLIDE open when evaluating vla-activate  - the two don't mix too well.  :wink:
Title: Re: How to set a document active?
Post by: Brick_top on December 07, 2011, 06:52:44 AM
oh..

I'll try to remember that!

thanks...

Anyway I could close VLIDE before I use vla-activate?
Title: Re: How to set a document active?
Post by: irneb on December 07, 2011, 10:52:22 AM
That might help, though your bigger problem is what you do after the activate. It's near impossible to get lisp to continue working on another drawing from the one you started the routine. Or at least extremely difficult with strange work-arounds.
Title: Re: How to set a document active?
Post by: Brick_top on December 07, 2011, 11:02:04 AM
Hi irneb

I'm not trying to do that now, I just want to set an already opened drawing active without any problems. I intend to run another routine on that drawing.