Jump to content

Switch between OPENED drawings (vla-activate)


Recommended Posts

Posted

I need to switch to a specific OPENED drawing between 5.

 

I know the name and the path

It is already OPENED

 

I HAVE USED THE VLA-ACTIVATE function but it opens a copy from the file adding a colon and a number at the end and as many times as I run the function it opens a new increesing the number after the colon.

 

Is there a way to switch to a specific previous opened drawing in the current AutoCAD session and run a command there and come back to the file where it was invoked the function?

 

Thanks in advance

Posted

I use the keyboard buttons to step through drawings by pressing the tow buttons Ctrl + tab

Posted

Yup. I thought I was considering all possibilities. I knew it was possible to do that. Still that doesn't solve my problem. I am looking for a specific routine that does what I explained because I want to make things automatically.

 

Thanks anyhow

Posted

Add the complete name of your opened drawing as shown in the code .

 

(defun c:Test nil
 (vlax-for doc (vla-get-Documents (vlax-get-acad-object))
   (if (eq (vla-get-fullname doc) [color=red]<complete_path_of_opened_drawing>[/color] )
     (vla-put-windowstate doc acmax)
     (vla-put-windowstate doc acmin)
   )
 )
 (princ)
)
(vl-load-com)

Posted

Thanks a lot, pretty much what I was looking for

 

.-)

  • 1 year later...
Posted

Hi,

 

I've tried to use this code,

 

It seems to minimise both windows without opening up the drawing. Any idea why it would do this. I'm using \\ in the filename

Posted
Hi,

 

I've tried to use this code,

 

It seems to minimise both windows without opening up the drawing. Any idea why it would do this. I'm using \\ in the filename

 

 

What does the function findfile return if you try it on filename?

Posted

If I use that line in the cmdline i get

 

(findfile "S:\\USER\\TEST.dwg")
"S:\\USER\\TEST.dwg"

which is the same as what I am typing in.

 

Basically my code is

 

(defun c:SwitchDWG nil
 (vlax-for doc (vla-get-Documents (vlax-get-acad-object))
   (if (eq (vla-get-fullname doc) Default )
     (vla-put-windowstate doc acmax)
     (vla-put-windowstate doc acmin)
   )
 )
 (princ)
)
(vl-load-com)

 

Where default gets switched out to the filepath S:\\USER\\TEST.dwg through a replace text vba code I have in excel. I have confirmed that the path exists in the file at the time of loading as I stepped through the vba code as it executed and noted that the path is there as autocad loads it.

 

If it helps when i run the switchdwg list i get no errors or anything so it would seem something is working.

Posted

Try:

(defun SwitchDWG (drawing)
 (vlax-for doc (vla-get-Documents (vlax-get-acad-object))
   (if (eq (vla-get-fullname doc) drawing )
     (vla-put-windowstate doc acmax)
     (vla-put-windowstate doc acmin)
   )
 )
 (princ)
)
(vl-load-com)

and try

(SwitchDWG "S:\\USER\\TEST.dwg")

In a Ribbon Panel I have macros to open and activate a number of drawings and templates.

Example:

^C^C^P(vla-activate(vla-open (vla-get-documents (vlax-get-acad-object))(findfile "chroma.dwg") :vlax-false))

 

I added the SwitchWindows Ribbon Menu Button to my Quick Access Toolbar which makes switching between open drawings as easy as it gets.

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