Jump to content

Pdf lot with VBA


muck

Recommended Posts

Is there a way to plot to a pdf file with the same name as the drawing in

AutoCAD VBA?

Thank you,

 

This one is not mine I don't remeber where I found it

Pehaps on this forum :)

 

Sub PDF()
Dim xymin As Variant
Dim xymax As Variant
Dim sysVarName As String
Dim varData As Variant
Dim blad As AcadLayout
Dim PlotXY(0 To 1) As Double
Dim i As Integer
Dim result As Boolean
On Error GoTo PDF_Error
Set blad = ThisDrawing.Layouts.Item(1)
ThisDrawing.ActiveLayout = blad
blad.ConfigName = "DWG To PDF.pc3"
blad.CanonicalMediaName = "ISO_A3_(420.00_x_297.00_MM)"
blad.PlotType = acExtents
blad.StandardScale = acScaleToFit
blad.CenterPlot = True
blad.ScaleLineweights = True
blad.StyleSheet = "acad.ctb"
blad.PlotWithPlotStyles = False
blad.PlotWithLineweights = False
PlotXY(0) = 0#
PlotXY(1) = 0#
sysVarName = "EXTMIN"
xymin = ThisDrawing.GetVariable(sysVarName)
sysVarName = "EXTMAX"
xymax = ThisDrawing.GetVariable(sysVarName)
If (xymax(0) - xymin(0)) > (xymax(1) - xymin(1)) Then
blad.PlotRotation = ac0degrees
Else
blad.PlotRotation = ac90degrees
End If
blad.PaperUnits = acMillimeters
result = ThisDrawing.Plot.PlotToFile(Replace(ThisDrawing.FullName, "dwg", "pdf"))
Exit Sub
PDF_Error:
MsgBox "Error PDF'ing Layout!", vbOKOnly, "Error"
End Sub

 

~'J'~

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...