Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 30 of 30

Thread: setting pagesetups in autocad

  1. #21
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    Ok tommy, im back, (long time!)
    heres what ive found out...
    I got acad to set the Pagesetup via lisp...called from vba. (i pass an argument [the pagesetup name] to the lisp)
    UNFORTUNATELY, after setting it to the papersetup i want that has the paper size i want, it wont "regen" to update the piece of paper in paperspace... pagesetup says its set but graphically it hasnt... the only way i can get it to do it is to actually enter the pagesetup command and set it and close... then graphically it updates... oh well.

    Heres my vba code: (all two lines of it!!)

    Dim PageSetup As String
    PageSetup = """LargeDoc 24x36{24x36}""": ThisDrawing.SendCommand "(psetup " & PageSetup & ") "


    Heres the Lisp code:
    ALL CREDITS OF THE LISP HAVE REMAINED.

    ; Jason Piercey . May 16th, 2003
    ; assign a pagesetup to a layout
    ; [layout] - string, layout name
    ; [setup] - string, pagesetup to assign
    ; return: T or nil
    ; modified by chris castelein 10-31-05
    ; to pass paper size as an argument.
    ; original prompt code left in and remarked out.
    (defun putPagesetup (layout setup / layouts plots)
    (defun item-p (collection item)
    (if
    (not
    (vl-catch-all-error-p
    (vl-catch-all-apply
    '(lambda () (setq item (vla-item collection item))))))
    item
    )
    )
    (and
    (or *acad* (setq *acad* (vlax-get-acad-object)))
    (or *doc* (setq *doc* (vla-get-activedocument *acad*)))
    (setq layouts (vla-get-layouts *doc*))
    (setq plots (vla-get-plotconfigurations *doc*))
    (setq layout (item-p layouts layout))
    (setq setup (item-p plots setup))
    (not (vla-copyfrom layout setup))
    )
    )
    (defun massoc (key alist / x nlist)
    (foreach x alist
    (if (eq key (car x))
    (setq nlist (cons (cdr x) nlist))
    )
    )
    (reverse nlist)
    )

    ; Return: list of all pagesetups defined in the current drawing or nil
    (defun getPagesetups ()
    (massoc 3 (dictsearch (namedobjdict) "Acad_PlotSettings"))
    )
    ; Jason Piercey . May 19th, 2003
    ; assign pagesetup to layout(s)
    ; LIMITED testing
    ; written for Shawn McDonald
    (defun psetup (page / lst res)
    (setq lst (mapcar 'strcase (getPagesetups)))
    (while (not page)
    ;(setq page (strcase (getstring T "\nspecify pagesetup to apply: ")))
    (if (or (= "" page) (not (member page lst)))
    (progn (princ "\npagesetup not found") (setq page nil))
    )
    )
    (initget "All Current")
    ;(if(not(setq res (getkword "\n[All/Current]apply pagesestup to which layout(s) <all>: ")))
    ;(setq res "All")
    (setq res "Current")

    (if (= "All" res)
    (foreach x (vl-remove "Model" (layoutlist)) (putPagesetup x page))
    (putPagesetup (getvar "ctab") page)
    )
    (princ "\nFinished")
    (princ)
    )



    Hope this helps you and somebody else!
    I already have my next question for ya tommy.. so look for my next post soon
    ccastelein

  2. #22
    VBAX Regular
    Joined
    Nov 2005
    Posts
    10
    Location

    create page setup

    This will create a page setup in autocad 2000-2002, and send the plot
    with the config

    Dim acadapp As Object
    Dim AutoCAD As Object
    Dim activedocument As Object
    Dim Thisdrawing As AcadDocument 'as Object
    Dim plotsObj As AcadPlotConfigurations
    Dim plotObj As AcadPlotConfiguration
    'On Error Resume Next

    Set acadapp = GetObject(, "autocad.application")
    Set Thisdrawing = acadapp.activedocument
    'this is a "short"cut, to making autoCAD save a plotconfig (page setup) in 2000 2002
    'You don't have to send the plot to make it add your settings, but I did to be sure it
    'fully refreshed and stayed in the drawing.
    'the confusion is the naming in autocad, a page set up is a "plotconfiguration"
    'saved (added) under the name prop of the object but in acad,
    'the config property is just the device, and no page setup exists as an
    'object named that (2000)

    'This is the object method for sending multiple windows to
    'a plot configuration plot, the plotconfig looks for the view created
    ' as you redefine and delete the view, from views creating from rectang bounding boxes
    'you can the send multiple areas of the same view name
    Apptivate 'extended appactivate function
    'Set plotObj = Thisdrawing.PlotConfigurations.plotconfiguration
    'On Error Resume Next
    'Creates a page setup (plotconfiguration), while it is ordering the
    'drawing.layout to plot to a device of the same settings, mirrored by the plotconfig
    'creation
    ' doubled these set properties, because I had certain things that
    'were not behaving properly until I did this
    Thisdrawing.PlotConfigurations.Add "TESTPC2", True
    Thisdrawing.ActiveLayout.ConfigName = "\\WLB-TUC3\HP Color LaserJet 8550"
    Thisdrawing.PlotConfigurations.Item("TESTPC2").ConfigName = "\\WLB-TUC3\HP Color LaserJet 8550"
    Thisdrawing.ActiveLayout.StyleSheet = "HP1050annex-half.ctb"
    Thisdrawing.PlotConfigurations.Item("TESTPC2").StyleSheet = "HP1050annex-half.ctb"
    Thisdrawing.ActiveLayout.CanonicalMediaName = "Letter"
    Thisdrawing.PlotConfigurations.Item("TESTPC2").CanonicalMediaName = "Letter"
    Thisdrawing.ActiveLayout.StandardScale = acScaleToFit
    Thisdrawing.PlotConfigurations.Item("TESTPC2").StandardScale = acScaleToFit
    Thisdrawing.ActiveLayout.CenterPlot = True
    Thisdrawing.PlotConfigurations.Item("TESTPC2").CenterPlot = True
    Thisdrawing.ActiveLayout.ViewToPlot = "XPLOT"
    ''Thisdrawing.PlotConfigurations.Item("TESTPC2").ViewToPlot = "XPLOT"
    Thisdrawing.ActiveLayout.PlotType = acView
    'Thisdrawing.PlotConfigurations.Item("TESTPC2").PlotType = acView
    'Thisdrawing.ActiveLayout.
    Thisdrawing.ActiveLayout.RefreshPlotDeviceInfo
    Thisdrawing.PlotConfigurations.Item("TESTPC2").ViewToPlot = "XPLOT"
    Thisdrawing.PlotConfigurations.Item("TESTPC2").PlotType = acView
    Thisdrawing.ActiveLayout.RefreshPlotDeviceInfo
    Thisdrawing.PlotConfigurations.Item("TESTPC2").RefreshPlotDeviceInfo
    'Thisdrawing.ActiveLayout.s
    'Thisdrawing.PlotConfigurations.Add "TESTPC2", True
    Thisdrawing.ActiveLayout.RefreshPlotDeviceInfo
    Thisdrawing.Plot.PlotToDevice "\\WLB-TUC3\HP Color LaserJet 8550" '"TESTPC2"
    Thisdrawing.ActiveLayout.RefreshPlotDeviceInfo
    'Thisdrawing.Plot
    'THIS CREATES THE PAGE SETUP- THEN RUN SEND COMMAND TO SEND THIS
    'LIKE, PICK RECTANG, CREATE VIEW, CREATE PAGE SETUP (PLOTCONFIG) WHICH REFS THE VIEW,
    'SEND PLOT WITH SENDKEYS, DELETE VIEW, REPEAT.
    'Thisdrawing.Plot.DisplayPlotPreview acFullPreview
    'Thisdrawing.PlotConfigurations.Item("K").

  3. #23
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    Hello zenwest,

    Lotsa code there... let me clarify the problem...
    I dont need to create a pagesetup...the file has all the pagesetups it needs.
    and i dont need to send a plot...

    all i want to do is set a layout tab to use a pre-defined pagesetup.
    it seems VBA wont allow you to do that. Though lisp will ...to an extent.
    im able to set a tab to use the pagesetup i want but it wont refresh the on screen graphics paper size after i set it. the Pagesetup dialog box says it is useing the correct pagesetup but it doesnt "show" it.

    you would think it would be something as simple as:
    thisdrawing.activelayout.plotconfiguration = "pagesetupnamehere"
    but no.

    heres the scenario:
    open new drawing...go to paper space...insert titleblock of 24x36 size...
    set paperspace tab (or layout) to use pre-defined pagesetup...

    thats it.
    let me know if you think it can do something that simple.
    ccastelein

  4. #24
    VBAX Regular
    Joined
    Nov 2005
    Posts
    10
    Location

    sendcommand bypass

    I will try to do it in vba next, but here is the non detailed -plot command version of sendcommand, maybe this will work as on my drawing, where it refreshed the predefined pages



    [VBA]

    Private Sub Command3_Click()
    Dim AutoCAD As AcadApplication
    Dim Thisdrawing As AcadDocument 'as Object
    Set acadapp = GetObject(, "autocad.application")
    Set Thisdrawing = acadapp.activedocument

    Thisdrawing.SendCommand "-PLOT" & vbCr & _
    "N" & vbCr & _
    vbCr & _
    "2436" & vbCr _
    & vbCr _
    & "No" & vbCr _
    & "yes" & vbCr _
    & "no" & vbCr _

    'command text: -PLOT
    'Thisdrawing.SendCommand "-PLOT" & vbCr & _
    '"N" & vbCr & _ ='Detailed plot configuration? [Yes/No] <No>:
    'vbCr & _ ='Enter a layout name or [?] <Layout1>:
    '"2436" & vbCr _ ='Enter a page setup name <811>: 2436
    ' & vbCr _ ='Enter an output device name or [?] <HP 1050C LDD3.pc3>:
    '& "No" & vbCr _ ='Write the plot to a file [Yes/No] <N>:
    '& "yes" & vbCr _ ='Save changes to layout [Yes/No]? <N> y
    '& "no" & vbCr _' ='Proceed with plot [Yes/No] <Y>: n

    End Sub

    [/VBA]

  5. #25
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    ccastelein,
    I think your problem is you are working in "Model" you may need to be in "Layout" for the plot configurations/page setups. Its just a guess. The only reason I am saying anything is because I could set it in Model but when I created it it was in layoust and I haven't revisited so just a view point

  6. #26
    VBAX Regular
    Joined
    Jun 2005
    Location
    Hiawatha Iowa
    Posts
    31
    Location
    Zenwest,
    Yeah, ive seen the posts for using the -plot command...not really interested in that. my posted solution works for the most part.. just disappointed it wont refresh.

    Tommy,
    no im in paper space alright... i think im going to have to wait for autodesk to enable what i want to do in VBA for their future releases of Acad. gives them something to do, and tease us with new "features" and improvements.
    im just disappointed they came so close and didnt finish it.

    but now im going to post a new question for ya.. so look for a new thread.
    im going to post it with out doing any research into it yet... maybe you guys know the answer and save me some time.
    ccastelein

  7. #27
    VBAX Newbie
    Joined
    Nov 2006
    Posts
    2
    Location
    This will Import a Page setup.

    Private Sub CommandButton1_Click()
    Me.Hide
    ThisDrawing.SendCommand "filedia" & vbCr & "0" & vbCr
    ThisDrawing.SendCommand "-psetupin" & vbCr & "C:\YourPath\Your.dwg" & vbCr & "DWF_36X24_48" & vbCr 'enter the correct path, dwg name, and 'page setup to import
    ThisDrawing.SendCommand "filedia" & vbCr & "1" And vbCr
    End Sub

  8. #28
    VBAX Regular
    Joined
    Nov 2005
    Posts
    15
    Location

    Of course!!!! This stumpdme for a long time...

    ...What I was doing, I found out, that If you insert a paperspace block, into paperspace (won't work in model), the block inserts with the page setups into pspace. But for some reason, they would be off, until you opened and previewed in a plot, for me anyways. So it kind of defeated part of the purpose for a batch plot, but anyways...
    I have seen that command pass by the command line on plots, or something. But I learn something new about cad every hour, that I should know already. Thanks, that command! I have to read all the sysvars and commands. I haven't tried it, but It looks like it will work. The page setup is so powerful and convenient, too bad it's not well supported in VB, but there is always a way. Thanks,

    lsddotms

  9. #29
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    If you already have one paperspace layout set up the way you want it, why not just copy it?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  10. #30
    VBAX Newbie
    Joined
    Nov 2006
    Posts
    2
    Location
    update after more testing...

    Private Sub CommandButton1_Click()
    Me.Hide
    ThisDrawing.SendCommand "filedia" & vbCr & "0" & vbCr
    ThisDrawing.SendCommand "-psetupin" & vbCr & "C:\YourPath\Your.dwg" & vbCr & "DWF_36X24_48" & vbCr & "Yes" & vbcr 'enter the correct path, 'dwg name, and 'page setup to import.
    ThisDrawing.SendCommand "filedia" & vbCr & "1" & vbCr
    End Sub

Posting Permissions

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