10-22-2018
01:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-22-2018
01:12 AM
Hello everyone,
I can't manage to set any print configurations, everytime I open a drawing it resets to what is default in the drawing. The problem occurs with some drawings exported from another program (cadmatic... ) and trying to print to PDF.
---- edit -----
Now I am loading a few preset plot configurations from another drawing, which seems to be working. Only I would like to use the button 'Apply to layout'. Does anyone know if this is possible thourhg VBA?
Function DoPdf(dwg As AcadDocument, pdfFile As String, config As String) As Boolean
' Initialize the acad plot, configs and configurations
Dim ptObj As AcadPlot
Dim ptConfigs As AcadPlotConfigurations
Dim plotConfig As AcadPlotConfiguration
' Create a new plot configuration with all needed parameters
Set ptObj = dwg.Plot
Set ptConfigs = dwg.PlotConfigurations
' Add a plotconfiguration
ThisDrawing.SendCommand "filedia" & vbCr & "0" & vbCr
ThisDrawing.SendCommand ".-psetupin" & vbCr & "PATH" & vbCr & "*" & vbCr & vbCr & vbCr
ThisDrawing.SendCommand "filedia" & vbCr & "1" & vbCr
' Set the configuration
Select Case config
Case "a3"
Set plotConfig = ptConfigs.Item("Spools_a3")
Case "a2"
Set plotConfig = ptConfigs.Item("Spools_a2")
Case "a1"
Set plotConfig = ptConfigs.Item("Spools_a1")
End Select
' Set background plotting to off so autocad will wait till print is finished. Prevents errors.
Call ThisDrawing.SetVariable("BACKGROUNDPLOT", 0)
' Updates the plot
plotConfig.RefreshPlotDeviceInfo
' Create a variable to see if print was succesfull
Dim success As Boolean
' Catch the error
On Error Resume Next
success = ptObj.PlotToFile(pdfFile, plotConfig.ConfigName)
If Err Then
'MsgBox "Not printed"
End If
' Delete the previous config
Set plotConfig = Nothing
' Return the result
DoPdf = success
End Function
Solved! Go to Solution.