Hi,
Keep in mind LISP execution only work in document context.
IOW, a LISP expression/function started in Drawing1 can not continue in another drawing.
For example, Drawing1 is the active document in which you execute:
(setq doc (vla-Open (vla-get-documents (vlax-get-acad-object)) "C:\\Temp\\Test.dwg"))
(vla-SendCommand doc "_circle 0,0 10 ")
It will open Test.dwg (if found) but it draws the circle in Drawing1.
That's to say you cannot use (command ...) or (vla-SendCommand ...) in another drawing,
But you can use other vla* functions to access to the newly opened document.
(setq doc (vla-Open (vla-get-documents (vlax-get-acad-object)) "C:\\Temp\\Test.dwg"))
(vla-AddCircle (vla-get-ModelSpace doc) (vlax-3d-point '(0. 0. 0.)) 10.)
This way, the circle will be drawn in Test.dwg.
So, if you can build a new function with the behavior of 'c:mycommand ' which accepts a document (vla-object) as argument and which only uses vla functions to edit the document (or its properties), you should be able to run it in a newly opened document.
You could even do better; open the drawing "in memory" only (that's to say not in the editor) with ObjectDBX, this runs much more faster.
Always with the same example:
(defun gc:GetAxDbDoc (filename / majVer progId axdbdoc)
(vl-load-com)
(setq progId
(if (< (setq majVer (substr (getvar 'acadver) 1 2)) "16")
"ObjectDBX.AxDbDocument"
(strcat "ObjectDBX.AxDbDocument." majVer)
)
)
(if (setq axdbdoc (vlax-create-object progId))
(if (vl-catch-all-apply
'vla-open
(list axdbdoc filename)
)
(not (vlax-release-object axdbdoc))
axdbdoc
)
)
)
(if (setq doc (gc:GetAxDbDoc "C:\\Temp\\Test.dwg"))
(progn
(vla-AddCircle (vla-get-ModelSpace doc) (vlax-3d-point '(0. 0. 0.)) 10.)
(vla-SaveAs doc "C:\\Temp\\Test.dwg")
(vlax-release-object doc)
)
)
This way the circle is drawn in Test.dwg even the file heven't been open in the AutoCAD editor.