Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 30

Thread: setting pagesetups in autocad

  1. #1
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location

    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

  2. #2
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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?

  3. #3
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    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

  4. #4
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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.

  5. #5
    VBAX Regular
    Joined
    Mar 2005
    Posts
    11
    Location
    Any luck with this? I need help with this too.

  6. #6
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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.

  7. #7
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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]

  8. #8
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    Thanks Tommy,
    ill look at first thing tomorrow.

    ccastelein

  9. #9
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    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?

  10. #10
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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

  11. #11
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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]

  12. #12
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    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

  13. #13
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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.

  14. #14
    VBAX Regular
    Joined
    Mar 2005
    Posts
    11
    Location
    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

  15. #15
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    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

  16. #16
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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

  17. #17
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    I wish to apologize to any readers for the unacceptable language in the posted file. It has been deleted.

    Thank You

  18. #18
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    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

  19. #19
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    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)))

  20. #20
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    LOL on the 8-12 post I said something about lisp being able to do it. Thank you for posting this, I will be looking into it . The part I am not sure of is at one time while fumbling through this I did set the page name someway but all of a sudden it didn't work On another note have you looked at vlisp? You have advanced debugging, looks a lot like the old turbo c debugger works similar (at least it used to).

    Once again thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •