AutoCad - crear PDF en VB

 
Vista:

crear PDF en VB

Publicado por guihe (6 intervenciones) el 04/06/2010 12:26:51
Hola a todos...
El otro día encontré un codigo de como crear pdf's de los dibujos de autocad. Yo el VB de autocad lo controlo poco y por eso os pido ayuda. El codigo funciona perfectamente pero los pdf's los guarda por defecto en la carpeta 'Mis Documentos' he trasteado un poco las propiedades que aparecen en el codigo pero me pierdo. A ver si alguien sabe como definir una ruta o carpeta donde se guarden estos archivos....
Muchas gracias y aqui os dejo el codigo que es de gran utilidad (no es mio, eso si)

CODIGO
**********
Sub CreaPDF()
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
PlotConfig.RefreshPlotDeviceInfo

'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
PlotConfig.RefreshPlotDeviceInfo

'Now you can use the PlotTofile method
If PtObj.PlotToFile(Replace(ThisDrawing.ActiveLayer.Name, "dwg", "pdf"), PlotConfig.ConfigName) Then
'MsgBox "PDF Was Created"
'If PtObj.PlotToFile(Replace(ThisDrawing.FullName, "dwg", "pdf"), PlotConfig.ConfigName) Then
Else
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.
PtConfigs.Item("PDF").Delete
Set PlotConfig = Nothing
ThisDrawing.SetVariable "BACKGROUNDPLOT", BackPlot

End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder