-
setting pagesetups in autocad
Does anyone have and info or code, in vba, on setting up PAGESETUPS in autocad... i looked and all i can find is setting the path of the file to bring in the setups.....but how do you set one if its already in the template file?
just wondering.
ccatelein
-
Hi ccatelein,
Not sure what you want here, I have no clue on how to setup a page layout for plotting, but I can show you how to load linetypes, create layers etc. Let me know what you are looking for, and I'll try to find out ok?
-
hey tommy,
well within autocad your able to setup pages (paperspace layout tabs). These layouts define the printer, size of paper, .ctb file to use, scale, etc... and then name it... That way if you publish a set of drawings you can use a PageSetup on all the sheets and it will print using the info defined in the PageSetup.
PageSetups have been available since Autocad 2000 at least. Im currently using ADT6 and trying to set an already defined PageSetup but unable to find anything in VBA about it. other than redefining the path to the PageSetup drawing you can import from.
any help?
ccastelein
-
I think you are looking for the AcadLayout class. It seems to have all the properties you are looking for. I have not worked with this before, as a matter of fact I just tried using the paperspace last weekend for the first time. I'll look at it this weekend and see what I can come up with. But from the documentation it looks like you can setup paperspace layouts anyway you would like, change papersize, plotter/printer, margins, etc.
-
Any luck with this? I need help with this too.
-
The only thing I have come up with is the plotter configurations. Seems kinda strange that you can specify everything else but you can't grab the page setup name, or set it, through code. I found some lisp routines that says it can do it, look for pagesetup.lsp that is as far as I have gotten.
-
Setting pagesetups, it is the plotter configuration. the example below will give the "pagesetup name". Sometimes it is just to simple LOL.
[VBA]
Sub pLOTcONFIG()
Dim P As AcadPlotConfiguration
Dim PL As AcadPlotConfigurations
Set PL = ThisDrawing.PlotConfigurations
For Each P In PL
MsgBox P.Name
Next
End Sub
[/VBA]
-
Thanks Tommy,
ill look at first thing tomorrow.
ccastelein
-
ok tommy,
finally got to it... weeks later...as usual ive tried a bunch of things but cant get it to work:
Dim PGS As AcadPlotConfiguration
sheetname = "LargeDoc 30x42{24x36}": Set PGS = ThisDrawing.PlotConfigurations(sheetname)
cant quite seem to set a pre-defined pagelayout to the current layout tab.
any ideas?
-
Yes I have it at home though. I will post in a couple of hours.
As a side note I was also looking into making a pagesetup if it doesn't exist, it sets the page size, plotter, ctb file, what to plot, scale. It is ment to setup a drawing when you first open it from scratch with the choices that you make. I'll be back soon just didn't want you to think I was not here
-
ccastelein,
The page setup name needs to exist. This program is using "Most".
This what works for me in 2000i:
[VBA]
Public CurPltCnfg As AcadPlotConfiguration
Public Function ChckFrPltCnfg(iName$) As Boolean
Dim Plt As AcadPlotConfiguration
For Each Plt In ThisDrawing.PlotConfigurations
If Plt.Name = iName Then
Set CurPltCnfg = Plt
ChckFrPltCnfg = True
Exit Function
End If
Next
End Function
'
Public Sub SetPltCnfg()
Dim Plt As AcadPlotConfiguration
For Each Plt In ThisDrawing.PlotConfigurations
If ChckFrPltCnfg("Most") Then '<-page setup name
MsgBox "Pages seup name has been set"
End If
Next
End Sub
[/VBA]
-
hhmmmm,
i must be pretty basic...im kinda looking for a very basic command...something like this:
dim CurPltCnfg as AcadPlotConfiguration
dim PageName as string
PageName = "ANYTHING HERE"
set CurPltCnfg = PageName
how come things cant be that easy...why does there always have to be FOR EACH ..NEXT stuff in vba...drives me crazy
in otherwords, im not haveing much success at this page setup thing...
ccastelein
-
LOL the problem is I think is the page setup name doesn't exist. So it will not work. The code you posted will work if it exist. For Each is basically a search on the items that are there, that way you don't have any errors that jump up out of nowhere. So if you do the for each and it wasn't there you would know to make it, or you could do error checking if an error occurs fix it either way. If you fell like messing with it I could post what I have for a pagesetup sub but it is real messy, not documented, I could go for days so I'll just say it isn't ready for someone to look at. but if you want to I will post. I'm just warnig you cause it gets real deep real fast I was suprised.
-
Sounds to me you may be trying to come up with a way to batch plot a set of drawings. I'll attach a routine I wrote, but it only plots the layout tab the drawing was saved in. Hope it helps.
Last edited by Tommy; 09-20-2005 at 09:09 AM.
Reason: unacceptable language in attachment
-
Well, i wish my above simple code worked but it doesnt...it tells me i have a type mismatch with pagename.. havent looked at the batchplot.zip file yet... but i will..to see if i can glean something from it...
ccastelein
-
This is what needs to be changed to make a "page setup"
[VBA]
ThisDrawing.ModelSpace.Layout.ConfigName = "Printer"
ThisDrawing.ModelSpace.Layout.CanonicalMediaName = "Legal"
ThisDrawing.ModelSpace.Layout.UseStandardScale = True
ThisDrawing.ModelSpace.Layout.StandardScale = acScaleToFit
ThisDrawing.ModelSpace.Layout.PlotRotation = ac90degrees
ThisDrawing.ModelSpace.Layout.PlotType = acExtents
ThisDrawing.ModelSpace.Layout.StyleSheet = "acad.ctb"
[/VBA]
The zip file has more information for setting up a page/plotter configuration, still rather rough though.
The reason you are having a mismatch with pagename is it is not a plotter configuration, it is a string looks like it was supposed to be a name
-
I wish to apologize to any readers for the unacceptable language in the posted file. It has been deleted.
Thank You
-
Tommy, i beleive i have found the answer ive been looking for and the reason why ive been so frustrated with PageSetups..
http://discussion.autodesk.com/threa...sageID=4793445
vba dosent expose the PreDefined PageSetups.... it lets you add them but you cant set them...( unless you care to prove me wrong..which i hope you can do)
looks like i can do it via Lisp...
ill let ya know how i do.
ccastelein
-
heres the code to the lisp file, pretty simple: (may help you to get it in vba):
(defun CurrentPlotConfig (strLayout / layts layt pconfig )
;;; this function is used with vba.
;;; vba does not expose Page Setup Name. It is stored
;;; as the (1 . "name") of (100 . "AcDbPlotsettings") subgroup
;;; of the "ACAD_LAYOUT" named object dictionary.
(setq layts (dictsearch (namedobjdict) "acad_layout"))
(setq layt (dictsearch (cdar layts) strLayout))
(setq pconfig (cdr (assoc 1 layt)))
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules