VB6 and AutoCAD

VB6 and AutoCAD

Anonymous
Not applicable
721 Views
6 Replies
Message 1 of 7

VB6 and AutoCAD

Anonymous
Not applicable
Hello,

I'm new to using VB6 in AutoCAD, but not new to using VB6.
How do I run AutoCAD commands in VB6? Is there some Active X control or DLL
that I need to load in order to use VB6 (not VBA) to run AutoCAD?

Thanks in advance!
0 Likes
722 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Doug, Just make sure you have a reference set to the AutoCad type library,
and you are good to go, of course you must have acad installed on the same
machine.

Regards,
Jacob Dinardi


Doug Cochran wrote in message
news:84DAD03D6C06A7FE3D2C5D4FF3810B7C@in.WebX.maYIadrTaRb...
Hello,

I'm new to using VB6 in AutoCAD, but not new to using VB6.
How do I run AutoCAD commands in VB6? Is there some Active X control or DLL
that I need to load in order to use VB6 (not VBA) to run AutoCAD?

Thanks in advance!
0 Likes
Message 3 of 7

Anonymous
Not applicable
Thanks Jacob,

Forgive me for sounding "dense" but just how do I set this reference?

Would it be something like "Set Acad = GetObject(, "AutoCAD.Application")"
Where would this reference be placed i.e. as a public sub or private??!!!
An example code would be nice!

thanks again


"Jacob Dinardi" wrote in message
news:FE2EE7B0ACBA63E7AB6D577AC676ACB2@in.WebX.maYIadrTaRb...
> Doug, Just make sure you have a reference set to the AutoCad type library,
> and you are good to go, of course you must have acad installed on the same
> machine.
>
> Regards,
> Jacob Dinardi
>
>
> Doug Cochran wrote in message
> news:84DAD03D6C06A7FE3D2C5D4FF3810B7C@in.WebX.maYIadrTaRb...
> Hello,
>
> I'm new to using VB6 in AutoCAD, but not new to using VB6.
> How do I run AutoCAD commands in VB6? Is there some Active X control or
DLL
> that I need to load in order to use VB6 (not VBA) to run AutoCAD?
>
> Thanks in advance!
>
>
>
>
0 Likes
Message 4 of 7

Anonymous
Not applicable
"To do this in VB, select the References option from the Project menu to
launch the Reference dialog box. From the References dialog box, choose
AutoCAD Release 15 Type Library and press OK."

Sub Ch2_ConnectToAcad()
Dim acadApp As AcadApplication
On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
MsgBox "Now running " + acadApp.Name + _
" version " + acadApp.Version
End Sub

For more, see AutoCAD Online Manuals:
ActiveX and VBA Developers Guide
Ch. 2 - Understanding ActiveX Automation Basics
Using Other Programming Languages
Converting VBA Code to VB
Connecting to AutoCAD from Visual Basic
--
John Goodfellow
irtf'nm
use 'microtouch' in address to email

"Doug Cochran" wrote in message
news:E68A93872F4A5A219E0DA6E8755B3A99@in.WebX.maYIadrTaRb...
> Thanks Jacob,
>
> Forgive me for sounding "dense" but just how do I set this reference?
>
> Would it be something like "Set Acad = GetObject(,
"AutoCAD.Application")"
> Where would this reference be placed i.e. as a public sub or private??!!!
> An example code would be nice!
>
> thanks again
>
>
> "Jacob Dinardi" wrote in message
> news:FE2EE7B0ACBA63E7AB6D577AC676ACB2@in.WebX.maYIadrTaRb...
> > Doug, Just make sure you have a reference set to the AutoCad type
library,
> > and you are good to go, of course you must have acad installed on the
same
> > machine.
> >
> > Regards,
> > Jacob Dinardi
> >
> >
> > Doug Cochran wrote in message
> > news:84DAD03D6C06A7FE3D2C5D4FF3810B7C@in.WebX.maYIadrTaRb...
> > Hello,
> >
> > I'm new to using VB6 in AutoCAD, but not new to using VB6.
> > How do I run AutoCAD commands in VB6? Is there some Active X control or
> DLL
> > that I need to load in order to use VB6 (not VBA) to run AutoCAD?
> >
> > Thanks in advance!
> >
> >
> >
> >
>
>
0 Likes
Message 5 of 7

Anonymous
Not applicable
Thank you very much for shedding some light on this subject!
It worked!

Doug


