nguyendan81985 Posted October 21, 2014 Share Posted October 21, 2014 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 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 21, 2014 Share Posted October 21, 2014 check this out its lisp rather than vba but does what you want http://www.cadtutor.net/forum/showthread.php?69132-Printing-LISP-Help...&highlight=Printing-LISP Quote Link to comment Share on other sites More sharing options...
nguyendan81985 Posted October 21, 2014 Author Share Posted October 21, 2014 check this out its lisp rather than vba but does what you want http://www.cadtutor.net/forum/showthread.php?69132-Printing-LISP-Help...&highlight=Printing-LISP thanks, but i need VBA to add in my marco. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 22, 2014 Share Posted October 22, 2014 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 ? Quote Link to comment Share on other sites More sharing options...
nguyendan81985 Posted October 22, 2014 Author Share Posted October 22, 2014 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. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 22, 2014 Share Posted October 22, 2014 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 Quote Link to comment Share on other sites More sharing options...
nguyendan81985 Posted October 22, 2014 Author Share Posted October 22, 2014 (edited) 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 October 23, 2014 by nguyendan81985 Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 22, 2014 Share Posted October 22, 2014 FWIW - Methinks it a far simpler implementation to import a named page setup, and apply that to Layouts. If/when you decide to step up into .NET API, this old post may be of use. Cheers Quote Link to comment Share on other sites More sharing options...
SLW210 Posted October 22, 2014 Share Posted October 22, 2014 Pleas read The Code Posting Guidelines and edit your post to include the Code in Code Tags. Quote Link to comment Share on other sites More sharing options...
nguyendan81985 Posted October 23, 2014 Author Share Posted October 23, 2014 Pleas read The Code Posting Guidelines and edit your post to include the Code in Code Tags. well noted Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.