GetPlotDeviceNames

GetPlotDeviceNames

Anonymous
Not applicable
654 Views
3 Replies
Message 1 of 4

GetPlotDeviceNames

Anonymous
Not applicable
I'm new to using VBA within AutoCAD and could do witha friendly pointer to get me started on a particular aspect.

I have a routine which I use for carrying specific plot tasks which I have written in LISP. I want to port this into VBA as a trial run but have met my first stumbling block. I have a form which lists all available AutoCAD plotters. In my LISP version, I then strip this list so that the dialog only displays the PC3 plotters and not Windows plotters. In LISP this is easy enough to step through each item in the text list and do a compare but in VBA I'm struggling to do the same.

Is the list produced by Layout.GetPlotDeviceNames in the form of a text list or something else? As I've said, I'm coming at this as a complete newbie and my LISP thinking keeps getting in the way.

Any pointers on the best way to achieve a list of just PC3 files would be greatly appreciated. I'm sure once I get a grip on this one aspect, a light should turn on and things should becomes a bit clearer.... hopefully!
0 Likes
655 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Here's one way:

Sub test()
Dim oLayout As AcadLayout
Dim sDevices As Variant
Dim sPC3() As String
Dim i As Integer, j As Integer

Set oLayout = ThisDrawing.Layouts.Item("Layout1")
sDevices = oLayout.GetPlotDeviceNames
ReDim sPC3(0 To UBound(sDevices) - 1)
For i = 0 To UBound(sDevices)
If UCase(sDevices(i)) Like "*.PC3" Then
sPC3(j) = sDevices(i)
j = j + 1
End If
Next i
ReDim Preserve sPC3(0 To j - 1)
For i = 0 To j - 1
Debug.Print sPC3(i)
Next
End Sub

wrote in message news:[email protected]...
I'm new to using VBA within AutoCAD and could do witha friendly pointer to
get me started on a particular aspect.

I have a routine which I use for carrying specific plot tasks which I have
written in LISP. I want to port this into VBA as a trial run but have met my
first stumbling block. I have a form which lists all available AutoCAD
plotters. In my LISP version, I then strip this list so that the dialog only
displays the PC3 plotters and not Windows plotters. In LISP this is easy
enough to step through each item in the text list and do a compare but in
VBA I'm struggling to do the same.

Is the list produced by Layout.GetPlotDeviceNames in the form of a text list
or something else? As I've said, I'm coming at this as a complete newbie and
my LISP thinking keeps getting in the way.

Any pointers on the best way to achieve a list of just PC3 files would be
greatly appreciated. I'm sure once I get a grip on this one aspect, a light
should turn on and things should becomes a bit clearer.... hopefully!
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thanks Jeff.

Does exactly what I want in a way I can understand.

Much appreciated.
0 Likes
Message 4 of 4

Anonymous
Not applicable
Here something that might help.

Joe
--

Public Sub GetPaperSizesAndNames()
Dim Layout As AcadLayout
Dim Width As Double
Dim Height As Double
Dim Margins As Variant
Dim MediaNames As Variant
Dim PlotDeviceNames As Variant

With ThisDrawing
.ActiveSpace = acPaperSpace
Set Layout = .ActiveLayout
End With

With Layout
MediaNames = .GetCanonicalMediaNames
Dim Index As Integer
For Index = 0 To UBound(MediaNames) - 1
.CanonicalMediaName = MediaNames(Index)
'get the current paper size
.GetPaperSize Width, Height
'format it to english units - AutoCAD returns the number in metric
Width = Format(Width, "0000.0") / 25.4: Height = Format(Height,
"0000.0") / 25.4
Debug.Print .CanonicalMediaName & vbTab & "Width: " & Width & vbTab &
"Height: " & Height
'Debug.Print MediaNames(index)
Next Index

'display plot device names
PlotDeviceNames = .GetPlotDeviceNames

For Index = 0 To UBound(PlotDeviceNames) - 1
Debug.Print "PlotDevice: " & PlotDeviceNames(Index)
Next Index
End With

With ThisDrawing
.ActiveSpace = acModelSpace
Set Layout = .ActiveLayout
End With
End Sub


wrote in message news:[email protected]...
I'm new to using VBA within AutoCAD and could do witha friendly pointer to
get me started on a particular aspect.

I have a routine which I use for carrying specific plot tasks which I have
written in LISP. I want to port this into VBA as a trial run but have met my
first stumbling block. I have a form which lists all available AutoCAD
plotters. In my LISP version, I then strip this list so that the dialog only
displays the PC3 plotters and not Windows plotters. In LISP this is easy
enough to step through each item in the text list and do a compare but in
VBA I'm struggling to do the same.

Is the list produced by Layout.GetPlotDeviceNames in the form of a text list
or something else? As I've said, I'm coming at this as a complete newbie and
my LISP thinking keeps getting in the way.

Any pointers on the best way to achieve a list of just PC3 files would be
greatly appreciated. I'm sure once I get a grip on this one aspect, a light
should turn on and things should becomes a bit clearer.... hopefully!
0 Likes