Wednesday, August 7, 2013

Importing Page Setup from another drawing file (AutoCAD)

One of the things that I took on at the company that I am currently working with is build a bunch of macros that would make the design process easier.  So, the first one that I created was a macro that would insert the companies titleblock in a drawing, import a page setup that was defined in a different drawing, create all the layers required for a given discipline, create a new viewport, and then at the end would go through the edit attribute for the title block. 
Today, I want to take a look at how you can import a page setup from one file to another, and how to set a given page setup as your plot parameters.
So, below is an example of what the code would look like...
^c^c-psetupin;"D_SIZE-PID.DWG" "*";^c^c-plot;n;layout1;11x17;;n;y;n;


First, I want to point out just incase you don't know...at the beginning of each command you will see "^c^c" this is just telling the program to cancel out of any commands that it may be in at that point.
Next, we have the command "-psetupin"; and then the semicolon is issueing an enter command in the macro.
Then you will pass the macro the name of the drawing that you are wanting to get the page setup from and in my example I am calling out "D_size-pid.dwg" and you have to make sure that it is in the quotations.  Also, as long as the file location of the drawing is setup in your search paths then you don't have to worry about adding the whole location of the file just the nam will suffice.  The asterisk after the file name just tells it to select all the setups that are associated with that file.
Then, we move on to setting a specific pagesetup to our layout.  With this we begin with "-plot" which will do all the plot settings through your command line.  After starting the command the first question is asking if you want to do a "Detailed plot configuration"...we want to put "no". 
Then you will tell it which layout you want to apply the pagesetup to; mine is "layout1", and then type in the page setup that you are wanting to apply "11x17".  After the page setup name there are 2 semicolons; the first represents the issueing of an enter command, and the second of these represent a question that follows after the setup name...this is for the output device (printer name), and as long as that is set properly in your setup then you should just have to issue an enter command. 
Then it asks if you want to plot to file and for that we want to say "no" as well and it should default to that, but just incase we will put an "n"; and then it asks if we want to save changes to page setup, and for this you will enter a "yes". 
The last question is if you want to go ahead and plot and for mine a said "no".
Now, after all that you should end up with something like this...
-plot;n;layout1;11x17;;n;y;n;

Good luck and hope this helps!

No comments:

Post a Comment