COM + External App

COM + External App

Anonymous
Not applicable
284 Views
6 Replies
Message 1 of 7

COM + External App

Anonymous
Not applicable
I'd like to have a COM interface that can wrap some functions in my app, and i'd like for that interface to be called from, for example, a stand alone VB EXE. I must admit that i don't know a whole bunch about COM. That being said, i can very easily make a COM class that can be use via the VBA for AutoCAD. But if i try to make an external VB app, it is never able to instantiate my COM class. I assume this is because the COM class needs to be in the presence of AutoCAD, and my external app doesn't "know" that AutoCAD is up and running. What do i need to do to expose COM classes from my ARX to external apps? Thanks! -Rich
0 Likes
285 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
A COM server that links to AutoCAD or its ARX libraries must be an in-process server (meaning it must be loaded into AutoCAD's process space). Hence, you cannot load such a COM server into another client process. To use an ARX based COM server from a client, you must load it via the GetInterfaceObject() method of the AutoCAD Application object, rather than the GetObject() method. If your client doesn't know AutoCAD is running, it must either start one, or try to connect to a running instance. -- http://www.caddzone.com AutoCAD based Security Planning Solutions: http://www.caddzone.com/securityplanning AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005 http://www.acadxtabs.com "Justavian" wrote in message news:40c03eb4$1_2@newsprd01... > I'd like to have a COM interface that can wrap some functions in my app, and > i'd like for that interface to be called from, for example, a stand alone VB > EXE. I must admit that i don't know a whole bunch about COM. That being > said, i can very easily make a COM class that can be use via the VBA for > AutoCAD. But if i try to make an external VB app, it is never able to > instantiate my COM class. I assume this is because the COM class needs to > be in the presence of AutoCAD, and my external app doesn't "know" that > AutoCAD is up and running. > > What do i need to do to expose COM classes from my ARX to external apps? > > Thanks! > > -Rich > >
0 Likes
Message 3 of 7

Anonymous
Not applicable
Wow. Amazingly i've been off and on trying to do this for like a year, and after just spending about 12 hours on it, i managed to figure it out. Just in case anyone else is having this problem - basically i couldn't instantiate my COM class directly. Instead, i needed to instantiate an AcadApplication in my VB project, and after retrieving it via GetObject(, "AutoCAD.Application"), i could then use acadApp.GetInterfaceObject() to retrieve an instance of my COM class. -Rich "Justavian" wrote in message news:40c03eb4$1_2@newsprd01... > I'd like to have a COM interface that can wrap some functions in my app, and > i'd like for that interface to be called from, for example, a stand alone VB > EXE. I must admit that i don't know a whole bunch about COM. That being > said, i can very easily make a COM class that can be use via the VBA for > AutoCAD. But if i try to make an external VB app, it is never able to > instantiate my COM class. I assume this is because the COM class needs to > be in the presence of AutoCAD, and my external app doesn't "know" that > AutoCAD is up and running. > > What do i need to do to expose COM classes from my ARX to external apps? > > Thanks! > > -Rich > >
0 Likes
Message 4 of 7

Anonymous
Not applicable
I'm working on a C++ app (as an ARX) that I may want to be able to call it's functions from VBA within Acad. I know very little about COM, but I think I understand enough to know that I will need to use it. Can you offer any suggestions? Is there a 'COM for Dummies'? -- Thanks, Martin Schmid, EIT, CCSA, MCDBA, MCSE "Justavian" wrote in message news:40c03eb4$1_2@newsprd01... > I'd like to have a COM interface that can wrap some functions in my app, and > i'd like for that interface to be called from, for example, a stand alone VB > EXE. I must admit that i don't know a whole bunch about COM. That being > said, i can very easily make a COM class that can be use via the VBA for > AutoCAD. But if i try to make an external VB app, it is never able to > instantiate my COM class. I assume this is because the COM class needs to > be in the presence of AutoCAD, and my external app doesn't "know" that > AutoCAD is up and running. > > What do i need to do to expose COM classes from my ARX to external apps? > > Thanks! > > -Rich > >
0 Likes
Message 5 of 7

Anonymous
Not applicable
If all you need to do is use it in VBA, it's quite easy. 1) Use the "New ATL Object" button on the ARX toolbar. 2) Choose "Simple Object" 3) Enter a name for your COM class. 4) On the Attributes tab, check the Support ISupportErrorInfo box. 5) Hit ok. 6) Find the interface for your class in the Class View - has a different icon from normal classes. 7) Right click to add methods, etc. So implement whatever methods you want, and you should be ready to go. Now when you load your ARX into AutoCAD, go to the VBA editor and add a reference to your ARX (actually, it might already be added - i can't remember). You can now make an instace of that class and use it. -Rich "Martin Schmid" wrote in message news:40c05f64$1_3@newsprd01... > I'm working on a C++ app (as an ARX) that I may want to be able to call it's > functions from VBA within Acad. I know very little about COM, but I think I > understand enough to know that I will need to use it. Can you offer any > suggestions? Is there a 'COM for Dummies'? > > -- > Thanks, > Martin Schmid, EIT, CCSA, MCDBA, MCSE > > > "Justavian" wrote in message > news:40c03eb4$1_2@newsprd01... > > I'd like to have a COM interface that can wrap some functions in my app, > and > > i'd like for that interface to be called from, for example, a stand alone > VB > > EXE. I must admit that i don't know a whole bunch about COM. That being > > said, i can very easily make a COM class that can be use via the VBA for > > AutoCAD. But if i try to make an external VB app, it is never able to > > instantiate my COM class. I assume this is because the COM class needs to > > be in the presence of AutoCAD, and my external app doesn't "know" that > > AutoCAD is up and running. > > > > What do i need to do to expose COM classes from my ARX to external apps? > > > > Thanks! > > > > -Rich > > > > > >
0 Likes
Message 6 of 7

