Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using AutoCAD VBA event in VB 6.0 Application

190 views
Skip to first unread message

Christy Bailey

unread,
May 25, 1999, 3:00:00 AM5/25/99
to
Hello,

I am looking for a way to use the EndOpen AutoCAD event in VB 6.0 (not VBA).
I have read the Help file on this, and it mentions use in VB, but I cannot
figure out the syntax. Is this possible?

Thanks,

Christy Bailey
Management, Information Systems Assistant

DAY BROWN RICE, inc.
9990 Richmond Ave.
South Building, Suite 300
Houston, Texas 77042
Phone: 713.914.0888
Fax: 713.914.0886
Email: cba...@dbrinc.com
Website: www.dbrinc.com


Randall Rath

unread,
May 25, 1999, 3:00:00 AM5/25/99
to
From The Visual Basic Help of VBDesign
http://vbdesign.hypermart.net/cadpages/

Hi Christy,

in your form or class module, add the following to the declares

Option Explicit
Private WithEvents ThisDrawing As AcadDocument

Now in the Object pulldown you have thisdrawing listed, and in the
procedures pull down, all of the events ( including EndOpen )
did I answer the question, or did I miss?
Randall Rath

Christy Bailey

unread,
May 27, 1999, 3:00:00 AM5/27/99
to
OK, here's where I'm stuck: I added the lines you suggested, and as you
said, I did get the EndOpen event in the procedures pulldown. However, I
guess I'm not sure how to use this event. I need to set ThisDrawing to the
active drawing, and when I typed the following lines (after declaring
ThisDrawing as you suggested):

Set ThisDrawing = acad.ActiveDocument

I get the following error message:

"Class does not support Automation or does not support expected interface."

However, if I set a different variable to the active document, say Doc, as
follows:

Dim Doc as AcadDocument
Set Doc = acad.ActiveDocument 'Sets doc to current dwg

and then I use a different variable (ThisDrawing) as you have outlined, the
program never goes to the line:

Private Sub ThisDrawing_EndOpen(ByVal FileName As String)

What am I missing?
(I hope this makes sense.)

Thanks,

Christy Bailey
Management, Information Systems Assistant

DAY BROWN RICE, inc.
9990 Richmond Ave.
South Building, Suite 300
Houston, Texas 77042
Phone: 713.914.0888
Fax: 713.914.0886
Email: cba...@dbrinc.com
Website: www.dbrinc.com


Randall Rath wrote in message <7if63h$en...@adesknews2.autodesk.com>...

Randall Rath

unread,
May 27, 1999, 3:00:00 AM5/27/99
to
From The Visual Basic Help of VBDesign
http://vbdesign.hypermart.net/cadpages/

Hi Christy,
You had the right track, ThisDrawing ( or whatever you call the document
,like acadDoc ) must be declared as the active document try the code below:

Option Explicit
Dim WithEvents ThisDrawing As AcadDocument
Dim AcadApp As AcadApplication
Private Sub Form_Load()
Set AcadApp = GetObject(, "Autocad.application")
Set ThisDrawing = AcadApp.ActiveDocument
End Sub

Private Sub ThisDrawing_BeginSave(ByVal FileName As String)
AppActivate Me.Caption
MsgBox AcadApp.FullName & "Is being saved"
End Sub

If this is the same as what you have tried ( notice I switched events ) or
you try this and it does not work, I know the problem, and have several idea
you can try...
Randall Rath

Christy Bailey

unread,
May 27, 1999, 3:00:00 AM5/27/99
to
Yeah, this is what I tried. When I do this, I get the following error
message:

"Class does not support Automation or does not support expected interface."

on the

"Set ThisDrawing = AcadApp.ActiveDocument"

line. I read in the VB help file under the "Dim" statement that
"WithEvents" is only valid in Class Modules. But I don't know much about
class modules. Is this my problem, or is it something else?

Thanks,

Christy


Randall Rath wrote in message <7ik8qd$po...@adesknews2.autodesk.com>...

Randall Rath

unread,
May 27, 1999, 3:00:00 AM5/27/99
to
From The Visual Basic Help of VBDesign
http://vbdesign.hypermart.net/cadpages/
Hi Christy,
That is not the complete picture, you can use the WithEvents in an Object
Module ( a userForm or Class Module ) a class module is the module with the
cls file extension. What we are seeing here is an interface problem, unless
you are trying to automate the VBA preview edition ( R14.0 ) The very first
thing I will ask, did you try changing the event ( I dont expect this to
make it work, I just need the info on what happens ) that you want to
respond to?
Next, You must be using R14, but which one? R14.0 or R14.01? And last,
is there any reason for using VB, over inprocess use of VBA?
Randall Rath

Christy Bailey

unread,
May 27, 1999, 3:00:00 AM5/27/99
to
First, I did try changing the event, but the same thing happens. (It never
gets to the event because the problem occurs where I try to make ThisDrawing
the Active Document).

I am running AutoCAD version 14.01.

I want to use VB over VBA because I am writing a VB application that I'm
calling a Project Manager. The user will be able to search for a project
and select it from Project Manager, and then they will have access to all
the project's files (dwg, doc, xls, etc.). Project Manager can open
drawings in AutoCAD and several other applications. Currently I am trying
to create a Batch plot that users can use from within my Project Manager.
It opens each drawing the user selects and then plots it. My problem is
that sometimes the "plot" command is sent before a drawing is finished
regenerating, so it doesn't plot and I end up with a blank screen. So I
figured if I could put the plot command in the EndOpen event, it would never
be sent before the drawing was completely opened. Does this make sense?

I'm out tomorrow, and won't be back until next Tuesday, but I'll definitely
check back then. Have a nice holiday, and thanks for all the help.

Christy Bailey

Randall Rath wrote in message <7ikbdc$po...@adesknews2.autodesk.com>...

0 new messages