Changing Orientation and Size of a Titleblock Template in Paperspace Layouts

Discussion in 'AutoCAD' started by matt_1ca, Mar 18, 2005.

  1. matt_1ca

    matt_1ca Guest

    Does anyone know how I can change the orientation of a titleblock template in paperspace layouts using VB?

    I have created a program the works in paperspace -- it creates layouts and inserts titleblocks in them which gets populated with information that I extract from my modelspace drawing.

    So far I have been successful in it -- but the only thing standing in the way is the size and orientation of the paper --

    I will need to be able to control both of it through code -- to really succeed and I do not know how to do it.

    Manually, what I am describing can be accomplished by right clicking the paperspace layout tab thence clicking page setup of the popup menu and choosing say for example
    8.5" x 14" and portrait for drawing orientation.

    So far I have had no luck trying to figure this one out -- the closest thing I've got seems to be GetPaperSize for retrieving dimensions but how about setting them -- and then changing the orientation from say landscape to portrait and vise versa -- is it possible?

    Thank you so much for all the kind help you can give.

    Matt
     
    matt_1ca, Mar 18, 2005
    #1
  2. matt_1ca

    matt_1ca Guest

    The kind of code that I call with sendcommand from VB is shown below:

    (defun TitleblockInsert(strInblock)
    (setq inblock strinblock)
    (setq clay (getvar "clayer"))
    (setq osmode (getvar "osmode"))
    (setvar "cmdecho" 0)
    (setvar "osmode" 0)
    (setvar "attreq" 0)
    (command "expert" 1)
    (setq iopset strinblock)
    (command "layout" "n" iopset)
    (command "layout" "s" iopset)
    (setq layall (ssget "x" '((0 . "VIEWPORT"))))
    (command "erase" layall "")
    (setq blkinspt (list 0 0 0))
    (setq MviewsW (list (car blkinspt) (+ (cadr blkinspt) 94)))
    (setq Mviewne (list (+ (car blkinspt) 203) (+ (cadr blkinspt) 291)))
    (setvar "clayer" "defpoints")
    (command "mview" Mviewsw Mviewne)
    (command "expert" 0)
    (setq inspt (list 0 0 0))
    (setq iopnum iopset)
    (setq blkinspt (list 0 0 0))
    (setq view1se (list (+ (car blkinspt) (* 203.4 1)) (- (cadr blkinspt) (* 0.4 1))))
    (setq view1nw (list (- (car view1se) (* 203.8 1)) (+ (cadr view1se) (* 343.8 1))))
    (command "-view" "w" iopno view1se view1nw)

    (if (= inblock "mytitleblock-1")
    (progn
    (command "-insert" "mytitleblock-1" inspt "" "" ""

    )
    )
    )



    (if (= inblock "mytitleblock-2")
    (progn
    (command "-insert" "mytitleblock-2" inspt "" "" ""
    )
    )
    )


    (if (= inblock "mytitleblock-3")
    (progn
    (command "-insert" "mytitleblock-3" inspt "" "" ""
    )
    )
    )




    (if (= inblock "mytitleblock-4")
    (progn
    (command "-insert" "mytitleblock-4" inspt "" "" ""

    )
    )
    )

    (setvar "attreq" 1)

    )

    It does what I want it -- inserts the titleblock that I want into a layout in paperspace.

    In the example code shown above it will insert a portrait type of titleblock -- when this portrait 8.5" x 14" gets inserted into a landscape of a different size then I start getting problems and hence my need to manipulate layout size and orientation.

    Thank you so much for all the kind help you can give.

    Matt
     
    matt_1ca, Mar 18, 2005
    #2
  3. matt_1ca

    Jackrabbit Guest

    From AutoCAD Help...

    [pre]

    To set the paper size, use the CanonicalMediaName property.


    --------------------------------------------------------------------------------
    CanonicalMediaName Property

    Specifies the paper size by name.

    Signature

    object.CanonicalMediaName

    object

    Layout, PlotConfiguration
    The object or objects this property applies to.

    CanonicalMediaName

    String; read-write
    The name of the paper size.

    Remarks

    Changes to this property will not be visible until after a regeneration of
    the drawing. Use the Regen method to regenerate the drawing.
    [/pre]
     
    Jackrabbit, Mar 18, 2005
    #3
  4. matt_1ca

    matt_1ca Guest

    Hello and thank you for your answer -

    I did see this method before and was thinking it might be the possible solution -- but I figured maybe I'd like to hear what people would say -- so as soon as I got your answer I tried it out right away and it worked like magic for changing the size of the paper that is -- like for example when a paper is oriented landscape and has Envelope size and I change it to Legal -- it does exactly that -- unfortunately -- the method does not change the orientation of the paper to legal size portrait so it did solve one of the two problems but left the other one (changing orientation) unsolved.

    Thanks again,
    Matt
     
    matt_1ca, Mar 18, 2005
    #4
  5. matt_1ca

    matt_1ca Guest

    Its okay everybody -- please consider this question closed -- I figured out how to rotate orientation of the layout and it is
    layout.plotrotation --

    Thanks again,
    Matt
     
    matt_1ca, Mar 18, 2005
    #5
  6. Hate to burst your bubble, but that is not reliable.

    What you need to do is retrieve the height/width of the current device's
    paper size and the layout's size [extmin/extmax] and comapring the two to
    calculate whether to rotate or not. For instance, if the layout is
    portrait, but the printer's paper is landscape, your rotate will over
    rotate it.

    -- Mike
    ___________________________
    Mike Tuersley
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Mar 18, 2005
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.