I have code the user can select button to start AutoCAD 2006 with a certain template, or a button to utilize the current drawing for an application. I have spent a week trying to convert/rewrite this to VB 2005 Express / AutoCAD 2006. I am now at the mercy of asking someone to get me to this point. (Before asking I have searched blogs, discussion groups, books, the internet, etc. and only found I am getting a migraine).
Sorry, the code is written in VB6, trying to just convert the code to VB 2005 express so just the start of the program will work.
1. click button AutoCAD 2006 starts with specific template
2. click button and the current drawing is useds.
Thanks for any help.
Well getting vb6 code to work in .net isn't that tough, but managing it absolutely is. The following will help you migrate, but generally you should get a newer version of whatever you were using. Sometimes the differences between autocad versions break the code by themselves.
MS has an entire book dedicated to migrating available for free here: http://msdn2.microsoft.com/en-us/vbrun/ms788236.aspx
Also: Upgrading Visual Basic 6.0 to Visual Basic .NET and Visual Basic 2005 guide , http://www.microsoft.com/downloads/details.aspx?FamilyId=7C3FE0A9-CBED-485F-BFD5-847FB68F785D&displaylang=en
You can get a free assessment tool http://www.microsoft.com/downloads/details.aspx?FamilyId=10C491A2-FC67-4509-BC10-60C5C039A272&displaylang=en
Finally there is a dedicated community to this issue: http://practices.gotdotnet.com/projects/vb62vbnet
But the bottom line is, if you are an architect and can afford that, go to rentacoder.com , and publish an Ad. I think for 100-200$ you'll get it done and working perfectly.
If you feel safe with sharing the code, I could take a look at it. You can contact me at firstname.lastname@example.org
Yes I tried the upgrade wizard in VB 2005 express and I got about 15 errors. I tried the different references
AutoCAD 2006 type library
acdbmgd.dll (in ProgFiles\AutoCAD 2006)
acmgd.dll (in ProgFiles\AutoCAD 2006)
I also tried several imports
One source said I needed to add this
AutoCAD = Autodesk.AutoCAD.Interop
AXDBLib = Autodesk.AutoCAD.Interop.Common
My old code had this
Public acadAp As Object
Public acadDoc As Object
As to the Arx question, I downloaded the ObjectArx sample for 2006 & 2007 and could not get any of the samples to work.
I am seeing so many confiicting samples that I dont know whick way is right. That is why I am here to just get my connection established. With the level of code I have seen here someone should be able help me out.
Thank you for your time. Please don't take this the wrong way, I am only reporting back what is happening. I did not have to change any references in any of the 3 samples.
When I started the VB6 app it failed. All I needed to do was add an End If to bottom of program. Once, I could run the application, I was prompted to select a dwg to use as a template. (I was wanting to have the code specify an existing dwt so all of my text/dim styles, layers, etc. would already be there) anyway, I selected the dwg file equivalent for my template. AutoCAD 2006 launched and the message was prompted on the command line. Which appeared to be perfect, but program did not actually use my drawing. There were no preset layers, dim styles, text styles etc. in the drawing that were displayed.
The upgraded code came up with no errors. It worked as the prior did. The open dialog box would only accept a dwg. I looked at the command line history and it brought in my titleblock.dwg and added .dwt to it?
From command line: Template drawing C:\\Titleblocks\NoTitleblock2006.dwg.dwt is not on file. Using defaults.Regenerating model.
Also, if I run the program, then close AutoCAD, then rerun the same open program, it crashes for some reason.
The rewritten app said it couldn't find the upgradesupport.vb, so I copied it from the other app to make that go away. When I launched the app it was asking permission to go to the internet which I declined. Then the following error was reported.
Troubleshooting Exceptions: System.Net.Sockets.SocketException
Overall the upgraded code is extremely close to what I need and any other newbies to VB2005 express will find this code is helpful getting started and very different from VB6. He even added VB6 code to do the same thing by only adding an End If statement.
Any other newbies finding this useful to them, chime in and thank CougarAC.
1. Oops, kinda did this on the quick. You could have also added an underscore to the line. Like so:
If Not curDoc Is Nothing Then _
curDoc.Utility.Prompt (vbLf & "Hello from VB6" & vbLf)
Or just deleted the line break:
If Not curDoc Is Nothing Then curDoc.Utility.Prompt (vbLf & "Hello from VB6" & vbLf)
2. In the VB6 version, I used a CommonDialog control. You can see the properties for this control are set as follows:
a. DefaultExt = .dwg (change this to .dwt)
b. Filter = AutoCad Drawings (*.dwg) | *.dwg (change this to AutoCAD Templates (*.dwt)|*.dwt)
In both .NET versions, CommonDialog was replaced with System.Windows.Forms.OpenFileDialog control. But if you change the same properties as above, it will allow templates.
Not sure why it is crashing though. Can you post any error information?
3. a. To be completly honest, the rewritten version was not fully rewritten, just made a copy of the project directory and reworked the code to make it more effecient. Must have missed a declaration.
b. This is really troubling. The code doesn't even use System.Net.Sockets. You can try to create a new EXE project, add the appropriate references to AutoCAD 2006 and ObjectDBX type libraries. Add the appropriate controls to the userform (Button and OpenFileDialog controls). Finally copy the code from the old project Form1 to your new project Form1.
Most of the .NET project files are XML files. You can open them in any text viewer and really get a feel as to what they contain.