Get ClassID of different versions of program with same ProgID

Discussion in 'Python' started by ilocke, Jun 1, 2007.

  1. ilocke

    ilocke Guest

    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
     
    ilocke, Jun 1, 2007
    #1
    1. Advertising

  2. ilocke

    Matimus Guest

    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
     
    Matimus, Jun 2, 2007
    #2
    1. Advertising

  3. ilocke

    ilocke Guest

    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
     
    ilocke, Jun 2, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mario Hébert

    .Net component and locked classid

    Mario Hébert, Jul 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    392
    Arild Fines
    Jul 5, 2003
  2. Christopher Brewster
    Replies:
    5
    Views:
    345
    John Machin
    Nov 14, 2008
  3. bluebaron
    Replies:
    3
    Views:
    743
    Jonathan N. Little
    Nov 4, 2009
  4. Peter X
    Replies:
    3
    Views:
    338
    Ray at
    Apr 8, 2004
  5. Yves Petinot
    Replies:
    9
    Views:
    295
    Brian McCauley
    Jun 30, 2004
Loading...

Share This Page