View Full Version : VB Open Multiple CAD Drawings
LouDog
01-13-2005, 11:55 AM
I am a VB beginner looking for some assistance.
I am trying to develop a code that can open multiple dwg's and plot
them using my defined Page-setups. I manage to get VB to open a single
dwg file in a defined location (C:\temp) but I cannot make VB to open
multiple drawings. How can I accomplish this?
Any suggestions will be greatly appreciated. I am running AutoCAD 2002
and VB-6.
Private Sub CmdRun_Click()
Dim acad As AutoCAD.AcadApplication
Dim dwg As AcadDocument
Set acad = New AutoCAD.AcadApplication
acad.Visible = False
Set dwg = acad.Documents.Open("c:\temp\007.dwg")
dwg.Close True
acad.Quit
End Sub
Thanks,
LouDog
I do this through Excel In Excel I keep a list of Drawing numbers that are
in structured storage
The code develops the path and opens the drawing prints it and closes the
drawing then moves on to the next dwg.
Try this
Private Sub CmdRun_Click()
Dim i As Variant
Dim DwgList As New Collection
Dim FileName As String
Dim acad As AutoCAD.AcadApplication
Dim dwg As AcadDocument
FileName = "C:\Temp1.dwg"
DwgList.Add FileName
FileName = "C:\Temp2.dwg"
DwgList.Add FileName
FileName = "C:\Temp3.dwg"
DwgList.Add FileName
FileName = "C:\Temp4.dwg"
DwgList.Add FileName
FileName = "C:\Temp5.dwg"
DwgList.Add FileName
Set acad = New AutoCAD.AcadApplication
acad.Visible = False
For Each i In DwgList
'loop through the drawings open them if successful tell the user
Set dwg = Nothing
On Error Resume Next
Set dwg = acad.Documents.Open(i)
On Error GoTo 0
If dwg Is Nothing Then
MsgBox "Failed to open " & i
Else
MsgBox "Opened " & i
'code here to use your print settings
dwg.Close True
End If
Next
acad.Quit
End Sub
"LouDog" <LOUDOGG5150@YAHOO.COM> wrote in message
news:1105646123.067683.186010@f14g2000cwb.googlegroups.com... I am a VB beginner looking for some assistance. I am trying to develop a code that can open multiple dwg's and plot them using my defined Page-setups. I manage to get VB to open a single dwg file in a defined location (C:\temp) but I cannot make VB to open multiple drawings. How can I accomplish this? Any suggestions will be greatly appreciated. I am running AutoCAD 2002 and VB-6. Private Sub CmdRun_Click() Dim acad As AutoCAD.AcadApplication Dim dwg As AcadDocument Set acad = New AutoCAD.AcadApplication acad.Visible = False Set dwg = acad.Documents.Open("c:\temp\007.dwg") dwg.Close True acad.Quit End Sub Thanks, LouDog
Johan Bechthum
01-13-2005, 01:29 PM
What do you mean by "open multiple drawings" ?
If you want to open several drawings at the same time, you can use the .Open
method mor than ione time:
=====================================
Dim acad As AutoCAD.AcadApplication
Dim dwg(1 To 10) As AutoCAD.AcadDocument
Set acad = New AutoCAD.AcadApplication
acad.Visible = False
Set dwg(7) = acad.Documents.Open("c:\temp\007.dwg")
Set dwg(9) = acad.Documents.Open("c:\temp\077.dwg")
Set dwg(2) = acad.Documents.Open("c:\temp\707.dwg")
Set dwg(4) = acad.Documents.Open("c:\temp\770.dwg")
dwg(9).Close True
dwg(4).Close True
dwg(7).Close True
dwg(2).Close True
acad.Quit
=====================================
Hope this helps.
Johan.
"LouDog" <LOUDOGG5150@YAHOO.COM> schreef in bericht
news:1105646123.067683.186010@f14g2000cwb.googlegroups.com... I am a VB beginner looking for some assistance. I am trying to develop a code that can open multiple dwg's and plot them using my defined Page-setups. I manage to get VB to open a single dwg file in a defined location (C:\temp) but I cannot make VB to open multiple drawings. How can I accomplish this? Any suggestions will be greatly appreciated. I am running AutoCAD 2002 and VB-6. Private Sub CmdRun_Click() Dim acad As AutoCAD.AcadApplication Dim dwg As AcadDocument Set acad = New AutoCAD.AcadApplication acad.Visible = False Set dwg = acad.Documents.Open("c:\temp\007.dwg") dwg.Close True acad.Quit End Sub Thanks, LouDog
Suda Nym
01-13-2005, 05:57 PM
Check out my AutoCAD class:
http://www.veign.com/vrc_codeview.asp?type=app&id=11
It will make opening drawings and setting plotting options, and plotting a
breeze...
--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--
"LouDog" <LOUDOGG5150@YAHOO.COM> wrote in message
news:1105646123.067683.186010@f14g2000cwb.googlegroups.com... I am a VB beginner looking for some assistance. I am trying to develop a code that can open multiple dwg's and plot them using my defined Page-setups. I manage to get VB to open a single dwg file in a defined location (C:\temp) but I cannot make VB to open multiple drawings. How can I accomplish this? Any suggestions will be greatly appreciated. I am running AutoCAD 2002 and VB-6. Private Sub CmdRun_Click() Dim acad As AutoCAD.AcadApplication Dim dwg As AcadDocument Set acad = New AutoCAD.AcadApplication acad.Visible = False Set dwg = acad.Documents.Open("c:\temp\007.dwg") dwg.Close True acad.Quit End Sub Thanks, LouDog
MyLounge.com Site Map
Forum:
Cars,
Cell Phone,
Database,
Games,
Home Improvement,
IT,
Music,
School,
Sports,
Web Design,
Web Server,
Weight Loss
The MyLounge.com forum is intended for informational use only and should not
be relied upon and is not a substitute for any advice. The information contained
on MyLounge.com are opinions and suggestions of members and is not a representation
of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for
the accuracy, completeness or usefulness of any postings or the qualifications
of any person responding. Please consult a expert or seek the services of an
attorney in your area for more accuracy on your specific situation. Please note
that our forums also serve as mirrors to Usenet newsgroups. Many posts you see
on our forums are made by newsgroup users who may not be members of MyLounge.com
Term of Service
vBulletin v3.0.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.