sanderson Posted March 8, 2010 Posted March 8, 2010 For some strange reason, I'm having a struggle to launch AutoCAD. I am getting the error 'Cannot create ActiveX component.' for this code, here... acadapp2009 = CreateObject("AutoCAD.Application.17.2") Imports Autodesk.AutoCAD.Interop Imports Autodesk.AutoCAD.Interop.AcadDocumentClass Imports Autodesk.AutoCAD.Interop.Common PublicClass Form1 ' Public WithEvents AcadApp2009 As Autodesk.AutoCAD.Interop.AcadApplication ' Public acadapp2009 As Autodesk.AutoCAD.Interop.AcadApplication Public acadapp2009 AsObject PublicSub LoadProfile(ByVal ProfileName AsString, ByVal ProfileFile AsString) Try acadapp2009 = GetObject(, "AutoCAD.Application.17.2") Catch ex As Exception acadapp2009 = CreateObject("AutoCAD.Application.17.2") EndTry Dim acaddoc As Autodesk.AutoCAD.Interop.AcadDocument = AcadApp2009.ActiveDocument With AcadApp2009.Preferences.Profiles .importfile(ProfileName, ProfileFile, True) EndWith EndSub The same code works great with AutoCAD 2006 - version 16. Strange, because the application does open, but the code stops and errors out. Do I need to add a timeout, or do until somewhere? Thanks in advance for the help. Quote
fixo Posted March 8, 2010 Posted March 8, 2010 For some strange reason, I'm having a struggle to launch AutoCAD. I am getting the error 'Cannot create ActiveX component.' for this code, here... acadapp2009 = CreateObject("AutoCAD.Application.17.2") Imports Autodesk.AutoCAD.Interop Imports Autodesk.AutoCAD.Interop.AcadDocumentClass Imports Autodesk.AutoCAD.Interop.Common PublicClass Form1 ' Public WithEvents AcadApp2009 As Autodesk.AutoCAD.Interop.AcadApplication ' Public acadapp2009 As Autodesk.AutoCAD.Interop.AcadApplication Public acadapp2009 AsObject PublicSub LoadProfile(ByVal ProfileName AsString, ByVal ProfileFile AsString) Try acadapp2009 = GetObject(, "AutoCAD.Application.17.2") Catch ex As Exception acadapp2009 = CreateObject("AutoCAD.Application.17.2") EndTry Dim acaddoc As Autodesk.AutoCAD.Interop.AcadDocument = AcadApp2009.ActiveDocument With AcadApp2009.Preferences.Profiles .importfile(ProfileName, ProfileFile, True) EndWith EndSub The same code works great with AutoCAD 2006 - version 16. Strange, because the application does open, but the code stops and errors out. Do I need to add a timeout, or do until somewhere? Thanks in advance for the help. Type in the command line: (getvar "acadver") You could see the current version of your AutoCAD - take a look at the fist 3 digits ~'J'~ Quote
sanderson Posted March 8, 2010 Author Posted March 8, 2010 17.2s, so I velieve 17.2 is correct! Remember, AutoCAD does load, but not until after the error appears. Quote
fixo Posted March 8, 2010 Posted March 8, 2010 17.2s, so I velieve 17.2 is correct! Remember, AutoCAD does load, but not until after the error appears. Again just an idea only, do you sure that you have a point to the correct versions of acmgd.dll and acmgdinternal.dll and set 'Copy Local' mode to false? Please, check it ~'J'~ Quote
sanderson Posted March 8, 2010 Author Posted March 8, 2010 Thanks for the info, but I don't get it. The program references AXDBLib (Autodesk.AutoCAD.Interop.Commom) and AutoCAD (Autodesk.AutoCAD.Interop). They are both for version 2009 (17.2s) What are these other dll files for? And what / where is the 'Copy Local' mode setting? Quote
fixo Posted March 8, 2010 Posted March 8, 2010 Thanks for the info, but I don't get it. The program references AXDBLib (Autodesk.AutoCAD.Interop.Commom) and AutoCAD (Autodesk.AutoCAD.Interop). They are both for version 2009 (17.2s) What are these other dll files for? And what / where is the 'Copy Local' mode setting? Here is citation: Go toscreen References tab, double-click on acdbmgd.dll to display its Properties, and set Copy Local to False. (This is to ensure your .NET add-in loads the copy of acdbmgd.dll stored in the AutoCAD folder and doesn’t added to \\bin folder) ~'J'~ Quote
Kerry Brown Posted March 8, 2010 Posted March 8, 2010 I won't do VB, but is the different spelling of AcadApp2009 critical to you ?? Kerry Quote
sanderson Posted March 9, 2010 Author Posted March 9, 2010 There is an MFC Mode property. Is this what you mean? Quote
sanderson Posted March 9, 2010 Author Posted March 9, 2010 Okay, here's my code. I still am getting same ActiveX error. I simply need to load AutoCAD The program works great if I load AutoCAD manually. I need to do a quit, yes at the end. Is there a way to do this?? PublicSub LoadProfile(ByVal ProfileName AsString, ByVal ProfileFile AsString) Dim acadapp2009 As AcadApplication acadapp2009 = CreateObject("AutoCAD.Application.17.2") DoUntil Err.Number = 0 ' Wait for instance of AutoCAD to load Loop Dim acaddoc As Autodesk.AutoCAD.Interop.AcadDocument = acadapp2009.ActiveDocument Dim acadPref As AcadPreferencesProfiles = acaddoc.Application.Preferences.Profiles If acadPref.ActiveProfile = "Despatch2k9"Then lstStatus.Items.Add("Despatch2k9 is already loaded.") Else acaddoc.Application.Preferences.Profiles.ImportProfile(ProfileName, ProfileFile, False) acadPref.ActiveProfile = "Despatch2k9" lstStatus.Items.Add("Despatch2k9 is imported and activated.") EndIf acaddoc.Application.Quit() ' Need to apply 'yes' EndSub Thanks for the help! Quote
Kerry Brown Posted March 10, 2010 Posted March 10, 2010 AcadApp2009 is just a variable. Yes, I realise that. What I asked is "is the different spelling of AcadApp2009 critical" in VB ie. is acadapp2009 the same as AcadApp2009 in VB ? Quote
sanderson Posted March 10, 2010 Author Posted March 10, 2010 I have changed all the case sensitivity.. There may have been some comments. NET self-corrects this to the name that is declared. Anyhow, if you have any thoughts, I would appreciate it. The program cannot create the ActiveX object because it is waiting for AutoCAD to open, yet AutoCAD does open. When AutoCAD is open, the program works. I'm also looking for a way to quit without saving out of the application. Thanks for your help thus far. Quote
shirazbj Posted March 16, 2010 Posted March 16, 2010 I think the program only tends to setup the comunication with AutoCAD ActiveX but not AutoCAD itself. After AutoCAD started, it registed its ActiveX somewhere in the operation system, so other program could contact it. So you must start AutoCAD first. I once use VBA under Excel to comunicate with AutoCAD. It has the same problem. If I changed the name to ACAD.exe for example in the setup sentence in the program, AutoCAD started, but no ActiveX connection then. Quite interested in using .net to comunicated with AutoCAD. Don't know if VB 2008 Express could do this work? Quote
yoannmaingon Posted May 3, 2010 Posted May 3, 2010 Is this issue solved? i have almost the same issue i guess. I am trying to start Autocad 2011 from Javascript/activex. It fails but, if i debug it, and i go step by step on the commands it works. So i was also thinking of having some kind of Timer. But i didn't find the solution yet. any idea? Quote
FunkyFresh Posted June 4, 2010 Posted June 4, 2010 same problem here too. only happens on windows 7 64bit Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.