VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Visual Studio 2005 + AutoCAD?

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
371 Views, 11 Replies

Visual Studio 2005 + AutoCAD?

Hi!
I wanted to start program using Visual Basic in Visual Studio 2005. I imported necessary libraries but I don't know how to integrate my VB code with AutoCAD session (Visual Studio doesn't see any of my objects which appear in AutoCAD) . Is there any way to run my VB programs directly from Visual Studio without using VB Editor build-in AutoCAD. Thx for replies in advance.
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: Anonymous

wrote in message news:5455519@discussion.autodesk.com...
Hi!
< I wanted to start program using Visual Basic in Visual Studio 2005.


Do you want to program an application, or do you want to start(run) an
application written in VB.NET (note, Visual Basic in VisualStudio2005 is
different thing from VBA in AutoCAD)? What kind of application it is?
Statnd-alone desktop or something must run inside other application(Acad)?


< I imported necessary libraries but I don't know how to integrate my VB
code with AutoCAD session (Visual Studio doesn't see any of my objects which
appear in AutoCAD) .


What does "integrate VB cod with Acad session" mean? Automate AutoCAD from
outside of Acad with your stand-alone app, or you want the VB code actually
run like VBA(topic of this NG) code inside AutoCAD? Why and how your object
appears in AutoCAD, and why VisyalStudio should see it? What did exactly do?


< Is there any way to run my VB programs directly from Visual Studio without
using VB Editor build-in AutoCAD. Thx for replies in advance.

If your Appication is a stand-alone app, you do not need Visual Staudio to
run it, neither VBA Editor in Acad. If you need VBA editor in Acad to run
your stuff, it VBA code, which does not run and cannot be used directly in
Visual Studio 2005.


There are just to many things that are so vague to understand what you want
to do, what you have done, and what you actually asked. If you can describe
what you exactly want to do in a bit more detail, it might result in some
helpful answers
Message 3 of 12
Anonymous
in reply to: Anonymous

Hello!


Can't I write an app using Visual Studio behaving like VBA code in AutoCAD? Isn't importing Acad libraries enough to write this kind of program.

< What kind of application it is? Statnd-alone desktop or something must run inside other application(Acad)? >

This app isn't stand-alone app, it must run with Acad already started. It's something like writing in VLisp inside Acad, it must behave like VBA in AutoCAD but written inVisual Studio (I should see the same stuff within Acad session as if I use VLisp or VBA in Acad).

I used:

acApp = GetObject(, "AutoCAD.Application.17")

to get my application for Acad 2007, but as I want to retrieve any object from model space using

acApp.Application.ActiveDocument.Item(0)

for instance, it doesnt see any of them even they are there. Moreover it behaves like it wouldn't get appropriate drawing (the one active in Acad).


run like VBA(topic of this NG) code inside AutoCAD? >

exacly
Message 4 of 12
Anonymous
in reply to: Anonymous

< or you want the VB code actually
run like VBA(topic of this NG) code inside AutoCAD >

exactly
Message 5 of 12
Anonymous
in reply to: Anonymous

What i understand is..
you want to automate AutoCAD from visual basic rather than VBA.
I would just set a reference to the object library from vb menu tool>references. i would do that if it were a microsoft office applications like Excel... i am not sure u could do this with AutoCAD may be u can try setting a reference to it

and u should create a object of type Autocad.application and iterate through to your object..


try it and let me know if u can do that............
Message 6 of 12
Anonymous
in reply to: Anonymous

I already added a reference to AutoCAD. I am able to create AutoCAD objects like AcadApplication, Drawing etc, but whole thing is that it just sees whole AutoCAD environment without current data in it i.e. ActiveDocument doesn't contain appropriate drawing loaded in AutoCAD.
Why Visual Studio see my aCAD session like it was empty?
Message 7 of 12
Anonymous
in reply to: Anonymous

OK, you want do programming with VS2005 that run inside Acad as VBA code.

There are two ways for you to choose.

1. With VS2005 (VB.NET or C#), you can only do program that truly run inside
Acad using ObjectARX .NET API. Inside ,NET API project, you can also use
Acad COM API by set reference to Acad Type library and Acad ObjectDBX
library. BUt the project must .NET API dll and load into AutoCAD with
command "netload".

2. You can write .NET dll and expose it as COM component and then use it in
conjunction with Acad VBA project, or stand-alone COM application.

If you want to use COM API in your VS2005 project (in must be .NET API
project, if it is to run inside Acad), the reference set to Acad type
library only gives part of COM APIs. You may also need to set reference to
"Acad/ObjectDBX common 16[17] type library", if you need more
functionalities.

Unless you want to COM DLL with VS2005, you are in wrong NG.


wrote in message news:5457129@discussion.autodesk.com...
< or you want the VB code actually
run like VBA(topic of this NG) code inside AutoCAD >

exactly
Message 8 of 12
Anonymous
in reply to: Anonymous

Ok, I just set a reference to "Acad/ObjectDBX common 17 type library" and it worked, I can see my active Acad session from within VS2005.
Thanks for help!

By the way I have some questions:

< Inside .NET API project, you can also use Acad COM API by set reference to Acad Type library and Acad ObjectDBX library >

What does generally Acad COM API mean? Is it simmilar to components I can retrieve when using VBA in Acad? What's ObjectDBX library for?

< Unless you want to COM DLL with VS2005, you are in wrong NG. >

What's NG ?
Message 9 of 12
LanKhuong
in reply to: Anonymous

< What's NG ? >

I guess he means News Group.
Message 10 of 12
Ed.Jobe
in reply to: Anonymous

Further, this NG is for vba/vb6. NET topics are discussed in the NET ng here:http://discussion.autodesk.com/forum.jspa?forumID=152

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 11 of 12
NathTay
in reply to: Anonymous

I would suggest it is alright for users of any language/version to use this group if the question is directly related to the ActiveX API.

Regards - Nathan
Message 12 of 12
Ed.Jobe
in reply to: Anonymous

10-4

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost