Visual Basic Customization

Visual Basic Customization

Reply
*Brookman, Bill
Message 1 of 7 (52 Views)

Connecting to a2k using vb6

52 Views, 6 Replies
02-08-2000 05:58 PM
I'm tring to connect to autocad using vb6. I have tried the examples in the
newsgroups and from Autocad 2000 vba book. I think i am connecting, but I
cannot open a drawing or edit an existing drawing. The following is the
code I am using. I have included the reference to the acad2000 library.
Any Help?

Thanks,
Bill Brookman
bb@brookmangroup.com

Private Sub Command1_Click()
Dim objAcadApp As AcadApplication
Dim ThisDrawing As AcadDocument

Set objAcadApp = GetObject(, "AutoCAD.Application.15")
Set ThisDrawing = objAcadApp.ActiveDocument

ThisDrawing.Application.Documents.Open ("d:\test.dwg")

'ThisDrawing.ActiveDocument.ActiveViewport.ZoomExtents
'objAcadApp.ActiveDocument.Open "d:\test.dwg"
'objAcadApp.ActiveDocument.ActiveViewport.ZoomExtents

End Sub
*Oquendo, Frank
Message 2 of 7 (52 Views)

Re: Connecting to a2k using vb6

02-08-2000 06:06 PM in reply to: *Brookman, Bill
Watch out for that ThisDrawng thing. It only works properly in VBA, not VB.
The moment the active document is switched, ThisDrawing stops firing events.
Also, since you already have a refrence to the AutoCAD Application object,
it is redundant to access Application methods via the document reference.

Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument

Set acadApp = GetObject(, "AutoCAD.Application.15")
acadApp.Documents.Open "d:\test.dwg"
Set acadDoc = acadApp.ActiveDocument

--
Get free software and more at:
http://msnhomepages.talkcity.com/protectionfault/foquendo

"Bill Brookman" wrote in message
news:87qhf2$3nt16@adesknews2.autodesk.com...
> I'm tring to connect to autocad using vb6. I have tried the examples in
the
> newsgroups and from Autocad 2000 vba book. I think i am connecting, but I
> cannot open a drawing or edit an existing drawing. The following is the
> code I am using. I have included the reference to the acad2000 library.
> Any Help?
>
> Thanks,
> Bill Brookman
> bb@brookmangroup.com
>
>
>
> Private Sub Command1_Click()
> Dim objAcadApp As AcadApplication
> Dim ThisDrawing As AcadDocument
>
> Set objAcadApp = GetObject(, "AutoCAD.Application.15")
> Set ThisDrawing = objAcadApp.ActiveDocument
>
> ThisDrawing.Application.Documents.Open ("d:\test.dwg")
>
>
> 'ThisDrawing.ActiveDocument.ActiveViewport.ZoomExtents
> 'objAcadApp.ActiveDocument.Open "d:\test.dwg"
> 'objAcadApp.ActiveDocument.ActiveViewport.ZoomExtents
>
>
> End Sub
>
>
>
*Brookman, Bill
Message 3 of 7 (52 Views)

Re:

02-08-2000 06:39 PM in reply to: *Brookman, Bill
I tried the code, but it didn't work. I followed each line in the debug.
The open line took longer than the rest, but the file didn't open. I have
autocad running.
???

Frank Oquendo wrote in message
news:87qi9t$3n815@adesknews2.autodesk.com...
> Watch out for that ThisDrawng thing. It only works properly in VBA, not
VB.
> The moment the active document is switched, ThisDrawing stops firing
events.
> Also, since you already have a refrence to the AutoCAD Application object,
> it is redundant to access Application methods via the document reference.
>
> Dim acadApp As AcadApplication
> Dim acadDoc As AcadDocument
>
> Set acadApp = GetObject(, "AutoCAD.Application.15")
> acadApp.Documents.Open "d:\test.dwg"
> Set acadDoc = acadApp.ActiveDocument
>
> --
> Get free software and more at:
> http://msnhomepages.talkcity.com/protectionfault/foquendo
>
>
> "Bill Brookman" wrote in message
> news:87qhf2$3nt16@adesknews2.autodesk.com...
> > I'm tring to connect to autocad using vb6. I have tried the examples in
> the
> > newsgroups and from Autocad 2000 vba book. I think i am connecting, but
I
> > cannot open a drawing or edit an existing drawing. The following is the
> > code I am using. I have included the reference to the acad2000 library.
> > Any Help?
> >
> > Thanks,
> > Bill Brookman
> > bb@brookmangroup.com
> >
> >
> >
> > Private Sub Command1_Click()
> > Dim objAcadApp As AcadApplication
> > Dim ThisDrawing As AcadDocument
> >
> > Set objAcadApp = GetObject(, "AutoCAD.Application.15")
> > Set ThisDrawing = objAcadApp.ActiveDocument
> >
> > ThisDrawing.Application.Documents.Open ("d:\test.dwg")
> >
> >
> > 'ThisDrawing.ActiveDocument.ActiveViewport.ZoomExtents
> > 'objAcadApp.ActiveDocument.Open "d:\test.dwg"
> > 'objAcadApp.ActiveDocument.ActiveViewport.ZoomExtents
> >
> >
> > End Sub
> >
> >
> >
>
>
*Brookman, Bill
Message 4 of 7 (52 Views)

