At some point in my code I used to call AutoCAD 2012 this way:
AcadApp = GetObject(, "AutoCAD.Application.18")
This procedure does for some reason not work in AutpCAD 2013
AcadApp = GetObject(, "AutoCAD.Application.19") produces an error
If if dim AcadApp as object I get a <COM Type> object (which I cannot use or convert to AcadApplication)
If I dim AcadApp A AcadApplication i get this exception:
{"Unable to cast COM object of type 'System.__ComObject' to interface type 'Autodesk.AutoCAD.Interop.AcadApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{2959C1CC-8577-4EDB-ADDC-6EBBAB147926}' failed due to the following error: En sådan grænseflade understøttes ikke (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."} System.Exception
What changed from 2012 to 2013?
Jan Grenov
CAD/BIM Manager
Solved! Go to Solution.
Solved by Alfred.NESWADBA. Go to Solution.
Hi,
>> What changed from 2012 to 2013?
The library you have to use the refrences for 19. As minimum for the corrent type "AcadApplication" you need the "AutoCAD 2013 Type Library". Take care for all references you use that they point to a *19*-file.
- alfred -
Referencing these AutoCAD dlls, is not an option for me.
I need to use latebinding, mainly because my program needs to support all versions of AutoCAD from 2002 and up.
Is there any way to use something like the code below, for AutoCAD 2013 64bit
Private Function GetAcadObject(byval SelectedVersion as string) As Object Dim ReadyTimeout As TimeSpan = TimeSpan.FromSeconds(60) Dim ReadyPollInterval As TimeSpan = TimeSpan.FromSeconds(0.25) Dim stopwatch__1 = Stopwatch.StartNew() Dim acadObj As Object While stopwatch__1.Elapsed < ReadyTimeout Try acadObj = CreateObject("AutoCAD.Application." + SelectedVersion) If Not acadObj Is Nothing Then Return acadObj End If Catch e As System.Runtime.InteropServices.COMException If e.ErrorCode <> DirectCast(&H800401E3, Integer) Then ' MK_E_UNAVAILABLE If Not e.ErrorCode = DirectCast(&H8001010A, Integer) Then Throw End If End If If e.ErrorCode <> DirectCast(&H8001010A, Integer) Then 'RPC_E_SERVERCALL_RETRYLATER If Not e.ErrorCode = DirectCast(&H800401E3, Integer) Then Throw End If End If End Try Threading.Thread.Sleep(ReadyPollInterval) End While Throw New TimeoutException("Unable to acquire the AutoCAD Object") End Function
Hi,
>> Is there any way to use something like the code below, for AutoCAD 2013 64bit
If that is just a question then I would say YES. You can use latebindng also in that case.
Or do you have any problems with your code, then which problem and at what line.
- alfred -
I have a similar problem.
I used "AutoCAD 2013 Type Library" in my vb6 project on a Windows 64-bit, but does not work.
(works on the autocad 2013 32bit!!)
error 429 the component can not create object.
you have any idea?
I leave you an example that I have constructed to understand the problem:
Option Explicit
Dim Acad As AcadApplication
Dim Dwg As AcadDocument
Private Sub Form_Load()
On Error GoTo Errore
Set Acad = GetObject(, "AutoCAD.Application.19")
Set Dwg = Acad.ActiveDocument
On Error GoTo 0
Exit Sub
Errore:
MsgBox Err.Number & " " & Err.Description
End Sub
thanks
Hi,
have you started AutoCAD before you run your code? If not then: GetObject does not start anything, it looks in the ROT for the first active/responding instance of an ActiveX-server. If GetObject does not find any it stops with the error you showed.
If you want your code to start AutoCAD then you have to use CreateObject!
- alfred -
I've managed to get this working, with just using CreateObject("AutoCAD.Application.19").
My settingfile was supplying AutoCAD.Application.19.0 which of course won't work...
I believed that I changed this to 19 but it was not the case..
Thanks for the help guys!
Alfred thanks for your answer,
Yes i have started AutoCAD before run my code.
The GetObject should catch the running AutoCAD and then execute commands.
The same code works fine on Windows 32-bit, it will not work for autocad 2013 on 64bit.
I do not know the instrument/function ROT.
can you help me please?
where can I find it?
(sorry for my bad english!)
thanks
Hi,
have you tried to start any program with VBA, e.g. MS-Excel and do the GetObject from that programm?
Let's see if that works!
- alfred -
Can't find what you're looking for? Ask the community or share your knowledge.