pmvliet 发表于 2004-10-24 22:07:33

页面设置

我不知道我是愚蠢还是只是愚蠢,但我无法让它发挥作用。我试图绘制一个模型空间限制的EPS文件,这样我就可以通过ghostscript传递它,生成pdf文件。但是,当我运行此代码时,它不会更改任何modelspace布局属性。

Public Function PlotToEPS(OutputFile As String) As Boolean
Dim Layout As AcadLayout
Dim Plot As AcadPlot
Dim orig(0 To 1) As Double
orig(0) = 0
orig(1) = 0
For Each Layout In ThisDrawing.Layouts
    If LCase(Layout.Name) = "model" Then
      With Layout
            .ConfigName = "PostScript.pc3"
            .CanonicalMediaName = "ANSI_B_(17.00_x_11.00_Inches)"
            .PaperUnits = acInches
            .PlotType = acLimits
            .StandardScale = acScaleToFit
            .PlotOrigin = orig
            .StyleSheet = "Ricoh.ctb"
            .PlotHidden = True
            .UseStandardScale = True
            .PlotRotation = ac90degrees
            .CenterPlot = True
      End With
      
      Set Plot = ThisDrawing.Plot
      Plot.PlotToFile OutputFile, "PostScript.pc3"
      Set Plot = Nothing
      PlotToEPS = True
    Else:
      PlotToEPS = False
    End If
Next
End Function

Note: I use the "For Each Layout In ThisDrawing.Layouts" in case I never need to make this work with paperspace.
**** Hidden Message *****

DanS_Carte 发表于 2004-10-27 20:47:42

我会变得又笨又笨,你怎么用这个?
我用脚本创建了一个类似的东西来绘制创建图。
使用这个有什么好处吗?
我要学的东西太多了...彼得

DanS_Carte 发表于 2004-10-29 20:51:53

我最近没有机会看这个,但我认为这是我的pc3文件中的错误,而不是代码中的错误。
我选择以这种方式而不是通过绘图脚本执行此操作的原因是,此方法在完成时将返回 true,这将允许我继续编写代码。现在我想到它可能无论如何都不起作用,我将不得不手动检查该文件。

DanS_Carte 发表于 2006-4-18 15:55:02

尝试用粗体行调整您的代码...
对于ThisDrawing.Layouts中的每个布局
如果LCase(Layout.Name)="model",那么
使用Layout
。刷新PlotDeviceInfo
。ConfigName="PostScript.pc3"
。刷新PlotDeviceInfo
...
不确定为什么我们需要刷新两次,但这是我可以让我的绘图例程正常工作的唯一方法。

DanS_Carte 发表于 2006-4-18 16:00:49

呜呜。别担心,那是行不通的。我在想别的事。。。

DanS_Carte 发表于 2006-4-18 16:44:55

这就是我使用的
Public Sub SetupAndPlot(ByRef Plotter As String, CTB As String, SIZE As String, PSCALE As String, ROT As String)
    Dim Layout As AcadLayout
    On Error GoTo Err_Control
    Set Layout = ThisDrawing.ActiveLayout
    Layout.RefreshPlotDeviceInfo
    Layout.ConfigName = Plotter    ' CALL PLOTTER
    Layout.PlotType = acExtents
    Layout.PlotRotation = ROT    ' CALL ROTATION
    Layout.StyleSheet = CTB    ' CALL CTB FILE
    Layout.PlotWithPlotStyles = True
    Layout.CanonicalMediaName = SIZE    ' CALL SIZE
    Layout.PaperUnits = acInches
    Layout.StandardScale = PSCALE    'CALL PSCALE
    Layout.ShowPlotStyles = False
    ThisDrawing.Plot.NumberOfCopies = 1
    Layout.CenterPlot = True
    Layout.ScaleLineweights = False
    Layout.RefreshPlotDeviceInfo
    ThisDrawing.Regen acAllViewports
    ZoomExtents
    Set Layout = Nothing
    ThisDrawing.Save
Exit_Here:
    Exit Sub
Err_Control:
    Select Case Err.Number
      Case "-2145320861"
            MsgBox "Unable to Save Drawing- " & Err.Description
      Case "-2145386493"
            MsgBox "Drawing is setup for Named Plot Styles." & (Chr(13)) & (Chr(13)) & "Run CONVERTPSTYLES command", vbCritical, "Change Plot Style"
      Case Else
            MsgBox "Unknown Error " & Err.Number
    End Select
End Sub
页: [1]
查看完整版本: 页面设置