VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assign view to page setup

0 REPLIES 0
Reply
Message 1 of 1
sa_jekov
69 Views, 0 Replies

Assign view to page setup

Can someone Help me. I want ot create pdf based oncordinates. I get them from other part of code.But i cant make it create it the window my cordinates. This is my code

Sub ExportPDFWithCustomSettings()
' Declare variables for plot settings and coordinates
Dim plotSettings As Object
Dim minPt As Variant, maxPt As Variant
Dim plotScale As Double
Dim paperSize As String
Dim plotFilePath As String

' Coordinates for the plot window (bottom-left corner and top-right corner)
minPt = Array(0, 0) ' Bottom-left corner (0, 0)
maxPt = Array(2920, 2050) ' Top-right corner (2920, 2050)

' Get the Plot object from the current drawing
Set plotSettings = ThisDrawing.Plot

' Set the plot area to custom window (acWindow)
plotSettings.PlotArea = acWindow ' Use acWindow to define custom window for plotting

' Define the custom plot window area with the coordinates (minPt and maxPt)
ThisDrawing.Plot.SetPlotWindowArea minPt, maxPt

' Set the plot scale (1:5)
plotScale = 5 ' 1:5 scale
plotSettings.plotScale = plotScale

' Set paper size to ISO Expand A3
plotSettings.paperSize = "ISO Expand A3"

' Set plot rotation to 0 degrees (no rotation)
plotSettings.PlotRotation = 0 ' No rotation

' Set to center the plot on the paper
plotSettings.CenterPlot = True

' Set the output file path for the PDF
plotFilePath = "C:\path\to\output\yourfile.pdf" ' Change this path to your desired location
plotSettings.PlotToFile = True
plotSettings.PlotFileName = plotFilePath

' Execute the plot to file (generate PDF)
ThisDrawing.Plot.PlotToFile plotFilePath

' Display a message when done
MsgBox "Plotting complete. PDF saved to: " & plotFilePath
End Sub

 

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report