Re:

02-08-2000 07:02 PM in reply to: *Brookman, Bill
I found my error. Had the open statement before setting the active document.

Thanks for your help.

This will get me started with vb!

Bill Brookman wrote in message
news:87qjre$3n527@adesknews2.autodesk.com...
> I tried the code, but it didn't work. I followed each line in the debug.
> The open line took longer than the rest, but the file didn't open. I have
> autocad running.
> ???
>
>
> Frank Oquendo wrote in message
> news:87qi9t$3n815@adesknews2.autodesk.com...
> > Watch out for that ThisDrawng thing. It only works properly in VBA, not
> VB.
> > The moment the active document is switched, ThisDrawing stops firing
> events.
> > Also, since you already have a refrence to the AutoCAD Application
object,
> > it is redundant to access Application methods via the document
reference.
> >
> > Dim acadApp As AcadApplication
> > Dim acadDoc As AcadDocument
> >
> > Set acadApp = GetObject(, "AutoCAD.Application.15")
> > acadApp.Documents.Open "d:\test.dwg"
> > Set acadDoc = acadApp.ActiveDocument
> >
> > --
> > Get free software and more at:
> > http://msnhomepages.talkcity.com/protectionfault/foquendo
> >
> >
> > "Bill Brookman" wrote in message
> > news:87qhf2$3nt16@adesknews2.autodesk.com...
> > > I'm tring to connect to autocad using vb6. I have tried the examples
in
> > the
> > > newsgroups and from Autocad 2000 vba book. I think i am connecting,
but
> I
> > > cannot open a drawing or edit an existing drawing. The following is
the
> > > code I am using. I have included the reference to the acad2000
library.
> > > Any Help?
> > >
> > > Thanks,
> > > Bill Brookman
> > > bb@brookmangroup.com
> > >
> > >
> > >
> > > Private Sub Command1_Click()
> > > Dim objAcadApp As AcadApplication
> > > Dim ThisDrawing As AcadDocument
> > >
> > > Set objAcadApp = GetObject(, "AutoCAD.Application.15")
> > > Set ThisDrawing = objAcadApp.ActiveDocument
> > >
> > > ThisDrawing.Application.Documents.Open ("d:\test.dwg")
> > >
> > >
> > > 'ThisDrawing.ActiveDocument.ActiveViewport.ZoomExtents
> > > 'objAcadApp.ActiveDocument.Open "d:\test.dwg"
> > > 'objAcadApp.ActiveDocument.ActiveViewport.ZoomExtents
> > >
> > >
> > > End Sub
> > >
> > >
> > >
> >
> >
>
>
*Sutphin, Joe
Message 5 of 7 (52 Views)

Re:

02-09-2000 03:46 AM in reply to: *Brookman, Bill
Bill,

The first issue of Sources contains an article about handling the Document
level events that
Frank eluded to in his post reply.

Joe Sutphin
Author of "AutoCAD 2000 VBA Programmers Reference"
ISBN #1861002564

Checkout Sources - The magazine dedicated to AutoCAD customization
http://vbdesign.hypermart.net/sources/

Bill Brookman wrote in message
news:87ql6r$3nb15@adesknews2.autodesk.com...
> I found my error. Had the open statement before setting the active
document.
>
> Thanks for your help.
>
> This will get me started with vb!
>
>
>
> Bill Brookman wrote in message
> news:87qjre$3n527@adesknews2.autodesk.com...
> > I tried the code, but it didn't work. I followed each line in the
debug.
> > The open line took longer than the rest, but the file didn't open. I
have
> > autocad running.
> > ???
> >
> >
> > Frank Oquendo wrote in message
> > news:87qi9t$3n815@adesknews2.autodesk.com...
> > > Watch out for that ThisDrawng thing. It only works properly in VBA,
not
> > VB.
> > > The moment the active document is switched, ThisDrawing stops firing
> > events.
> > > Also, since you already have a refrence to the AutoCAD Application
> object,
> > > it is redundant to access Application methods via the document
> reference.
> > >
> > > Dim acadApp As AcadApplication
> > > Dim acadDoc As AcadDocument
> > >
> > > Set acadApp = GetObject(, "AutoCAD.Application.15")
> > > acadApp.Documents.Open "d:\test.dwg"
> > > Set acadDoc = acadApp.ActiveDocument
> > >
> > > --
> > > Get free software and more at:
> > > http://msnhomepages.talkcity.com/protectionfault/foquendo
> > >
> > >
> > > "Bill Brookman" wrote in message
> > > news:87qhf2$3nt16@adesknews2.autodesk.com...
> > > > I'm tring to connect to autocad using vb6. I have tried the
examples
> in
> > > the
> > > > newsgroups and from Autocad 2000 vba book. I think i am connecting,
> but
> > I
> > > > cannot open a drawing or edit an existing drawing. The following is
> the
> > > > code I am using. I have included the reference to the acad2000
> library.
> > > > Any Help?
> > > >
> > > > Thanks,
> > > > Bill Brookman
> > > > bb@brookmangroup.com
> > > >
> > > >
> > > >
> > > > Private Sub Command1_Click()
> > > > Dim objAcadApp As AcadApplication
> > > > Dim ThisDrawing As AcadDocument
> > > >
> > > > Set objAcadApp = GetObject(, "AutoCAD.Application.15")
> > > > Set ThisDrawing = objAcadApp.ActiveDocument
> > > >
> > > > ThisDrawing.Application.Documents.Open ("d:\test.dwg")
> > > >
> > > >
> > > > 'ThisDrawing.ActiveDocument.ActiveViewport.ZoomExtents
> > > > 'objAcadApp.ActiveDocument.Open "d:\test.dwg"
> > > > 'objAcadApp.ActiveDocument.ActiveViewport.ZoomExtents
> > > >
> > > >
> > > > End Sub
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
*Adam, Claire
Message 6 of 7 (52 Views)

Re: Connecting to a2k using vb6

02-09-2000 05:56 AM in reply to: *Brookman, Bill
Dear Bill,

I have used VB6 with AutoCAD and I found the facility.vbp example that
shipped with Acad2000 and 14 extremely useful to start off.

Check ACAD2000\Sample\activeX\Facility\facility.vbp
or AutoCADR14\Sample\ActiveX\facility\facility.vbp

It shows hoe to connect to AutoCAD from a standalone VB exe and some of the
main differences in code between VB and vba(ACAD)

cheers
claire
*McDowell, John
Message 7 of 7 (52 Views)

Re: Connecting to a2k using vb6

03-14-2000 10:55 AM in reply to: *Brookman, Bill
Use this line to open AutoCad session
Set objAcad = CreateObject("Autocad.Application")

Use this line to acquire an existing AutoCad session
Set objAcadApp = GetObject(, "AutoCAD.Application")

Check this line of your code as "ThisDrawing" is already the ActiveDocument
'ThisDrawing.ActiveDocument.ActiveViewport.ZoomExtents
Set ThisDrawing = objAcadApp.ActiveDocument

Hope this helps

Bill Brookman wrote in message <87qhf2$3nt16@adesknews2.autodesk.com>...
>I'm tring to connect to autocad using vb6. I have tried the examples in
the
>newsgroups and from Autocad 2000 vba book. I think i am connecting, but I
>cannot open a drawing or edit an existing drawing. The following is the
>code I am using. I have included the reference to the acad2000 library.
>Any Help?
>
>Thanks,
>Bill Brookman
>bb@brookmangroup.com
>
>
>
>Private Sub Command1_Click()
>Dim objAcadApp As AcadApplication
>Dim ThisDrawing As AcadDocument
>
>Set objAcadApp = GetObject(, "AutoCAD.Application.15")
>Set ThisDrawing = objAcadApp.ActiveDocument
>
>ThisDrawing.Application.Documents.Open ("d:\test.dwg")
>
>
>'ThisDrawing.ActiveDocument.ActiveViewport.ZoomExtents
>'objAcadApp.ActiveDocument.Open "d:\test.dwg"
>'objAcadApp.ActiveDocument.ActiveViewport.ZoomExtents
>
>
>End Sub
>
>
>
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.