VB6 - AutoCAD communication

VB6 - AutoCAD communication

sgrya1
Advocate Advocate
941 Views
23 Replies
Message 1 of 24

VB6 - AutoCAD communication

sgrya1
Advocate
Advocate
Can someone point me in a direction here?

I want AutoCAD to communicate with a VB6 application i have made.

Basically I need a series of questions to be asked in AutoCAD and for my VB app to process the answers and draw things based on the answers given.

Is there a tutorial that someone could point me to or can someone post a simple example for me?

One extra thing is that I want to protect my application with a HASP key which may limit my options of how to implement this.

Hope someone can help.
0 Likes
942 Views
23 Replies
Replies (23)
Message 2 of 24

Anonymous
Not applicable
Three popular methods for temporary storage of parameters passed back and forth are:

1) in ACAD's UserXX system variables.
2) in the Registry
3) in a temporary file

Since you posted this in the VB(A) forum, I'll assume the part of your code that asks the series of questions in ACAD is being written in VBA. In that case, for option #2 look at the VBA "SaveSetting" and "GetSetting" functions, which allow access to a specific section of the Registry. There are similar types of functions in VLisp if you need them.

Examples of these three methods are available in this forum. Hope this helps!
0 Likes
Message 3 of 24

sgrya1
Advocate
Advocate
Hi Colin,

I'm fine with temporary storage of parameters. Been using VB6.0 for a few years.

I really need help with understanding how to communicate between vb6.0 and Autocad. I just need one example really to start me off.

For example, how do I have VB6.0 write a question in the AutoCAD command line "Do you want to draw a line N?"

If I type "Y" then VB6.0 draws a line in AutoCAD.
0 Likes
Message 4 of 24

Anonymous
Not applicable
Hi,

Why not open a form to do what you want with an Option Control for drawing
the line?

Interaction with the user via the command line is generally unecessary and
very hard to recover from when the user inputs the wrong value.

--


Regards

Laurie Comerford
wrote in message news:5850741@discussion.autodesk.com...
Hi Colin,

I'm fine with temporary storage of parameters. Been using VB6.0 for a few
years.

I really need help with understanding how to communicate between vb6.0 and
Autocad. I just need one example really to start me off.

For example, how do I have VB6.0 write a question in the AutoCAD command
line "Do you want to draw a line N?"

If I type "Y" then VB6.0 draws a line in AutoCAD.
0 Likes
Message 5 of 24

sgrya1
Advocate
Advocate
I really don't want to use forms. A form is like a toolbar in my eyes. The less toolbars you use the better(or faster) you are as a draughtsman. I see using even one toolbar as having a full sized keyboard on screen if you were a typist. It's a lot faster typing a sentence using a keyboard than using a mouse. Same goes with toolbars. My 2 cents anyway.
0 Likes
Message 6 of 24

Anonymous
Not applicable
Hi,

You don't have to use a mouse to drive a form. The mouse is simply the way
adopted by most users.

You can use the Tab key to move around and the Enter key (or any other key
for that matter if you program it) to run commands from the form.

Keyboard entry is a highly efficient way of drafting, but the point of
programming is to set up a system which can end up drafting many things from
one input set. For many situations a form is the most effective way of
entering the necessary data to work efficiently. You should not reject use
of forms because you can type keyboard short cuts quicker than you can find
and select an Icon on a toolbar. The two are seperate issues.
--


Regards

Laurie Comerford

wrote in message news:5851303@discussion.autodesk.com...
I really don't want to use forms. A form is like a toolbar in my eyes. The
less toolbars you use the better(or faster) you are as a draughtsman. I see
using even one toolbar as having a full sized keyboard on screen if you were
a typist. It's a lot faster typing a sentence using a keyboard than using a
mouse. Same goes with toolbars. My 2 cents anyway.
0 Likes
Message 7 of 24

sgrya1
Advocate
Advocate
I just think that people will instinctively use the mouse to navigate a form. The questions I need to ask are a series and it would be good to progressively ask them with only relevant questions being asked.

Is anyone able to point me at a simple example of what I'm after?
0 Likes
Message 8 of 24

Anonymous
Not applicable
wrote in message news:5850741@discussion.autodesk.com...
Hi Colin,

I'm fine with temporary storage of parameters. Been using VB6.0 for a few
years.

I really need help with understanding how to communicate between vb6.0 and
Autocad. I just need one example really to start me off.

For example, how do I have VB6.0 write a question in the AutoCAD command
line "Do you want to draw a line N?"

If I type "Y" then VB6.0 draws a line in AutoCAD.


You're looking for the various Getxxx methods on the
Acad.Application.Utility object
For example your sample above would use .GetKword
there's also GetString, GetReal, etc
F1 and google have the details
hth
mark
0 Likes
Message 9 of 24

Anonymous
Not applicable
"MP" wrote in message
news:5851839@discussion.autodesk.com...
wrote in message news:5850741@discussion.autodesk.com...
Hi Colin,

I'm fine with temporary storage of parameters. Been using VB6.0 for a few
years.

I really need help with understanding how to communicate between vb6.0 and
Autocad. I just need one example really to start me off.

For example, how do I have VB6.0 write a question in the AutoCAD command
line "Do you want to draw a line N?"

If I type "Y" then VB6.0 draws a line in AutoCAD.


You're looking for the various Getxxx methods on the
Acad.Application.Utility object
For example your sample above would use .GetKword
there's also GetString, GetReal, etc
F1 and google have the details
hth
mark

ooops 😐
I meant the .Document.Utility object
mark
0 Likes
Message 10 of 24

Anonymous
Not applicable
>> I really need help with understanding how to communicate between
>> vb6.0 and Autocad. I just need one example really to start me off.

>> For example, how do I have VB6.0 write a question in the AutoCAD
>> command line "Do you want to draw a line N?"

>> If I type "Y" then VB6.0 draws a line in AutoCAD.

Question #1: Are you an experienced AutoCAD user?

Question #2: Have you looked at the AutoCAD VBA documentation and samples?

You can use the command line in AutoCAD to prompt for many types of input, and do not need dialog boxes for that.

Dialogs are useless for object selection and precise geometric input that may require measuring things in a drawing (with the aid of object snap); selecting objects in a drawing; and so on, and much of the input that AutoCAD applications typically solicit falls into that category, so you are on the right track.

As far as samples of getting input using the command line, there is plenty of sample code in the VBA docs. Look up the AcadUtility class in documentation.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
0 Likes
Message 11 of 24

Anonymous
Not applicable
Hi,

No one doubts that most users will use the mouse by to navigate a form, but
then you indicated that this program was for some one who wouldn't use the
mouse and shared your prejudice against toolbars - ie I anticipated the
program was for personal use.

As Tony points out below you will probably use the mouse for selection of
data from the drawing. In many cases there can be value in returning that
data to a form for review by the user before committing the data to extra
computation and resultant drafting or output to file etc.

--


Regards

Laurie Comerford
wrote in message news:5851703@discussion.autodesk.com...
I just think that people will instinctively use the mouse to navigate a
form. The questions I need to ask are a series and it would be good to
progressively ask them with only relevant questions being asked.

Is anyone able to point me at a simple example of what I'm after?
0 Likes
Message 12 of 24

sgrya1
Advocate
Advocate
Re Q1.
Like to think so. Daily for a few years now.
Re Q2.
Looked at the VBA Samples but both rely on forms. I need an example of how to ask a question in the command line and for VB (or VBA) to respond to that question.

Even as simple as :
Do you want to draw a line N:
Then as a response :
Specify the start point:
Specify the end point:

There'd be a whole series of questions but that is a simple example of what I'm after.

I've created a VB6.0 application that draws a bunch of things to AutoCAD but I now just want to know how to communicate to and from VB6.0.

What's an ARX application. Is it VB oriented?
0 Likes
Message 13 of 24

Anonymous
Not applicable

wrote in message news:5852343@discussion.autodesk.com...
Re Q1.
Like to think so. Daily for a few years now.
Re Q2.
Looked at the VBA Samples but both rely on forms. I need an example of how
to ask a question in the command line and for VB (or VBA) to respond to
that question.

Even as simple as :
Do you want to draw a line N:
Then as a response :
Specify the start point:
Specify the end point:

There'd be a whole series of questions but that is a simple example of what
I'm after.



apparently my answer didn't satisfy
:-)
mark
0 Likes
Message 14 of 24

sgrya1
Advocate
Advocate
Mark,

Sorry. Trying to look into your answer. Can't find anything in 2007 help and I just don't know what to google. ".Document.Utility"

Nothing seems to point me at a simple example or tutorial.
0 Likes
Message 15 of 24

Anonymous
Not applicable

wrote in message news:5852385@discussion.autodesk.com...
Mark,

Sorry. Trying to look into your answer. Can't find anything in 2007 help and
I just don't know what to google. ".Document.Utility"



Where are you looking???
Do you see Developer Help under Additional Resources?



Nothing seems to point me at a simple example or tutorial.



googling .Utility gave me 131 hits in under 1 sec.

ps don't know what it's like looking at these ngs under the web interface
a newsreader is generally preferred for er... reading newsgroups

mark
0 Likes
Message 16 of 24

sgrya1
Advocate
Advocate
Off topic but yes, it is a big prejudice. I’m not there myself but I highly regard anyone who can work with anything close to a clean screen. Every half second of moving the mouse around while you have one hand hovering already over the keyboard is a half second wasted and all those half seconds add up (to a frightening point when I see draftsmen with one hand idle). I look on in awe at some draftsmen who’ve spent enough time creating every single keyboard shortcut they can to the point where both hands trying to keep up with what they are thinking.

A form popping up every minute or so is as disruptive as an uncessary toolbar.
0 Likes
Message 17 of 24

sgrya1
Advocate
Advocate
Dead right. I don't know who's responding to what in this internet discussion group. Newsgroups??? Appears I need help there too.

I was googling it in google on the internet which gives 169,000,000+ results for .utility.

Is there a website with a google search engine within it I should be looking at?
0 Likes
Message 18 of 24

Anonymous
Not applicable

wrote in message news:5852402@discussion.autodesk.com...
Dead right. I don't know who's responding to what in this internet
discussion group. Newsgroups??? Appears I need help there too.

I was googling it in google on the internet which gives 169,000,000+ results
for .utility.

Is there a website with a google search engine within it I should be looking
at?



for reading newsgroups, use a newsreader
What os are you on?
Assuming some flavor of windows, you likely have Outlook express.
There are other options but for starters it is at least 1000% better than
the horrid web interface.
(imho)
:-)

"Subscribe" to this ng (and any others you want to access)

For google you want GoogleGroups "AdvancedSearch" then enter the group's
name and topics

eg:
http://groups.google.com/groups?q=group%3Aautodesk.autocad.customization.vba+%22.utility%22&ie=UTF-8&oe=UTF-8&hl=en
0 Likes
Message 19 of 24

Anonymous
Not applicable
If you really have looked Acad VBA help, you could not missed
AcadUntility.GetPoint() (and all other GetXXX() methods), and for each of
the GetXXX() methods, VBA help provides a piece of example code. The sample
code for GetPoint() does exactly what you want: ask user to pick two points
and then draw a line. There is not form is required/relied on (however, if
your process logic need to use form beofre/after asking uer picking points,
you can have one, of course).

But the real issue, IMO, is that you automate Acad from a stand-alone exe.
Your user runs the exe, and they get prompted in Acad (so, you have to find
a reliable way to make the targeting Acad session ,and there could be more
than 1 session running, becoming active Window), so user has to turn his
attetion from your app to Acad; once the user picked the poins (or did other
things), you have to make your exe active Windows again, user has to turn
his eye back to your app. Form the point of view of usability, it is bad
application design.

If you have to automate app, like Acad, you should focus the user in your
app and make the automating really "automatic". If the process requires
focusing unser interaction in one app (Acad, in your case), you should use
AutoCAD to automate your app (you can make your VB6 app as an ActiveX EXE,
COM automate-able).

Do not really know what your app does, hard to say more. Just do not like
the idea of asking user to respond in Acad while automating Acad. Acad
itself is so complicated and most drafting commands reqires certain user
interaction. Acad provides so many ways to be programmed that the better
solution most likely should be done from Acad end, rather than from outside
app end when user interacting with Acad is required.


"sgrya1" wrote in message news:5852343@discussion.autodesk.com...
Re Q1.
Like to think so. Daily for a few years now.
Re Q2.
Looked at the VBA Samples but both rely on forms. I need an example of how
to ask a question in the command line and for VB (or VBA) to respond to
that question.

Even as simple as :
Do you want to draw a line N:
Then as a response :
Specify the start point:
Specify the end point:

There'd be a whole series of questions but that is a simple example of what
I'm after.

I've created a VB6.0 application that draws a bunch of things to AutoCAD but
I now just want to know how to communicate to and from VB6.0.

What's an ARX application. Is it VB oriented?
0 Likes
Message 20 of 24

sgrya1
Advocate
Advocate
Norman,

Thankyou very much for your reply. Your response heavily backs Mark's (MP) suggestion that I search for GetXXX.

I clearly need some “self help” advise in how to search what I’m after.

I don't know what you mean by “Acad VBA help”. Where is this located and how do I access it?

You mentioned that it provides exactly the sample code I was after but I can’t find it.

Mark suggested google groups but
http://groups.google.com/group/autodesk.autocad.customization.vba/search?hl=en&group=autodesk.autocad.customization.vba&q=getxxx
offers 1 only result for “AcadUntility.GetPoint()”

I don’t necessarily want to automate Acad from a stand-alone exe. I just want to protect what I’ve created with a HASP key.
As you say it would be better if I have VB(A) work with the drawing that that is open so that I don’t have problems in understanding which open drawing the exe should be working with.

Can I protect the VBA code that works inside AutoCAD? To be honest I’ve never created VB code inside AutoCAD so I don’t know where to start and is the reason I’m asking the question.

To try to explain my application, all I want is for AutoCAD to converse with the user asking for a start point and an end point and what to insert at the start points and end points and what to do in between. It’s a series of questions and mouse clicks for different adjustment locations. After a few calculations I need to then insert different blocks here and there and add numerical text values at defined points.
You mention that I could make my VB6 app as an ActiveX EXE, COM automate-able. Sorry but not so sure what you mean by that either.
0 Likes