.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

can dotnet find the right acad session?

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
322 Views, 5 Replies

can dotnet find the right acad session?

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
5 REPLIES 5
Message 2 of 6
NathTay
in reply to: Anonymous

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?


Yes. Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication is retrieving from the process your dll is loaded into.
Message 3 of 6
Anonymous
in reply to: Anonymous

wrote in message news:6375012@discussion.autodesk.com...
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?


Yes. Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication is
retrieving from the process your dll is loaded into.

Thanks for the response. I'll have to fix that in the original app when i
get back to work. That will be good to get that problem resolved.
Thanks
mark
Message 4 of 6
Anonymous
in reply to: Anonymous

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
Message 5 of 6
Anonymous
in reply to: Anonymous

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

"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
Message 6 of 6
Anonymous
in reply to: Anonymous

For standalone clients, you must either use the
RunningObjectTable, or it's pot luck insofar as
which of several running instances the app
connects to.

You can't use the code I showed for NETLOADed
dlls, because those APIs are not available to
out-of-process clients.

Another way to solve the problem is to make the
standalone app a COM server in addition to a COM
client, and then you can start it from AutoCAD using
the (vlax-create-object) function, and you can pass
it the object returned by (vlax-get-acad-object).

Another way to solve the problem is to convert the
app to a NETLOADed DLL.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

"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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost