Get ClassID of different versions of program with same ProgID

I

ilocke

Hello,

I am new to Python and COM, but both seem very useful for automation
as AutoCAD, ArcGIS, and my gps software all have COM interfaces and
ArcGIS actually uses python scripts.

My trouble is that I am running two versions of AutoCAD (14 and 2004).
The problem is that both have the same ProgID.

When I use:
acad=win32com.client.Dispatch('AutoCAD.Application")
with no AutoCAD open, I get whichever version is set as default (I
tested switching my default).
With an AutoCAD session open, it will find the open session regardless
of version.

How can I get the ClassID of the different versions? I can connect to
them, is there some:
acad=win32com.client.Dispatch('AutoCAD.Application")
print acad.ClsID # Or something like that?

I have searched and searched and cannot find such.
I have also tried looking at the makepy, but trying the id numbers I
see there I just get errors:
'Class not registered'

Oh, one note, I don't have access to the registry (at least regedit),
so can't look up the ID's there. I tried pythoncom.GetClassFile, but
get error:
'Moniker cannot open file'
I am assuming because I don't have access to registry.

Thanks for the help,
Ivan
 
M

Matimus

Bummer you can't look into the registry. By convention the ProgID is
named <Program>.<Component>.<version>. Also, usually there is a
version independent ProgID that goes <Program>.<Component>. The
version independent ProgID usually points to the newest version. It
looks like that is what you are using. Many programs get away with not
using those conventions, but I'm willing to bet that there is an
'AutoCAD.Application.14' and an 'AutoCAD.Application.??'. I don't know
what will be there for 2004. Chances are that it is not '2004', but
'15' (or something similar). So, you should be able to use those
instead of the version independent one.

Matt
 
I

ilocke

AutoCAD.Application.16 opens 2004, but I tried numbers before and
after and nothing opend up 14.

I figured out a way to find it though. I was using
pythoncom.GetClassFile on the AutoCAD executable instead of a drawing
file.

I used it with .dwg twice while associated to each of the versions,
and it gave me the ClassID of the associated version.

Now just to get down to the real work and make it do something useful.

Ivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top