Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: .COM troubles

  1. #1
    Member
    Join Date
    2012-01
    Location
    Rhode Island USA
    Posts
    18
    Login to Give a bone
    0

    Default .COM troubles

    Hi everybody, I am trying to access AutoCAD from a Visual Basic Windows form, and pulling my hair out. Every bit of help I can find from Autodesk involves .NET class library projects, the available wizards are for same, and the only internet references I can find to do what I want say something like "you cant reference the .NET dlls if using a Windows form, you can only use the .COM references, Autocad libraries and ObjectDBX". OK, so I have tryed a hundred ways of doing that without success. I used to use userforms in VBA and migrated to VB6 and was still able to access AutoCAD from forms and this is the way I would prefer to continue with Visual Studio (I would also prefer to keep using "Thisdrawing" , but it seems impossible no matter how many web contributers say otherwise). Is there anyone out there that has accomplished what I am trying to do, or is this way of programming very unfortunately going completely extinct and Netload is the only option left? (currently working with trial versions of AutoCAD 2013 and Visual Studio 2010 at home but at work I use AutoCAD 2011 which is what I really need to update my old projects for)

    Thanks for any help...

  2. #2
    AUGI Addict
    Join Date
    2015-12
    Posts
    2,095
    Login to Give a bone
    0

    Default Re: .COM troubles

    I think there may be a misquote there. I've used forms with both in-process dotNET DLLs, and a couple of out-of-process EXEs which connected to AutoCAD through COM. I think part of the problem is confusing terms "forms" with whether the final product is a NETLOADed/demand loaded DLL or stand-alone executeable.

    If you are trying to do development at home along with 2013, you won't be able to re-use it with the earlier 2011 release without major changes. There's a major re-organization of dependancies on the DLL side, and for a stand-alone EXE you would need to reference the interop DLLs from the ObjectARX package.

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: .COM troubles

    I know this is easier said then done, but have you considered instead simply porting your VBA to VB.NET?

    Unless VBA7 comes to fruition, I suspect you're going to continue to experience some difficulty in using VBA with newer versions. Not that it would be impossible moving forward; I'm simply offering what I consider to be a logical progression.

    HTH
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Member
    Join Date
    2012-01
    Location
    Rhode Island USA
    Posts
    18
    Login to Give a bone
    0

    Default Re: .COM troubles

    Yes dgorsman, out of process is what I have been having trouble with, I was not aware that forms could also be used with NETLOADed projects. Actually I found the information I needed almost immediately after I posted the question, midway down the following link:
    http://www.cadalyst.com/category/cad...afting/autocad

    This (in a quick test) worked perfectly for the experimentation I have been doing at home on 2013 on a Vista 32 bit system, I can even change it so "Thisdrawing" works just like VBA for the few tasks I tried, except it looks like I need to also add another reference as "Regen" gives me an error (Whichviewport) with just the interop and interop.common references. This seemed incredibly simple, hopefully it will be similar on 2011 Windows 7 64 bit.

    I loved RenderMan's reference to VBA7, is that a joke or is that a serious rumor? Anyway, as comfortable as I am in VBA, just making it work forever as is in future operating systems wouldn't make up for it's shortcomings.

  5. #5
    Member
    Join Date
    2012-01
    Location
    Rhode Island USA
    Posts
    18
    Login to Give a bone
    0

    Default Re: .COM troubles

    Actually I found what I needed midway through this page (The World of AutoCAD Programming Platforms, Part 3
    19 Jul, 2012By: Andrew G. Roe )almost right after my original post:

    http://www.cadalyst.com/category/cad...afting/autocad


    After changing "acadDoc" to "Thisdrawing" , a few tries of "Thisdrawing.Modelspace.Addline" and Thisdrawing.Sendcomand" it seems to be just what I was looking for, I am sure I tried something very similar unsuccessfully many times but I probably had .Net references mixed in. It does not work exactly as I had hoped, I noticed "Thisdrawing.Regen" resulted in an error, something to do with "Whichveiwports" not being recognised, the syntax showed underneath as soon as I typed "Regen" but it wouldn't take.

  6. #6
    Member
    Join Date
    2012-01
    Location
    Rhode Island USA
    Posts
    18
    Login to Give a bone
    0

    Default Re: .COM troubles

    Seems to work out of process if referencing just the interop dlls....

    I stopped trying to use .NET altogether for out of process and followed the steps on the following tutorial:

    http://www.cadalyst.com/category/cad...afting/autocad (midway down page)

    The World of AutoCAD Programming Platforms, Part 3
    19 Jul, 2012By: Andrew G. Roe

    This seems to do just what I want, acadDoc can be changed to ThisDrawing and work almost the same (I did notice an error when I tried Thisdrawing.Regen)
    Last edited by rhutchi1; 2012-09-16 at 12:46 PM.

  7. #7
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: .COM troubles

    Quote Originally Posted by rhutchi1 View Post
    This seems to do just what I want, acadDoc can be changed to ThisDrawing and work almost the same (I did notice an error when I tried Thisdrawing.Regen)
    Note that renaming a var to ThisDrawing is not dynamic, i.e. if the current doc changes, a var called ThisDrawing isn't going to update to point to the new doc. You have to handle that. Since you're running out-of-process, acad can't do it for you.
    C:> ED WORKING....


    LinkedIn

  8. #8
    Member
    Join Date
    2012-01
    Location
    Rhode Island USA
    Posts
    18
    Login to Give a bone
    0

    Default Re: .COM troubles

    Ed, not too worried about that, ran into same when converting a VBA application to VB6. I am just relieved that I can make the connection at all for now. Hopefully down the road I will be able to make use of some of the suggestions given here, everything seems to work better in process, and I would like to try dgorsman's advice of using forms in process .NET, but that is another issue altogether, as even showing forms is so much different then what I am used to (even form1.show causes shared errors) which I need to wrap my head around.....

  9. #9
    AUGI Addict
    Join Date
    2015-12
    Posts
    2,095
    Login to Give a bone
    0

    Default Re: .COM troubles

    AutoDesk recommends using their own form-handling methods e.g. ShowModalDialog() rather than those inherited from the Form, for just such reasons.

  10. #10
    Member
    Join Date
    2012-01
    Location
    Rhode Island USA
    Posts
    18
    Login to Give a bone
    0

    Default Re: .COM troubles

    Is there a write up or example on how Autodesk describes best use of ShowModalDialog() for forms in a netload type project?

Page 1 of 2 12 LastLast

Similar Threads

  1. WipeOut Troubles
    By TerribleTim in forum AutoCAD General
    Replies: 3
    Last Post: 2009-07-22, 05:21 PM
  2. Roof Troubles
    By mhannan.100562 in forum ACA General
    Replies: 5
    Last Post: 2008-04-10, 01:39 AM
  3. Workset Troubles - Please Help
    By ekneer in forum Revit Structure - General
    Replies: 10
    Last Post: 2007-04-20, 01:21 PM
  4. Topo Troubles
    By bass.130671 in forum Revit Architecture - General
    Replies: 0
    Last Post: 2007-03-15, 04:06 PM
  5. Elevation troubles
    By h.jobe in forum ACA General
    Replies: 1
    Last Post: 2006-08-25, 05:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •