.NET

Reply
Contributor
dijitalb
Posts: 12
Registered: ‎10-10-2006
Message 1 of 10 (186 Views)

VB 2005 Express to AutoCAD 2006

186 Views, 9 Replies
10-10-2006 06:10 AM
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).

Brian Jarrett
DijitalB@aol.com
New Member
KCorax
Posts: 2
Registered: ‎10-11-2006
Message 2 of 10 (186 Views)

Re: VB 2005 Express to AutoCAD 2006

10-11-2006 07:23 AM in reply to: dijitalb
I'm a little confused, your original code was writen in vb6 or vb.net ? IF the latter then there should be no problem, vb.net code is cross version safe.

Does your code rely on ObjectArx to work or ?
Contributor
dijitalb
Posts: 12
Registered: ‎10-10-2006
Message 3 of 10 (186 Views)

Re: VB 2005 Express to AutoCAD 2006

10-11-2006 10:55 AM in reply to: dijitalb
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.
BJ
New Member
KCorax
Posts: 2
Registered: ‎10-11-2006
Message 4 of 10 (186 Views)

Re: VB 2005 Express to AutoCAD 2006

10-11-2006 11:24 AM in reply to: dijitalb
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 kcorax@removethispartgmail.com
Contributor
dijitalb
Posts: 12
Registered: ‎10-10-2006
Message 5 of 10 (186 Views)

Re: VB 2005 Express to AutoCAD 2006

10-12-2006 07:11 AM in reply to: dijitalb
I have seen 10's of documents and Im totally confused. Everything I have tried is not working. I am asking please for someone for a sample or reply to just get me connected.

BJ
Distinguished Contributor
cgay
Posts: 125
Registered: ‎08-02-2005
Message 6 of 10 (186 Views)

Re: VB 2005 Express to AutoCAD 2006

10-12-2006 02:42 PM in reply to: dijitalb
Brian,

Have you tried to upgrade the code to VB.NET 2005? (Not sure if the express edition includes the upgrade wizard or not)

Without seeing some code I am afraid we would just be guessing as to how to help you.

I can say that you probably don't want to use the .NET ARX APIs, just the COM APIs because you want the ability to launch AutoCAD with a template if it is not running, yes?

C
Contributor
dijitalb
Posts: 12
Registered: ‎10-10-2006
Message 7 of 10 (186 Views)

Re: VB 2005 Express to AutoCAD 2006

10-12-2006 03:59 PM in reply to: dijitalb
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
Imports System.Reflection
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices

One source said I needed to add this
AutoCAD = Autodesk.AutoCAD.Interop
AXDBLib = Autodesk.AutoCAD.Interop.Common

My old code had this
Option Explicit
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.

I appreciate the responses
BJ
Distinguished Contributor
cgay
Posts: 125
Registered: ‎08-02-2005
Message 8 of 10 (186 Views)

Re: VB 2005 Express to AutoCAD 2006

10-13-2006 11:09 AM in reply to: dijitalb
I have attached a zip file containing a VB6 project, and two VB.NET 2005 Projects.

The VB6 project should run as is.

The 2 VB.NET 2005 Projects may not work unless you load them, delete the references to AutoCAD 2006 type library and AutoCAD/ObjectDBX Common 16.0 type library, them re-add them.

The VB.NET project in the folder "Project1.NET Upgraded" is the VB6 project, upgraded, then slightly fixed to solve a couple of upgrade errors.

The VB.NET project in the folder "Project1.NET Rewritten" does the same thing as the previous 2 projects, but the code was refactored a bit.

C
Contributor
dijitalb
Posts: 12
Registered: ‎10-10-2006
Message 9 of 10 (186 Views)

Re: VB 2005 Express to AutoCAD 2006

10-13-2006 01:23 PM in reply to: dijitalb
CougarAC,
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.

Thanks BJ
Distinguished Contributor
cgay
Posts: 125
Registered: ‎08-02-2005
Message 10 of 10 (186 Views)

Re: VB 2005 Express to AutoCAD 2006

10-15-2006 10:28 PM in reply to: dijitalb
BJ,

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.

C
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.