以下是代码
- Public Sub PrintToJPG()
- Dim Layout As AcadLayout
- On Error GoTo Err_Control
- Set Layout = ThisDrawing.ActiveLayout
- Layout.RefreshPlotDeviceInfo
- Layout.ConfigName = "JPG.pc3" ' You need to call your PC3 you created to print to jpg here
- Layout.PlotType = acExtents
- Layout.PlotRotation = ac0degrees
- Layout.StyleSheet = "CTB.ctb" ' Add your ctb or stb file here
- Layout.PlotWithPlotStyles = True
- Layout.PlotViewportBorders = False
- Layout.PlotViewportsFirst = True
- Layout.CanonicalMediaName = "UserDefinedRaster (10800.00 x 7200.00Pixels)" ' Set your paper size here
- Layout.PaperUnits = acPixels
- Layout.SetCustomScale 300, 1 ' Add your scale factor based on the sheet size and resolution here
- Layout.ShowPlotStyles = False
- ThisDrawing.Plot.NumberOfCopies = 1
- Layout.CenterPlot = True
- Layout.ScaleLineweights = False
- ThisDrawing.Regen acAllViewports
- ZoomExtents
- strDrawingName = (Left(ThisDrawing.Name, (Len(ThisDrawing.Name) - 4)))
- Set Layout = Nothing
- ThisDrawing.Plot.PlotToFile strDrawingName
- Exit_Here:
- Exit Sub
- Err_Control:
- End Sub
|