Thanks,
jake
thanks,
-Josh
jake
Jacob Dinardi wrote in message <7nd6lr$ij...@adesknews2.autodesk.com>...
I'm not sure to understand the question but it looks like someone is trying
to set the papersize with the GetPaperSize method instead of using the
CanonicalMediaName property. Maybe the help file could be more specific on
the possible values of this property?
Note that the only bug I'm aware of is that the GetPaperSize method does not
seem to consider the PaperUnits value and always returns millimeters (on our
systems it may depend of the Reg. Settings).
Maybe this piece of code will help you to fix your plotting routine:
'----------------------------------------
' This example sets the name of the
' media for the active layout to A3
' and retrieves the papersize
' DGagne 99-09-27
Sub SetPaperSize()
Dim PaperWidth As Double
Dim PaperHeight As Double
Dim MediaName As String
MediaName = "A3"
With ThisDrawing.ActiveLayout
.CanonicalMediaName = MediaName
.PaperUnits = acInches 'Try to set units to inches
.GetPaperSize PaperWidth, PaperHeight
End With
' Even if you want inches
' you'll get millimeters #@?&!
MsgBox "The media for the active layout is: " & _
MediaName & Chr(10) & "The papersize is " & _
CStr(PaperWidth) & "mm X " _
& CStr(PaperHeight) & "mm"
ThisDrawing.Regen acActiveViewport
End Sub
'----------------------------------------
Salutations,
Denis
Private Sub MyDevice()
Dim PaperWidth As Double
Dim PaperHeight As Double
With ThisDrawing
If PrinterBox.Text = "Laserjet" Then
.ActiveLayout.ConfigName = "HP Laserjet 5L PCL"
PaperWidth = 8.5
PaperHeight = 11
.ActiveLayout.GetPaperSize PaperWidth, PaperHeight
ElseIf PrinterBox.Text = "Cannon" Then
.ActiveLayout.ConfigName = "Canon Bubble-Jet BJC-4550"
PaperWidth = 8
PaperHeight = 6
.ActiveLayout.GetPaperSize PaperWidth, PaperHeight
ElseIf PrinterBox.Text = "Plotter" Then
.ActiveLayout.ConfigName = "DesignJet 600.pc3"
.ActiveLayout.GetPaperSize 35.5, 120#
End If
End With
End Sub
Cheers,
jake
Minkwitz Design Service wrote in message <379E2EF3...@xta.com>...
p.s.- there is also acPlotPaperUnits, which I haven't reviewed yet.
"Denis Gagné" wrote:
> Hi all,
>
> I'm not sure to understand the question but it looks like someone is trying
> to set the papersize with the GetPaperSize method instead of using the
> CanonicalMediaName property. Maybe the help file could be more specific on
> the possible values of this property?
>
> Note that the only bug I'm aware of is that the GetPaperSize method does not
> seem to consider the PaperUnits value and always returns millimeters (on our
> systems it may depend of the Reg. Settings).
>
> Maybe this piece of code will help you to fix your plotting routine:
>
> '----------------------------------------
> ' This example sets the name of the
> ' media for the active layout to A3
> ' and retrieves the papersize
> ' DGagne 99-09-27
> Sub SetPaperSize()
> Dim PaperWidth As Double
> Dim PaperHeight As Double
From AutoCAD help file:
All ActiveX Automation properties are represented in millimeters or radians,
regardless of the units settings.
Denis
Private Sub MyDevice()
Dim PaperWidth As Double
Dim PaperHeight As Double
Dim MediaName As String
With ThisDrawing.ActiveLayout
If PrinterBox.Text = "Laserjet" Then
.ConfigName = "HP Laserjet 5L PCL"
PaperWidth = 8.5
PaperHeight = 11
.GetPaperSize PaperWidth, PaperHeight
MediaName = "Letter"
ElseIf PrinterBox.Text = "Cannon" Then
.ConfigName = "Canon Bubble-Jet BJC-4550"
PaperWidth = 11
PaperHeight = 17
.GetPaperSize PaperWidth, PaperHeight
MediaName = "Legal"
ElseIf PrinterBox.Text = "Plotter" Then
.ConfigName = "DesignJet 600.pc3"
PaperWidth = 35.5
PaperHeight = 120
.GetPaperSize PaperWidth, PaperHeight
MediaName = "ANSI E"
End If
.CanonicalMediaName = MediaName
End With
End Sub
-Josh
With ThisDrawing.ActiveLayout
If PrinterBox.Text = "Laserjet" Then
.ConfigName = "HP Laserjet
5L PCL"
MediaName = "Letter" 'this works
ElseIf PrinterBox.Text = "Cannon" Then
.ConfigName = "Canon Bubble-Jet
BJC-4550"
MediaName = "User-defined size" 'this does not, I can't set MediaName to a user-defined size
ElseIf PrinterBox.Text = "Plotter" Then
.ConfigName = "DesignJet
600.pc3"
MediaName = "ANSI E"
'this does not work either, I can't set MediaName
at all if ConfigName is a pc3 file instead of a windows printer
End If
.CanonicalMediaName = MediaName
End With
End Sub
If I run the code just as you see it, I get an "invalid input" error with either of the last two options. GetPaperSize is commented out in my code. Looking at your code, I'm assuming that you are able to set ConfigName to a pc3, which puts me at a loss as to what I'm doing wrong. I even tried changing the default paper size in my pc3. If you see the error of my ways, please let me know. If not, suggestions are welcome.
-Josh
"Denis Gagné" wrote:
Josh - I'm afraid you do not use the GetPaperSize
method the way it should be. You don't even need this method to set the
paper size but only to check what it is.First set the Config (plotter device and paper)
then you can use the GetPaperSize method if neededHere's a complete example that shows the sequence you should follow:
'----------------------------------------
' This example sets the name
' of the Config plotter to
' DWF Classic.pc3
' and the name of the
' media for the active layout to
' ANSI_B_(17.00_x_11.00_Inches)
' Then it checks the papersize in mm
' DGagne 99-09-28
Sub SetPaperSize()
Dim PaperWidth As Double
Dim PaperHeight As Double
Dim MediaName As String
MediaName = "ANSI_B_(17.00_x_11.00_Inches)"
With ThisDrawing.ActiveLayout
.ConfigName = "DWF Classic.pc3"
.CanonicalMediaName = MediaName
.GetPaperSize PaperWidth, PaperHeight
End With
' Even if you specify inches
' you'll always get millimeters
MsgBox "The media for the active layout is: " & _
MediaName & Chr(10) & "The papersize is " & _
CStr(PaperWidth) & "mm X " _
& CStr(PaperHeight) & "mm"
ThisDrawing.Regen acActiveViewport
End Sub
'----------------------------------------Denis
Minkwitz Design Service a écrit dans le message
<379F3746...@xta.com>...
'
'TO DISPLAY SIZES IN A COMBO BOX
'
Size = myPlotConfig.GetCannonIcalMediaNames()
i = 0
For i = LBound(Size) to UBound(Size)
frmMain.cboSize.AddItem myPlotConfig.GetLocaleMediaName(Size(i))
Next i
'
'TO SET SIZES
'
myPlotConfig.CannonIcalMediaName = Size(frmMain.cboSize.ListIndex)
There may be a better way to do it this is how I figured it out though. It
works. Anyway check this out guys... In the past month of struggling with
this problem this is what I have figured out. There are 3 ways to plot
basicly.
1.Create a layout object.
2.Create a PlotConfiguration object
3.Use "ThisDrawing.blah.blah.blah"
Anyway you look at it, it's all about the same. I have just been trying to
plot from model space so far (mainly). Today by chance I was working on my
plot interface while I had a drawing open with some user-defined
configurations. Now when I went to plot my drawing later (using ACAD) I
wanted to add a new configuration for a small laserjet plotter, with a scale
to fit setting. Inside the add dialog box, there was my plot configuration
name from my interface, except it was attached to "Layout", not "Model". So
I got all excited and went back to work on my plotting interface. No matter
what I do though I cannot create the plot configuration attached to model
space. And to top that off, it still plots incorrectly in paperspace (layout
whatever) I believe this has something to do with it all. I found an
interesting help topic in the vba developers guide under plotting... "When
you plot from model space, the defaults that are used, IF THERE ARE NO
SETTINGS SPECIFIED, include plot to system printer, plot the current
display, scaled to fit, 0 rotation, and 0 origin. To modify the plot
settings change the LAYOUT OBJECT ASSOCIATED TO MODEL SPACE." I'm sick of
all this crap. Someone help!
jake
Minkwitz Design Service wrote in message <379F8140...@xta.com>...
The trouble I was having had to do with the 'Invalid Input' error when
I tried to set any of the plot configuration parameters for the FIRST
TIME in a CAD session.
If I began a brand new AutoCAD session and tried to run my code, it
would crash with the 'Invalid Input' error. However, after I plotted
from the command line just once, my code would work just fine.
The missing piece? The .RefreshPlotDeviceInfo method had to be invoked
before any plot configuration information could be altered.
The code below plots a window based on a standard title block that I
use. gTitleInsPt and gTitleUpRightCorner are 2 global variables set
elsewhere that take into account the actual insert point and scale of
the title block. This eliminates entities outside of the title block,
yet maintains a known scale.
Sub PlotMyWindow()
Dim CurrPlot As AcadPlot, PlotConfig As AcadPlotConfiguration
Dim PltOrigin(1) As Double
'In millimeters
PltOrigin(0) = 0
PltOrigin(1) = 25
Set PlotConfig = ThisDrawing.ActiveLayout
With PlotConfig
.RefreshPlotDeviceInfo
.ConfigName = "HP LaserJet 4MV"
.CanonicalMediaName = "Tabloid"
.PlotRotation = ac90degrees
.PlotOrigin = PltOrigin
.PlotType = acWindow
.SetWindowToPlot gTitleInsPt, gTitleUpRightCorner
End With
Set CurrPlot = ThisDrawing.Plot
CurrPlot.DisplayPlotPreview acFullPreview
End Sub
Keith Lozier
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.