Author Topic: Layout and viewport questions  (Read 3298 times)

0 Members and 1 Guest are viewing this topic.

csgoh

  • Newt
  • Posts: 176
Layout and viewport questions
« on: August 23, 2006, 11:35:26 PM »
I am writing a function whereby it adds a new layout named "QTF".
I have 2 questions :-

i)  How do one get the vla-object of the viewport in the active layout  and how to delete it?

ii) In a active layout, how to change the viewport say, from a regular rectangular shape to a irregular shape ?

My code so far to create a new layout named "QTF".

Code: [Select]
(defun wg:StartPlot (PlotLotPT-list /
                        FromToPT-List   GB:pSpace    ALL-LAYOUTS   Layout-List
                        ss
                    )
 (foreach plot PlotLotPT-list
  (if (and (>= (nth 2 plot) (atoi frompt))
           (<= (nth 2 plot) (atoi topt))
      )
     (setq FromToPT-List (cons plot FromToPT-List))
  );if
 );foreach


  ;;
  ;; IAcadPaperspace Collection
  ;;
       (setq  GB:acadObj           (vlax-get-acad-object)
        ;; acad Object
        GB:ActivedocumentObj (vla-get-Activedocument GB:acadObj)
        GB:pSpace   (vla-get-PaperSpace GB:ActivedocumentObj))
        ;; the paperspace collection

 (setq objLAYOUTS (vla-get-layouts GB:ActivedocumentObj)
       Layouts-List (WG:GetName-any-type objLayouts) ; existing layouts
 )

 (if (not (member "QTF" layouts-List))
  (progn
   (setq Current-Layout (vl-catch-all-apply 'vla-add (list objLAYOUTS "QTF")))
   (vla-put-ActiveLayout GB:Activedocumentobj Current-Layout)
   (vla-put-PlotRotation Current-Layout 1)
   (vla-regen GB:ActivedocumentObj acActiveViewport)
   (vla-zoomall GB:acadObj)

   (setq Current-Pviewport (vla-get-ActivePviewport GB:Activedocumentobj))
   (vla-delete current-pviewport)
  )
 )

); wg:StartPlot


(defun WG:GetName-any-type (obj? / name? theList)
  (vlax-for each-item obj?
    (setq name?   (strcase (vla-get-name each-item))
          theList (cons name? theList)
    )
  ) ;_vlax-for
  thelist
) ;_WG:GetName-any-type


Thanks.

KewlToyZ

  • Guest
Re: Layout and viewport questions
« Reply #1 on: August 24, 2006, 12:50:26 PM »
Here is a routine I am using right now creating the layouts.
For the most part we only use layouts for plotting and try to stay away from too many viewports.
Most of it add's plotters and page setups to the drawing.
More or less we set up default dwt files and reference them.

Code: [Select]
(defun c:shtsetup
       (/ shtsz x y UserOk shtnm dialogLoaded dialogShow UserOk2 pens)
  (setup)


  (if (= -1 (setq dcl_id (load_dialog "shtsetup.dcl")))
    (progn
      ;; There's a problem - display a message and set the
      ;; dialogLoaded flag to nil
      (princ "\nCannot load shtsetup.dcl")
      (setq dialogLoaded nil)

    ) ;_ end of progn
    (setq dialogLoaded T)
  ) ;_ end of if

  (if (and dialogLoaded
  (not (new_dialog "shtsetup_mainDialog" dcl_id))
      ) ;_ end of and
    (progn
      ;; There's a problem...
      (princ "\nCannot show dialog shtsetup_mainDialog")
      (setq dialogShow nil)
    ) ;_ end of progn
    (setq dialogShow T)
  ) ;_ end of if


  (action_tile
    "sketchp"
    "(setq shtsz \"SketchP\")"
  )
  (action_tile
    "sketchl"
    "(setq shtsz \"SketchL\")"
  )
  (action_tile
    "22x34"
    "(setq shtsz \"22x34\")"
  )
  (action_tile
    "24x36"
    "(setq shtsz \"24x36\")"
  )
  (action_tile
    "30x42"
    "(setq shtsz \"30x42\")"
  )
  (action_tile
    "30x48"
    "(setq shtsz \"30x48\")"
  )
(action_tile
    "34x44"
    "(setq shtsz \"34x44\")"
  )
  (action_tile
    "36x48"
    "(setq shtsz \"36x48\")"
  )
  (action_tile
    "36x50"
    "(setq shtsz \"36x50\")"
  )
  (action_tile
    "accept"
    (strcat "(done_dialog) (setq UserOk T)")
  )

  (start_dialog)

  (if (= UserOk T)

    (progn
      (setvar "tilemode" 1)
      (command "regenauto" "on")
      (if (and (/= shtsz "SketchP") (/= shtsz "SketchL"))
(delOldSetups)

      )
;;;      (initget 1 "22x34 24x36 30x42 30x48 34x44 36x48 36x50 Sketch")
;;;      (setq
;;; shtsz (getkword
;;; "\nEnter Sheet Size (22x34 24x36 30x42 30x48 34x44 36x48 36x50 Sketch):"
;;;      )
;;;      )
      (setvar "cmdecho" 1)
;      (command "layout"
;       "t"
;       "general/xerox 8830 layouts.dwt"
;      )
      (cond
((= shtsz "22x34")
(command "expert" "2")
(command "layout" "t" "general/22x34.dwt")
(command "22x34")
(setq x 34)
(setq y 22)
(command "layout" "s" "22x34")
(setshtview x y)
;(delOldPageSetups)
(command "psetupin" "general/22x34.dwt" "Plotter01 Full Size")
(command "psetupin" "general/22x34.dwt" "Plotter01 Half Size")
(command "psetupin" "general/22x34.dwt" "Plotter02 Full Size")
(command "psetupin" "general/22x34.dwt" "Plotter02 Half Size")
(command "psetupin" "general/22x34.dwt" "Plotter03 Full Size")
(command "psetupin" "general/22x34.dwt" "Plotter03 Half Size")
(command "psetupin" "general/22x34.dwt" "Plotter04 Full Size")
(command "psetupin" "general/22x34.dwt" "Plotter04 Half Size")
(command "psetupin" "general/22x34.dwt" "Acrobat Distiller Full Size")
(command "psetupin" "general/22x34.dwt" "Acrobat Distiller Half Size")
;(command "psetupin" "general/22x34.dwt" "eDoc PDF Full Size")
;(command "psetupin" "general/22x34.dwt" "eDoc PDF Half Size")
(command "psetupin" "general/22x34.dwt" "Plot to File Full Size")
(command "psetupin" "general/22x34.dwt" "Plot to File Half Size")
;(command "psetupin" "general/22x34.dwt" "Old Bond Plotter Full Size")
;(command "psetupin" "general/22x34.dwt" "Old Bond Plotter Half Size")
;(command "psetupin" "general/22x34.dwt" "Old Vellum Plotter Full Size")
;(command "psetupin" "general/22x34.dwt" "Old Vellum Plotter Half Size")
(command "expert" "0")
(command "model")
)

((= shtsz "24x36")
(command "expert" "2")
(command "layout" "t" "general/24x36.dwt")
(command "24x36")
(setq x 36)
(setq y 24)
(command "layout" "s" "24x36")
(setshtview x y)
(command "psetupin" "general/24x36.dwt" "Plotter01 Full Size")
(command "psetupin" "general/24x36.dwt" "Plotter01 Half Size")
(command "psetupin" "general/24x36.dwt" "Plotter02 Full Size")
(command "psetupin" "general/24x36.dwt" "Plotter02 Half Size")
(command "psetupin" "general/24x36.dwt" "Plotter03 Full Size")
(command "psetupin" "general/24x36.dwt" "Plotter03 Half Size")
(command "psetupin" "general/24x36.dwt" "Plotter04 Full Size")
(command "psetupin" "general/24x36.dwt" "Plotter04 Half Size")
(command "psetupin" "general/24x36.dwt" "Acrobat Distiller Full Size")
(command "psetupin" "general/24x36.dwt" "Acrobat Distiller Half Size")
;(command "psetupin" "general/24x36.dwt" "eDoc PDF Full Size")
;(command "psetupin" "general/24x36.dwt" "eDoc PDF Half Size")
(command "psetupin" "general/24x36.dwt" "Plot to File Full Size")
(command "psetupin" "general/24x36.dwt" "Plot to File Half Size")
;(command "psetupin" "general/24x36.dwt" "Old Bond Plotter Full Size")
;(command "psetupin" "general/24x36.dwt" "Old Bond Plotter Half Size")
;(command "psetupin" "general/24x36.dwt" "Old Vellum Plotter Full Size")
;(command "psetupin" "general/24x36.dwt" "Old Vellum Plotter Half Size")
(command "expert" "0")
(command "model")
)
((= shtsz "30x42")
(command "expert" "2")
(command "layout" "t" "general/30x42.dwt")
(command "30x42")
(setq x 42)
(setq y 30)
(command "layout" "s" "30x42")
(setshtview x y)
(command "psetupin" "general/30x42.dwt" "Plotter01 Full Size")
(command "psetupin" "general/30x42.dwt" "Plotter01 Half Size")
(command "psetupin" "general/30x42.dwt" "Plotter02 Full Size")
(command "psetupin" "general/30x42.dwt" "Plotter02 Half Size")
(command "psetupin" "general/30x42.dwt" "Plotter03 Full Size")
(command "psetupin" "general/30x42.dwt" "Plotter03 Half Size")
(command "psetupin" "general/30x42.dwt" "Plotter04 Full Size")
(command "psetupin" "general/30x42.dwt" "Plotter04 Half Size")
  (command "psetupin" "general/30x42.dwt" "Acrobat Distiller Full Size")
(command "psetupin" "general/30x42.dwt" "Acrobat Distiller Half Size")
;(command "psetupin" "general/30x42.dwt" "eDoc PDF Full Size")
;(command "psetupin" "general/30x42.dwt" "eDoc PDF Half Size")
(command "psetupin" "general/30x42.dwt" "Plot to File Full Size")
(command "psetupin" "general/30x42.dwt" "Plot to File Half Size")
;(command "psetupin" "general/30x42.dwt" "Old Bond Plotter Full Size")
;(command "psetupin" "general/30x42.dwt" "Old Bond Plotter Half Size")
;(command "psetupin" "general/30x42.dwt" "Old Vellum Plotter Full Size")
;(command "psetupin" "general/30x42.dwt" "Old Vellum Plotter Half Size")
(command "expert" "0")
(command "model")
)
((= shtsz "30x48")
(command "expert" "2")
(command "layout" "t" "general/30x48.dwt")
(command "30x48")
(setq x 48)
(setq y 30)
(command "layout" "s" "30x48")
(setshtview x y)
(delOldPageSetups)
(command "psetupin" "general/30x48.dwt" "Plotter01 Full Size")
(command "psetupin" "general/30x48.dwt" "Plotter01 Half Size")
(command "psetupin" "general/30x48.dwt" "Plotter02 Full Size")
(command "psetupin" "general/30x48.dwt" "Plotter02 Half Size")
(command "psetupin" "general/30x48.dwt" "Plotter03 Full Size")
(command "psetupin" "general/30x48.dwt" "Plotter03 Half Size")
(command "psetupin" "general/30x48.dwt" "Plotter04 Full Size")
(command "psetupin" "general/30x48.dwt" "Plotter04 Half Size")
(command "psetupin" "general/30x48.dwt" "Acrobat Distiller Full Size")
(command "psetupin" "general/30x48.dwt" "Acrobat Distiller Half Size")
;(command "psetupin" "general/30x48.dwt" "eDoc PDF Full Size")
;(command "psetupin" "general/30x48.dwt" "eDoc PDF Half Size")
(command "psetupin" "general/30x48.dwt" "Plot to File Full Size")
(command "psetupin" "general/30x48.dwt" "Plot to File Half Size")
;(command "psetupin" "general/30x48.dwt" "Old Bond Plotter Full Size")
;(command "psetupin" "general/30x48.dwt" "Old Bond Plotter Half Size")
;(command "psetupin" "general/30x48.dwt" "Old Vellum Plotter Full Size")
;(command "psetupin" "general/30x48.dwt" "Old Vellum Plotter Half Size")
(command "expert" "0")
(command "model")
)
((= shtsz "34x44")
(command "expert" "2")
(command "layout" "t" "general/34x44.dwt")
(command "34x44")
(setq x 44)
(setq y 34)
(command "layout" "s" "34x44")
(setshtview x y)
(command "psetupin" "general/34x44.dwt" "Plotter01 Full Size")
(command "psetupin" "general/34x44.dwt" "Plotter01 Half Size")
(command "psetupin" "general/34x44.dwt" "Plotter02 Full Size")
(command "psetupin" "general/34x44.dwt" "Plotter02 Half Size")
(command "psetupin" "general/34x44.dwt" "Plotter03 Full Size")
(command "psetupin" "general/34x44.dwt" "Plotter03 Half Size")
(command "psetupin" "general/34x44.dwt" "Plotter04 Full Size")
(command "psetupin" "general/34x44.dwt" "Plotter04 Half Size")
(command "psetupin" "general/34x44.dwt" "Acrobat Distiller Full Size")
(command "psetupin" "general/34x44.dwt" "Acrobat Distiller Half Size")
;(command "psetupin" "general/34x44.dwt" "eDoc PDF Full Size")
;(command "psetupin" "general/34x44.dwt" "eDoc PDF Half Size")
(command "psetupin" "general/34x44.dwt" "Plot to File Full Size")
(command "psetupin" "general/34x44.dwt" "Plot to File Half Size")
;(command "psetupin" "general/34x44.dwt" "Old Bond Plotter Full Size")
;(command "psetupin" "general/34x44.dwt" "Old Bond Plotter Half Size")
;(command "psetupin" "general/34x44.dwt" "Old Vellum Plotter Full Size")
;(command "psetupin" "general/34x44.dwt" "Old Vellum Plotter Half Size")
(command "expert" "0")
(command "model")
)
((= shtsz "36x48")
(command "expert" "2")
(command "layout" "t" "general/36x48.dwt")
(command "36x48")
(setq x 48)
(setq y 36)
(command "layout" "s" "36x48")
(setshtview x y)
(command "psetupin" "general/36x48.dwt" "Plotter01 Full Size")
(command "psetupin" "general/36x48.dwt" "Plotter01 Half Size")
(command "psetupin" "general/36x48.dwt" "Plotter02 Full Size")
(command "psetupin" "general/36x48.dwt" "Plotter02 Half Size")
(command "psetupin" "general/34x48.dwt" "Plotter03 Full Size")
(command "psetupin" "general/34x48.dwt" "Plotter03 Half Size")
(command "psetupin" "general/34x48.dwt" "Plotter04 Full Size")
(command "psetupin" "general/34x48.dwt" "Plotter04 Half Size")
(command "psetupin" "general/36x48.dwt" "Acrobat Distiller Full Size")
(command "psetupin" "general/36x48.dwt" "Acrobat Distiller Half Size")
;(command "psetupin" "general/36x48.dwt" "eDoc PDF Full Size")
;(command "psetupin" "general/36x48.dwt" "eDoc PDF Half Size")
(command "psetupin" "general/36x48.dwt" "Plot to File Full Size")
(command "psetupin" "general/36x48.dwt" "Plot to File Half Size")
;(command "psetupin" "general/36x48.dwt" "Old Bond Plotter Full Size")
;(command "psetupin" "general/36x48.dwt" "Old Bond Plotter Half Size")
;(command "psetupin" "general/36x48.dwt" "Old Vellum Plotter Full Size")
;(command "psetupin" "general/36x48.dwt" "Old Vellum Plotter Half Size")
(command "expert" "0")
(command "model")
)
((= shtsz "36x50")
(command "expert" "2")
(command "layout" "t" "general/36x50.dwt")
(command "36x50")
(setq x 50)
(setq y 36)
(command "layout" "s" "36x50")
(setshtview x y)
(command "psetupin" "general/36x50.dwt" "Plotter01 Full Size")
(command "psetupin" "general/36x50.dwt" "Plotter01 Half Size")
(command "psetupin" "general/36x50.dwt" "Plotter02 Full Size")
(command "psetupin" "general/36x50.dwt" "Plotter02 Half Size")
(command "psetupin" "general/36x50.dwt" "Plotter03 Full Size")
(command "psetupin" "general/36x50.dwt" "Plotter03 Half Size")
(command "psetupin" "general/36x50.dwt" "Plotter04 Full Size")
(command "psetupin" "general/36x50.dwt" "Plotter04 Half Size")
(command "psetupin" "general/36x50.dwt" "Acrobat Distiller Full Size")
(command "psetupin" "general/36x50.dwt" "Acrobat Distiller Half Size")
;(command "psetupin" "general/36x50.dwt" "eDoc PDF Full Size")
;(command "psetupin" "general/36x50.dwt" "eDoc PDF Half Size")
(command "psetupin" "general/36x50.dwt" "Plot to File Full Size")
(command "psetupin" "general/36x50.dwt" "Plot to File Half Size")
;(command "psetupin" "general/36x50.dwt" "Old Bond Plotter Full Size")
;(command "psetupin" "general/36x50.dwt" "Old Bond Plotter Half Size")
;(command "psetupin" "general/36x50.dwt" "Old Vellum Plotter Full Size")
;(command "psetupin" "general/36x50.dwt" "Old Vellum Plotter Half Size")
(command "expert" "0")
(command "model")
)
((or (= shtsz "SketchP") (= shtsz "SketchL"))


(if (and dialogLoaded
 (not (new_dialog "shtsetup_sketchDialog" dcl_id))
    ) ;_ end of and
  (progn
    ;; There's a problem...
    (princ "\nCannot show dialog shtsetup_sketchDialog")
    (setq dialogShow nil)
  ) ;_ end of progn
  (setq dialogShow T)
) ;_ end of if



(action_tile
  "accept"
  (strcat
    "(setq shtnm (get_tile \"sketchnm\"))"
    "(done_dialog) (setq UserOk2 T)"
  )
)

(start_dialog)
(unload_dialog dcl_id)

(if (and (/= (substr shtnm 1 1) " ")
 (/= shtnm "")
 (= UserOk2 T)
 (= shtsz "SketchP")
    )
  (progn (command "layout" "t" "general/sketchP.dwt")
     (command "8.5 x 11 Sketch")
; (setq shtnm (getstring "\nEnter sketch name:"))
 (command "layout" "rename" "8.5 x 11 Sketch" shtnm)
 (command "layout" "s" shtnm)
 (dosketch)
  )
  (if (and (/= (substr shtnm 1 1) " ")
   (/= shtnm "")
   (= UserOk2 T)
   (= shtsz "SketchL")
      )
    (progn (command "layout" "t" "general/sketchL.dwt")
         (command "11 x 8.5 Sketch");11 x 8.5 Sketch
; (setq shtnm (getstring "\nEnter sketch name:"))
   (command "layout" "rename" "11 x 8.5 Sketch" shtnm)
   (command "layout" "s" shtnm)
   (dosketch)
    )
    (command "")
  )
)




)

      )
    )
  )
  (command "layout" "d" "Layout1")
  (command "layout" "d" "Layout2")

  (initget "A E")
  (setq pens (getkword "\nArchitectural or Engineering pens (A/<E>): "))
  (cond
    ((equal pens "A")
     (setpens "KTA.ctb")
     )
    (t (setpens "KTA.ctb"))
    )
  (end)
)



(defun setshtview (x y / pltwdw)
  (setq x (rtos (* x ds) 2 0))
  (setq y (rtos (* y ds) 2 0))

  (command "layer" "m" "defpoints" "t" "defpoints" "on" "defpoints" "")
  (setvar "tilemode" 0)
  (command "mview" "f")
  (setq pltwdw (entlast))
  (command "mview" "h" "off" pltwdw "")
  (command "mspace")
  (command "zoom" "w" "0,0" (strcat x "," y))
  (command "zoom"
  (strcat "1/" (rtos (getvar "dimscale") 2 0) "xp")
  )
  (command "pspace")
  (setvar "psltscale" 0)
  (command "zoom" "e")

)

(defun dosketch (/ now ntt p1 scl)
  (lrs "DefPoints")

  (setq
    now
     (getint "\Enter number of windows to open <1>/2/3(maximum):"
     )
  )
  (if (= now 2)
    (setq ntt 1)
  )
  (if (= now 3)
    (setq ntt 2)
  )
  (if (= now nil)
    (setq now 1)
  )
  (repeat now
    (command "mview")
    (princ)
    (command
      (setq
p1 (getpoint "\nSelect first corner of window opening: ")
      )
    )
    (prompt "\n ")
    (command
      (getcorner p1
"\nSelect opposite corner of window opening: "
      )
    )
    (prompt "\n ")
    (command "mspace")
    (command "zoom" "e")
    (command "zoom" "c")
    (command (getpoint "\nSelect center of view:"))
    (command
      (strcat "1/" (rtos (getvar "dimscale") 2 0) "xp")
    )
  ) ;end repeat
  (command "pspace")
  (setvar "psltscale" 0)

)

(defun delOldSetups ()
  (command "layout" "d" "22x34")
(command "layout" "d" "22 x 34 Bond")
  (command "layout" "d" "22 x 34 Half-Size Bond (11 x 17)")
  (command "layout" "d" "22 x 34 Half-Size Vellum (11 x 17)")
  (command "layout" "d" "22 x 34 Vellum")
  (command "layout" "d" "24x36")
  (command "layout" "d" "24 x 36 Bond")
  (command "layout" "d" "24 x 36 Half-Size Bond (12 x 18)")
  (command "layout" "d" "24 x 36 Half-Size Vellum (12 x 18)")
  (command "layout" "d" "24 x 36 Vellum")
  (command "layout" "d" "30x42")
  (command "layout" "d" "30 x 42 Bond")
  (command "layout" "d" "30 x 42 Half-Size Bond (15 x 21)")
  (command "layout" "d" "30 x 42 Half-Size Vellum (15 x 21)")
  (command "layout" "d" "30 x 42 Vellum")
  (command "layout" "d" "30x48")
  (command "layout" "d" "30 x 48 Bond")
  (command "layout" "d" "30 x 48 Half-Size Bond (15 x 24)")
  (command "layout" "d" "30 x 48 Half-Size Vellum (15 x 24)")
  (command "layout" "d" "30 x 48 Vellum")
  (command "layout" "d" "34x44")
  (command "layout" "d" "34 x 44 Bond")
  (command "layout" "d" "34 x 44 Half-Size Bond (17 x 22)")
  (command "layout" "d" "34 x 44 Half-Size Vellum (17 x 22)")
  (command "layout" "d" "34 x 44 Vellum")
  (command "layout" "d" "36x48")
  (command "layout" "d" "36 x 48 Bond")
  (command "layout" "d" "36 x 48 Half-Size Bond (18 x 24)")
  (command "layout" "d" "36 x 48 Half-Size Vellum (18 x 24)")
  (command "layout" "d" "36 x 48 Vellum")
  (command "layout" "d" "36x50")
  (command "layout" "d" "36 x 50 Bond")
  (command "layout" "d" "36 x 50 Half-Size Bond (18 x 25)")
  (command "layout" "d" "36 x 50 Half-Size Vellum (18 x 25)")
  (command "layout" "d" "36 x 50 Vellum")
)
(defun delOldPageSetups ()
  (command "(vl-load-com)")
  (command "(vlax-for page_set (vla-get-plotconfigurations (vla-get-activedocument(vlax-get-acad-object)))(vla-delete page_set))")
)

DCL to follow

KewlToyZ

  • Guest
Re: Layout and viewport questions
« Reply #2 on: August 24, 2006, 12:50:47 PM »
Here is the dcl file:

Code: [Select]
shtsetup_mainDialog : dialog {
label = "Sheet Setup";
: boxed_radio_column {    // defines the radio button areas
  label = "Select Sheet Size";
  : radio_button {        // defines the lightweight radio button
    label = "8-1/2 x 11 Sketch";
    key = "sketchp";
   }
     : radio_button {        // defines the lightweight radio button
    label = "11 x 8-1/2 Sketch";
    key = "sketchl";
   }
: radio_button {       // defines the old-style polyline radio button
  label = "22x34";
  key = "22x34";
 }
: radio_button {       // defines the old-style polyline radio button
  label = "24x36";
  key = "24x36";
 }
: radio_button {       // defines the old-style polyline radio button
  label = "30x42";
  key = "30x42";
 }
 : radio_button {       // defines the old-style polyline radio button
  label = "30x48";
  key = "30x48";
 }
: radio_button {       // defines the old-style polyline radio button
  label = "36x48";
  key = "36x48";
 }
}

: row {          // defines the OK/Cancel button row
  : spacer { width = 1; }
  : button {    // defines the OK button
    label = "OK";
    is_default = true;
    key = "accept";
    width = 8;
    fixed_width = true;
  }
  : button {    // defines the Cancel button
    label = "Cancel";
    is_cancel = true;
    key = "cancel";
    width = 8;
    fixed_width = true;
  }
  : spacer { width = 1;}

}
}

shtsetup_sketchDialog : dialog {
label = "Sketch Name";



: edit_box {      // defines the Radius of Tile edit box
  key = "sketchnm";
 // value = "Sketch ";
  edit_width = 40;
}
: row {          // defines the OK/Cancel button row
  : spacer { width = 1; }
  : button {    // defines the OK button
    label = "OK";
    is_default = true;
    key = "accept";
    width = 8;
    fixed_width = true;
  }
  : button {    // defines the Cancel button
    label = "Cancel";
    is_cancel = true;
    key = "cancel";
    width = 8;
    fixed_width = true;
  }
  : spacer { width = 1;}

}

}

csgoh

  • Newt
  • Posts: 176
Re: Layout and viewport questions
« Reply #3 on: August 24, 2006, 08:43:18 PM »
Thanks, KewlToyZ for your lisp but it does not answer the questions I posted.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layout and viewport questions
« Reply #4 on: August 25, 2006, 11:28:55 AM »
This will show you how to create a layout:

From this code, http://www.theswamp.org/index.php?topic=443.msg5448#msg5448
here is a modified version to create layouts: <just changed the rtos to force decimal>

Code: [Select]
(defun c:addlayouts (/ laylst loutsnum n)
  (vl-load-com) ; or else
  (setq loutsnum (getint "Enter the number of layouts to create: "))
  (setq laylst (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))))
  (setq n (vlax-get-property laylst 'count))
  (setq loutsnum (+ n loutsnum))
  (while (< n loutsnum)
    (vla-add laylst (strcat "Layout X" (rtos n 2 0)))
    (setq n (1+ n))
  )
)

Here is an example that copies the settings from an existing layout.
http://tinyurl.com/pg8ec

The "sourcelayoutname" must exist in your drawing.

Code: [Select]
(defun c:test ()
  (setq ; get active x objects
    acadobj       (vlax-get-acad-object)
    curdoc        (vla-get-activedocument acadobj)
    layouts       (vla-get-layouts curdoc)
    new_layout    (vla-add layouts "newlayoutname")
    source_layout (vla-item layouts "sourcelayoutname") ; existing layout to copy properties from
  )
  (vla-copyfrom new_layout source_layout)
)


Sister thread: http://forums.augi.com/showthread.php?t=45561
« Last Edit: August 25, 2006, 11:44:01 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layout and viewport questions
« Reply #5 on: August 25, 2006, 11:40:33 AM »
« Last Edit: August 25, 2006, 11:45:05 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layout and viewport questions
« Reply #6 on: August 25, 2006, 12:14:50 PM »
How about this for creating a layout without a viewport?
Code: [Select]
(defun c:test ()
  (setq gb:acadobj           (vlax-get-acad-object)
        gb:activedocumentobj (vla-get-activedocument gb:acadobj)
        gb:pspace            (vla-get-paperspace gb:activedocumentobj)
  )

  ;; the paperspace collection
  (setq objlayouts   (vla-get-layouts gb:activedocumentobj)
        layouts-list (wg:getname-any-type objlayouts) ; existing layouts
  )


  (setq new_layout (vl-catch-all-apply 'vla-add (list objlayouts "QTF")))
  (if (setq tab1-name (cadr layouts-list))
    (progn
      (setq source_layout (vla-item layouts tab1-name))
      (vla-copyfrom new_layout source_layout)
      (vla-put-activelayout gb:activedocumentobj new_layout)
    )
  )
  (vla-put-plotrotation new_layout 1)



  (princ)
)


(defun wg:getname-any-type (obj? / thelist)
  (vlax-for each-item obj?
    (setq thelist (cons (strcase (vla-get-name each-item)) thelist))
  )
  thelist
) ;_WG:GetName-any-type
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layout and viewport questions
« Reply #7 on: August 25, 2006, 12:32:09 PM »
   As for creating an "Irregular Viewport" I haven't found any info on that yet.
   Out of time here, Ill check back later.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

csgoh

  • Newt
  • Posts: 176
Re: Layout and viewport questions
« Reply #8 on: August 26, 2006, 12:31:16 PM »
Thanks, Cab.

In the meantime, I have added a dialog box for selecting the plotter, paper size and the ctb plotstyle pens and it seems to be working well.

In my lisp, I have chosen the plot scale to be 1 : 1 ,portrait orientation and plot in mm. HOWEVER, when I go to the pagesetup, the settings is for inches. It seems that the data is not updated. Please see the P3.PNG picture for better picture. By the way, I am using AutocadMap 4 with winXP pro.
I have also experienced a problem when plotting and I always have to click the papersize even though it is the same paper size. If not the plot offsets is diffferent when I center the plot. Is there some variable I have not set? Pls advise.

I have attached my lisp and other related files required and hope some gurus could help me out why the above is happening.

I have also tried this lisp in Autocad 2005 and it crash midway after the PLOT QT dialog> What is wrong anyway? It would be great if someone can advise me. Thanks.


csgoh

  • Newt
  • Posts: 176
Re: Layout and viewport questions
« Reply #9 on: August 27, 2006, 09:21:27 AM »
I did a search and found this thread http://www.theswamp.org/index.php?topic=9363.0 regarding updating Layout Object with plot settings by T.Wiley having a problem of not updating. Makes me wonder if acad2004 has a problem updating certain records.

Regarding the crash in acad2005,  it happen in acad 2004 too, I found that the problem lies is the plotstyletablenames where it contains a ".stb" file  in one of the list. To solve this I need to set the pstylepolicy variable to 1 for ctb. file - I think.

One question, is there a commandline equivalent for the dialog box command of the pagesetup command?