PDA

View Full Version : Open Command, 2 drawings at once?



JasonSelf
2004-09-13, 09:12 PM
I was wondering if you could in lisp open two drawings at once. Basically at the end of my lisp I want it to open two drawings that it had created. Example. when you use the open dialog box in autocad and select two drawings to open at once.

If any of that made any sense I would appreciate the input.
Thanks,
Jason

RobertB
2004-09-13, 09:36 PM
Check out the Open method on the Documents collection in the ActiveX interface.

kennet.sjoberg
2004-09-13, 10:01 PM
Hi Jason !
...mmm good question, very interesting, and probably not possible in lisp.
The open and close command in later release than R14 is still a miserable for me...

Happy Computing !

kennet

RobertB
2004-09-13, 11:04 PM
It is possible.


(defun I:OpenFiles (fileList / docs)
(vl-load-com)
(setq docs (vla-Get-Documents (vlax-Get-Acad-Object)))
(foreach fileName fileList
(vla-Open docs fileName)))

;|
Sample assumes two drawings located in C:\Temp named Test and Test2
(I:OpenFiles '("C:\\Temp\\Test.dwg" "C:\\Temp\\Test2.dwg"))
|;

Note that you can use Visual LISP to activate one of the documents you just opened, but then your LISP hangs until you go back to the original document.

For full access to all open drawings you really need to use VBA.

JasonSelf
2004-09-14, 01:18 PM
LOL, what I have noticed is that most of the stuff that I wish I could acomplish with lisp and don't know how, it involves lisp interpreting ActiveX or VBA commands

Thanks,
Jason

JasonSelf
2004-09-14, 02:22 PM
Actually Rob, if you don't mind. How would I translate a drawing path I set as a variable in lisp over to the VBA/ActiveX side of things in this example?

RobertB
2004-09-14, 11:17 PM
Assume: (setq MyPath "C:\\Temp\\")

(I:OpenFiles
(mapcar
(function
(lambda (aStr)
(strcat MyPath aStr)))
'("Test.dwg" "Test2.dwg")))

JasonSelf
2004-09-15, 02:35 PM
Thanks, thats a good bunch of information....I have been reading up on mapcar, quote, function, and lambda functions since you posted that and have learned a bunch of new stuff.

RobertB
2004-09-15, 05:31 PM
Happy to help!