26 | 02 | 2017

Create PDF using saved PC3

If you would like to create a PDF file from your drawing use the code below. It is also possible to specify more details.

{code lang:vbnet title:"Create PDF" lines:false hidden:false}Sub CreatePDF()

Dim PtConfigs As AcadPlotConfigurations
Dim PlotConfig As AcadPlotConfiguration
Dim PtObj As AcadPlot
Dim BackPlot As Variant

'Create a new plot configuration with all needed parameters
Set PtObj = ThisDrawing.Plot
Set PtConfigs = ThisDrawing.PlotConfigurations
'Add a new plot configuration
PtConfigs.Add "PDF", False
'The plot config you created become active
Set PlotConfig = PtConfigs.Item("PDF")
'Use this method to set the scale
PlotConfig.StandardScale = acScaleToFit
'Updates the plot
'Here you specify the pc3 file you want to use
PlotConfig.ConfigName = "DWG To PDF.pc3"
'You can select the plot style table here
PlotConfig.StyleSheet = "Acad.ctb"
'Specifies whether or not to plot using the plot styles
PlotConfig.PlotWithPlotStyles = True

'If you are going to create pdf files in a batch mode,
'I would recommend to turn off the BACKGROUNDPLOT system variable,
'so autocad will not continue to do anything until finishes
'the pdf creation
BackPlot = ThisDrawing.GetVariable("BACKGROUNDPLOT")
ThisDrawing.SetVariable "BACKGROUNDPLOT", 0
'Updates the plot
'Now you can use the PlotTofile method
If PtObj.PlotToFile("C:\PlottedFile.pdf") Then 'Change path and name here
MsgBox "PDF Was Created"
MsgBox "PDF Creation Unsuccessful"
End If
'If you wish you can delete th plot configuration you created
'programmatically, and set the 'BACKGROUNDPLOT' system variable
'to its original status.
Set PlotConfig = Nothing
ThisDrawing.SetVariable "BACKGROUNDPLOT", BackPlot

End Sub{/code}


Sign up now and upload your code to the website.

Help us to continue.....
Articles View Hits
Latest Articles