Jump to content

[VBA]Create custom paper for plot


Recommended Posts

Posted

Hello

 

I wrote this code to create pdf from a design by specifying which area of the drawing must be printed.

 

The code works, but the file is always in the format "A4".

 

How can I define a custom format with vba, that is not present in the default format for the printer?

 

Each print has a size different from the others and I wish the paper was the same size and proportions of the printed design.

 

I hope I explained myself well because my English is bad.

If not I'll try to explain better

 

This is the code

Private Sub cmdPdf_Click()

Dim stampa As AcadPlot
Dim nBACKGROUNDPLOT As Long

nBACKGROUNDPLOT = ThisDrawing.GetVariable("BACKGROUNDPLOT")

nBACKGROUNDPLOT = ThisDrawing.GetVariable("BACKGROUNDPLOT")

Dim num_prova As Integer
Dim x_origine As Double
Dim y_origine As Double
Dim origine_testa_y As Double
Dim ptA(0 To 2) As Double
Dim ptB(0 To 2) As Double


Dim puntoA As Variant
Dim puntoB As Variant


num_prova = txtNumProva.Text

x_origine = 200 + (num_prova * 200)
y_origine = 200


origine_testa_y = y_origine + 62.5



ptA(0) = x_origine + 14.4325
ptA(1) = y_origine + 7.1914
ptB(0) = x_origine + 104.4325
ptB(1) = origine_testa_y + 51.7515


puntoA = ptA
puntoB = ptB



ThisDrawing.ActiveLayout.CenterPlot = True
ThisDrawing.ActiveLayout.StandardScale = acScaleToFit
ThisDrawing.ActiveLayout.GetWindowToPlot puntoA, puntoB


ThisDrawing.ActiveLayout.PlotType = acWindow



Set stampa = ThisDrawing.Plot
stampa.PlotToDevice ("Adobe PDF")

Call ThisDrawing.SetVariable("BACKGROUNDPLOT", nBACKGROUNDPLOT)


End Sub

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...