"John Goodfellow" wrote in message
news:2D8B8F5CB6851D5BCC9F73AEBEFDA71E@in.WebX.maYIadrTaRb...
> "To do this in VB, select the References option from the Project menu to
> launch the Reference dialog box. From the References dialog box, choose
> AutoCAD Release 15 Type Library and press OK."
>
> Sub Ch2_ConnectToAcad()
> Dim acadApp As AcadApplication
> On Error Resume Next
> Set acadApp = GetObject(, "AutoCAD.Application")
> If Err Then
> Err.Clear
> Set acadApp = CreateObject("AutoCAD.Application")
> If Err Then
> MsgBox Err.Description
> Exit Sub
> End If
> End If
> MsgBox "Now running " + acadApp.Name + _
> " version " + acadApp.Version
> End Sub
>
> For more, see AutoCAD Online Manuals:
> ActiveX and VBA Developers Guide
> Ch. 2 - Understanding ActiveX Automation Basics
> Using Other Programming Languages
> Converting VBA Code to VB
> Connecting to AutoCAD from Visual Basic
> --
> John Goodfellow
> irtf'nm
> use 'microtouch' in address to email
>
> "Doug Cochran" wrote in message
> news:E68A93872F4A5A219E0DA6E8755B3A99@in.WebX.maYIadrTaRb...
> > Thanks Jacob,
> >
> > Forgive me for sounding "dense" but just how do I set this reference?
> >
> > Would it be something like "Set Acad = GetObject(,
> "AutoCAD.Application")"
> > Where would this reference be placed i.e. as a public sub or
private??!!!
> > An example code would be nice!
> >
> > thanks again
> >
> >
> > "Jacob Dinardi" wrote in message
> > news:FE2EE7B0ACBA63E7AB6D577AC676ACB2@in.WebX.maYIadrTaRb...
> > > Doug, Just make sure you have a reference set to the AutoCad type
> library,
> > > and you are good to go, of course you must have acad installed on the
> same
> > > machine.
> > >
> > > Regards,
> > > Jacob Dinardi
> > >
> > >
> > > Doug Cochran wrote in message
> > > news:84DAD03D6C06A7FE3D2C5D4FF3810B7C@in.WebX.maYIadrTaRb...
> > > Hello,
> > >
> > > I'm new to using VB6 in AutoCAD, but not new to using VB6.
> > > How do I run AutoCAD commands in VB6? Is there some Active X control
or
> > DLL
> > > that I need to load in order to use VB6 (not VBA) to run AutoCAD?
> > >
> > > Thanks in advance!
> > >
> > >
> > >
> > >
> >
> >
>
0 Likes
Message 6 of 7

Anonymous
Not applicable
Hai Doug Cochran,

I have a solution for your doubt, you can easily call autocad using vb6,
just you have to do some settings first

Please follow this

1. Open Vb6 and in Format menu click on References, Reference dialogue box
opens.
2. Select Autocad 2000 type Library
3. Apply and close the reference dialogue box.

Now open your form and add this code this will open Autocad, and you can
generate drawings same as in vba.

Private Sub command_click()
Dim myApp As AcadApplication
Dim acad As AcadDocument
Set myApp = CreateObject("AutoCAD.Application")
myApp.WindowState = acMax
myApp.ActiveDocument.WindowState = acMax
myApp.ActiveDocument.Width = 725
myApp.ActiveDocument.Height = 375
myApp.ActiveDocument.SendCommand "circle" & vbcr & "0,0" & vbcr & "5"& vbCr
End sub

I hope this will solve your problem,

Please mail back if you need any further help


thanking you
surender rao karanam
Regency Infotech pvt.ltd
#7-1-59/6, dharam karan road
Ameerpet, Hyderabad
Andhra pradesh
India
Pin 500016


Doug Cochran wrote in message
news:84DAD03D6C06A7FE3D2C5D4FF3810B7C@in.WebX.maYIadrTaRb...
> Hello,
>
> I'm new to using VB6 in AutoCAD, but not new to using VB6.
> How do I run AutoCAD commands in VB6? Is there some Active X control or
DLL
> that I need to load in order to use VB6 (not VBA) to run AutoCAD?
>
> Thanks in advance!
>
>
0 Likes
Message 7 of 7

Anonymous
Not applicable
this code writtin by karanam, is general code whatever version of autocad i am using, version of autocad is defind in the refrences list only or needs to be there within the code itself also, because this code didnt wok when i tried to use it with autocad 2008, although i choosed autocad 2008 type library.
0 Likes