Jump to content

VBA to set printer


nguyendan81985

Recommended Posts

hi all

i have marco to issue many drawing automatically, and now i want to set up printer for them to print faster. so please help me to write VBA to setup printer for autocad drawing as following:

 

1. change to Layout and add viewport to frame of drawing (the frame shall be scaled in each drawing)

2. Printer/Plotter: default printer

3. paper size: A3

4. plot area: window (get all drawing in layout)

5.Plot offset: center the plot

6.Scale: fit to paper

7.Plot Style table: Monochrome.

 

thanks

Link to comment
Share on other sites

It is an example of the method of how to do you would need to rewrite in VBA, do you know how to program VBA ?

 

hi. i just know VBA, not LISP. so would you please help me to program in VBA. thanks.

ex: draw Rectang in Model, then move to Layout and set printer as following setting:

 

1. in layout, add viewport to Rectang

2. Printer/Plotter: default printer of PC

3. paper size: A3

4. plot area: window (get all drawing in layout)

5.Plot offset: center the plot

6.Scale: fit to paper

7.Plot Style table: Monochrome.

Link to comment
Share on other sites

You need to understand within VBA some basic principles I am no expert but know enough to do basic programming. Have you checked the developers Help from within Autocad?

 

Vlisp version detailed there will be documentation for all these steps as VBA

open the autocad document (vla-get-activedocument (vlax-get-acad-object))

get the layouts as a group from the document(vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object)))

loop through the layouts one at a time (vlax-for lay (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object)))

this returns the layout number (vla-get-taborder lay)

Open up the current layout ctab by retrieving the layoutname (setvar "ctab" (vla-get-name lay))

The (command "Plot".... could be done by invoking a plot script VBA thisdrawing.plot http://forums.autodesk.com/t5/visual-basic-customization/automated-print-from-vba-using-a-saved-page-setup/m-p/2250520

 

A quick google and this was found here at Cadtutor solves 1 problem Cadtutor is not a write code for me service if you want that then you either pay someone or wait for possible help.

Sub FindLayouts()
   Dim oLay As AcadLayout
       For Each oLay In ThisDrawing.Layouts
           MsgBox oLay.Name
       Next
End Sub

Link to comment
Share on other sites

thanks BIGAL

i completed with my program. below is my program

 

Sub Example_PlotType()
   
   Dim ACADLayout As ACADLayout
   Dim originalValue As Integer
   Dim Print1 As String
   Dim Paper1 As String

   Set ACADLayout = ThisDrawing.ActiveLayout
   
   Print1 = "HP LaserJet 5200 Series PCL 5" ' name of my printer
   Paper1 = "A3" 'type of paper size
   
   ACADLayout.PlotType = acExtents
   ACADLayout.CenterPlot = True
   ThisDrawing.ActiveLayout.StyleSheet = "monochrome.ctb"
   ThisDrawing.ActiveLayout.StandardScale = acScaleToFit
   ThisDrawing.ActiveLayout.ConfigName = Print1
   ThisDrawing.ActiveLayout.CanonicalMediaName = Paper1

End Sub

Edited by nguyendan81985
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...