Jump to content

vba to vb.net


metaldan

Recommended Posts

Hi

 

I have a application for autocad 2008 in vba and now, we like to upgrade to autocad 2011 ( 643 bit ). I try with the vba patch ( with acad 2011 64 bit) , but I have with that line

 

Set oblock = ThisDrawing.ModelSpace.InsertBlock(PT1, TYPE_BOM, 1#, 1#, 1#, 0#)

 

It look like that autocad 2011 don't reconize to code for manipulate autocad object.

 

There is a way to use my old code, or I have to re-code it in vb.net??

 

If my solution is VB.net, where i can foud a good tutoriel for manipulate acad odbjet ( insert block, change is atribute, copy block in a second drawing) . I allerady know i vb.net work, I just need a few help to start me with the acad object.

 

Thank's for your help and excuse my english, I'am a french guy

Link to comment
Share on other sites

You need to use Autodesk's "Magic Macro" to port your VBA code to VB.NET for Visual Studio 2008, then you can open your Visual Studio 2008 project with Visual Studio 2010, and your code will automagically be converted to the current standard, syntax, etc..

 

Just be sure that you set your "compile" .NET Framework to 3.5 (or older) to suit the platforms for which you are writing code.

 

You can still obtain the Express (Free) versions of Visual Studio 2008, and 2010... I personally use 2010. If you go the Express route, there are some tricks to getting it (VSE) to properly debug, and step through breakpoints, etc.

 

Hope this helps!

Link to comment
Share on other sites

Hi

 

A lot of the older VBA examples and code used "ThisDrawing" as above in you code

A lot of times its easy to define "ThisDrawing" and code can? function (some tweaking may be needed)

Define ThisDrawing:

 

Dim ThisDrawing As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument

May resolve some issues

Link to comment
Share on other sites

You need to use Autodesk's "Magic Macro" to port your VBA code to VB.NET for Visual Studio 2008, then you can open your Visual Studio 2008 project with Visual Studio 2010, and your code will automagically be converted to the current standard, syntax, etc..

 

Just be sure that you set your "compile" .NET Framework to 3.5 (or older) to suit the platforms for which you are writing code.

 

You can still obtain the Express (Free) versions of Visual Studio 2008, and 2010... I personally use 2010. If you go the Express route, there are some tricks to getting it (VSE) to properly debug, and step through breakpoints, etc.

 

Hope this helps!

 

 

:thumbsup:

 

 

@ metaldan:

I have lots of old VBA code that was written for AutoCAD 2004 and it all runs fine on AuotCAD 2011/2012, 32 and 64 Bit.

 

In your code try putting quotation marks around your block name:

 

Set oblock = ThisDrawing.ModelSpace.InsertBlock(PT1, [b][color=red]"TYPE_BOM"[/color][/b], 1#, 1#, 1#, 0#)

 

and then you need to iterate the attribute references to set them.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...