Are you talking an external application (stand-alone exe) that automates
AutoCAD (thus the need to identify running Acad session), or a program
written with ObejctARX .NET API, running inside Acad (then there is no need
to identify Acad session, it runs inside Acad)?
If it is the former, you CANNOT use something like:
m_AcadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
in the COM exe application to automate Acad.
If it is the latter, as said above, no need to identify Acad session, you
code runs in the Acad session is is loaded into.
"mp" wrote in message
news:6374897@discussion.autodesk.com...
I haven't been able to extensively experiment with this yet, just wondering
if anyone knew off hand
and could offer tips that may make my exploration more targeted.
back in the vb6 days there were lots of discussions about trying to find the
correct acad session (more than one runnning), i recall reading about the
running object table but don't know if there was ever a final solution.
the question has arisen again for me in dotnet as our company hired some
programming done before i got here, and it involves a vbnet app that uses
com interop. the current version will not function correctly if you have
more than one session, depending on which session you try to run the program
from. I'm in the process of writing a revised version of that program, as
there were several defects in the original app.
the orgininal app connected to acad application via GetObject,
'm_AcadApp = TryCast(GetObject(, "AutoCAD.Application"), AcadApplication)
Tony alerted me to the fact that that was the incorrect way for an app
getting loaded via netload(running in process). so that's been changed to
m_AcadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
i'm wondering if that issue is part of the cause of the app getting the
wrong session?
one weird thing to me is the current app will find the right session for
some of it's operations...ie placing text objects in the drawing with xdata
attached...the text will go in the right dwg.
but then other aspects of the app will find the wrong session when trying to
find certain blocks in the drawing and read back the xdata text objects for
it's next operation...it will report the block(with certain properties) is
not found, when indeed it is there...because in that instance the app is
finding the wrong drawing for reading the blocks...
i don't understand why it would find the right dwg for some ops and the
wrong dwg for other ops.
any tips appreciated,
mark