PDA

View Full Version : Problem in working in multiple document environment


rajat126
2004-06-21, 11:58 AM
Hi,
I am an ActiveX learner and I have a little problem.

** Assuming: More than one document is opened.
If "drawing1" is the ActiveDocument, then I want to Activate "drawing2" as ActiveDocument and send some commands to newly activated (drawing2) document.But my program does not work correctly.It will be very helpful if you rectify this program with proper explanation.
Thanks,
Rajat
Kolkata
India

Here is my program:

; ** More than one document must exists.
(defun xx (/ app documents dc docs doc mspace)
(vl-load-com)
(setq app (vlax-get-acad-object))
(setq documents (vla-get-Documents app))
(vlax-for dd documents (setq docs (cons dd docs)))
(setq doc (vla-get-activedocument app)) ; Get current ActiveDocument.

(if(equal doc (nth 0 docs))(setq dc (nth 1 docs))(setq dc (nth 0 docs))) ; Find another document which is not ActiveDocument.
(vla-put-activedocument app dc) ; Specify document "dc" as ActiveDocument ;

(setq doc (vla-get-activedocument app)) ; Get current ActiveDocument.
(setq mspace (vla-get-ModelSpace doc)) ; Get Current ActiveDocument's ModelSpace.

(vla-addcircle mspace (vlax-3d-point '(3.0 3.0 0.0)) 10) ; Add circle in the Active ModelSpace.
(vla-ZoomExtents app) ; Zoom in the current viewport.
(princ)
)

MarkTheSwampThomas
2004-06-21, 06:13 PM
You can only run Vlisp from one activedocument. You can however modify the others, just don't try to make them active.

whdjr
2004-06-22, 03:10 PM
Rajat,

You can access the other documents for manipulation through the document object. ActiveX doesn't allow you to make another drawing active, but it does allow you to manipulate the document. This should for you.