Anonymous
Not applicable
If you want to understand the internals of COM/Automation, a good book I've found is "Visual C++ .NET Bible" by Archer & Whitechapel. A large portion of the book is dedicated to various aspects of COM programming in an easy-to-follow way. However, you can easily get away using and understanding just enough COM to interact with VBA and AutoCAD by just imitating the samples. Just make sure your project uses ATL. 🙂 Look at the property palette samples, as all those properties are accessible from VBA. that should get you started. Andrew "Martin Schmid" wrote in message news:40c05f64$1_3@newsprd01... > I'm working on a C++ app (as an ARX) that I may want to be able to call it's > functions from VBA within Acad. I know very little about COM, but I think I > understand enough to know that I will need to use it. Can you offer any > suggestions? Is there a 'COM for Dummies'? > > -- > Thanks, > Martin Schmid, EIT, CCSA, MCDBA, MCSE > > > "Justavian" wrote in message > news:40c03eb4$1_2@newsprd01... > > I'd like to have a COM interface that can wrap some functions in my app, > and > > i'd like for that interface to be called from, for example, a stand alone > VB > > EXE. I must admit that i don't know a whole bunch about COM. That being > > said, i can very easily make a COM class that can be use via the VBA for > > AutoCAD. But if i try to make an external VB app, it is never able to > > instantiate my COM class. I assume this is because the COM class needs to > > be in the presence of AutoCAD, and my external app doesn't "know" that > > AutoCAD is up and running. > > > > What do i need to do to expose COM classes from my ARX to external apps? > > > > Thanks! > > > > -Rich > > > > > >
0 Likes
Message 7 of 7

Anonymous
Not applicable
Hmmm - this just showed up for me, six hours after it says it was posted. Had it appeared when the time says it was posted, i would have this problem solved 20 minutes sooner! Thanks for the response Tony... -Rich "Tony Tanzillo" wrote in message news:40c0a646$1_1@newsprd01... > A COM server that links to AutoCAD or its ARX libraries > must be an in-process server (meaning it must be loaded > into AutoCAD's process space). Hence, you cannot load > such a COM server into another client process. > > To use an ARX based COM server from a client, you must > load it via the GetInterfaceObject() method of the AutoCAD > Application object, rather than the GetObject() method. > > If your client doesn't know AutoCAD is running, it must > either start one, or try to connect to a running instance. > > -- > http://www.caddzone.com > > AutoCAD based Security Planning Solutions: > http://www.caddzone.com/securityplanning > > AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005 > http://www.acadxtabs.com > > > "Justavian" wrote in message news:40c03eb4$1_2@newsprd01... > > I'd like to have a COM interface that can wrap some functions in my app, and > > i'd like for that interface to be called from, for example, a stand alone VB > > EXE. I must admit that i don't know a whole bunch about COM. That being > > said, i can very easily make a COM class that can be use via the VBA for > > AutoCAD. But if i try to make an external VB app, it is never able to > > instantiate my COM class. I assume this is because the COM class needs to > > be in the presence of AutoCAD, and my external app doesn't "know" that > > AutoCAD is up and running. > > > > What do i need to do to expose COM classes from my ARX to external apps? > > > > Thanks! > > > > -Rich > > > > > >
0 Likes