DCL

Discussion in 'AutoCAD' started by BParker35, Dec 1, 2004.

  1. BParker35

    BParker35 Guest

    Hi,

    I have a lisp in conjunction with a DCL. My lisp makes a layer so it is a choice in my DCL's pull down. How can I make that layer the default choice in the pull down? Any help would be greatly appreciated.

    Thanks in advance,

    BP
     
    BParker35, Dec 1, 2004
    #1
  2. BParker35

    ECCAD Guest

    BP,
    The following is a sample of 'how' to set a list element current,
    as you fire up the DCL list...
    In your existing lisp code, setq 'lay_name' with the Layername
    --------------------
    (setq lay_name "LAYERNAME"); Layer to set as default..
    (start_list "layer_lst") (mapcar 'add_list lay_lst) (end_list)

    ;; Dialog control..
    ;;
    (setq chk_file "C:/acad/testlayer.dcl")
    (setq dcl_id (load_dialog chk_file))
    (if (not (new_dialog "layer_chk" dcl_id)) (exit))
    (start_list "layer_lst") (mapcar 'add_list lay_lst) (end_list)
    (mode_tile "layer_lst" 2)
    (if (/= lay_name nil); get 'list index of default layer
    (setq _j (itoa (- (length lay_lst) (length (member lay_name lay_lst)))))
    (setq _j "0"); else, set top of list..
    ); end if
    (set_tile "layer_lst" _j)

    ;; Fire-up the Dialog
    (setq what_next 7)
    (while (/= 4 what_next)
    (action_tile "layer_lst" "(done_dialog 4)")
    (action_tile "accept" "(done_dialog 4)")
    (action_tile "cancel" "(setq Abort 1)(done_dialog 4)")
    (setq what_next (start_dialog))
    ); end while what_next
    ;;
    (unload_dialog dcl_id)
    ------------------------
    The (main) thing you need is the index to the 'list..e.g.
    (mode_tile "layer_lst" 2)
    (if (/= lay_name nil); get 'list index of default layer
    (setq _j (itoa (- (length lay_lst) (length (member lay_name lay_lst)))))
    (setq _j "0"); else, set top of list..
    ); end if
    (set_tile "layer_lst" _j)
    .... _j is set to the 'location' within the list, and (set_tile "layer_lst" _j)...... points to that element.

    Bob
     
    ECCAD, Dec 1, 2004
    #2
  3. BParker35

    BillZ Guest

    BParker35,

    In your lisp.

    (set_tile "dropdownkey" "indexoflist")

    Then be sure to get that value when okay is pressed.

    Bill
     
    BillZ, Dec 1, 2004
    #3
  4. BParker35

    BParker35 Guest

    Still can get a-anno-note to be the default selection in my layer pulldown.

    LISP PART

    (command "-layer" "n" "A-Anno-Note" "")


    ; Side (a) and Angle (A) Known
    ;
    (defun aE ()
    (setq sidea sidea_len)
    (setq sidec (/ sidea (sin anga)))
    (setq sideb (sqrt (- (* sidec sidec) (* sidea sidea))))
    )
    ;
    ;
    ; Side (b) and Angle (A) Known
    ;
    ;
    (defun bD ()
    (setq sideb sideb_len)
    (setq sidec (/ sideb (cos anga)))
    (setq sidea (sqrt (- (* sidec sidec) (* sideb sideb))))
    )
    ;
    ;
    ;
    ;
    (defun s1 ()
    (setq p2x (+ p1x sidea_len))
    (setq p2y p1y)
    (setq p2 (list p2x p2y))
    (setq p3x p2x)
    (setq p3y (+ p2y sidea))
    (setq p3 (list p3x p3y))
    (setq p4x (+ p1x (* 0.5 sidea_len)))
    (setq p4y (- p1y xtxt2))
    (setq p4 (list p4x p4y))
    (setq p5x (+ p2x ytxt))
    (setq p5y (+ p2y (* 0.5 sidea)))
    (setq p5 (list p5x p5y))
    (setq sidea (rtos (* (/ 1 ds) 24 sidea) 5 4))
    (command "line" pS p2 p3)
    (command "")
    (command "text" "c" p4 txtht 0 12)
    (command "text" p5 txtht 0 sidea)
    )
    ;
    ;
    ;
    ;
    (defun s2 ()
    (setq p2x p1x)
    (setq p2y (+ p1y sidea_len))
    (setq p2 (list p2x p2y))
    (setq p3x (+ p2x sideb))
    (setq p3y p2y)
    (setq p3 (list p3x p3y))
    (setq p4x (- p1x ytxt))
    (setq p4y (+ p1y (* 0.5 sidea_len)))
    (setq p4 (list p4x p4y))
    (setq p5x (+ p2x (* 0.5 sideb)))
    (setq p5y (+ p2y xtxt1))
    (setq p5 (list p5x p5y))
    (setq sideb (rtos (* (/ 1 ds) 24 sideb) 5 4))
    (command "line" pS p2 p3)
    (command "")
    (command "text" "r" p4 txtht 0 12)
    (command "text" "c" p5 txtht 0 sideb)
    )
    ;
    ;
    ;
    ;
    (defun s3 ()
    (setq p2x p1x)
    (setq p2y (+ p1y sidea_len))
    (setq p2 (list p2x p2y))
    (setq p3x (- p2x sideb))
    (setq p3y p2y)
    (setq p3 (list p3x p3y))
    (setq p4x (+ p1x ytxt))
    (setq p4y (+ p1y (* 0.5 sidea_len)))
    (setq p4 (list p4x p4y))
    (setq p5x (- p2x (* 0.5 sideb)))
    (setq p5y (+ p2y xtxt1))
    (setq p5 (list p5x p5y))
    (setq sideb (rtos (* (/ 1 ds) 24 sideb) 5 4))
    (command "line" pS p2 p3)
    (command "")
    (command "text" p4 txtht 0 12)
    (command "text" "c" p5 txtht 0 sideb)
    )
    ;
    ;
    ;
    ;
    (defun s4 ()
    (setq p2x (- p1x sidea_len))
    (setq p2y p1y)
    (setq p2 (list p2x p2y))
    (setq p3x p2x)
    (setq p3y (+ p2y sidea))
    (setq p3 (list p3x p3y))
    (setq p4x (- p1x (* 0.5 sidea_len)))
    (setq p4y (- p1y xtxt2))
    (setq p4 (list p4x p4y))
    (setq p5x (- p2x ytxt))
    (setq p5y (+ p2y (* 0.5 sidea)))
    (setq p5 (list p5x p5y))
    (setq sidea (rtos (* (/ 1 ds) 24 sidea) 5 4))
    (command "line" pS p2 p3)
    (command "")
    (command "text" "c" p4 txtht 0 12)
    (command "text" "r" p5 txtht 0 sidea)
    )
    ;
    ;
    ;
    ;
    (defun s5 ()
    (setq p2x (- p1x sidea_len))
    (setq p2y p1y)
    (setq p2 (list p2x p2y))
    (setq p3x p2x)
    (setq p3y (- p2y sidea))
    (setq p3 (list p3x p3y))
    (setq p4x (- p1x (* 0.5 sidea_len)))
    (setq p4y (+ p1y xtxt1))
    (setq p4 (list p4x p4y))
    (setq p5x (- p2x ytxt))
    (setq p5y (- p2y (* 0.5 sidea)))
    (setq p5 (list p5x p5y))
    (setq sidea (rtos (* (/ 1 ds) 24 sidea) 5 4))
    (command "line" pS p2 p3)
    (command "")
    (command "text" "c" p4 txtht 0 12)
    (command "text" "r" p5 txtht 0 sidea)
    )
    ;
    ;
    ;
    ;
    (defun s6 ()
    (setq p2x p1x)
    (setq p2y (- p1y sidea_len))
    (setq p2 (list p2x p2y))
    (setq p3x (- p2x sideb))
    (setq p3y p2y)
    (setq p3 (list p3x p3y))
    (setq p4x (+ p1x ytxt))
    (setq p4y (- p1y (* 0.5 sidea_len)))
    (setq p4 (list p4x p4y))
    (setq p5x (- p2x (* 0.5 sideb)))
    (setq p5y (- p2y xtxt2))
    (setq p5 (list p5x p5y))
    (setq sideb (rtos (* (/ 1 ds) 24 sideb) 5 4))
    (command "line" pS p2 p3)
    (command "")
    (command "text" p4 txtht 0 12)
    (command "text" "c" p5 txtht 0 sideb)
    )
    ;
    ;
    ;
    ;
    (defun s7 ()
    (setq p2x p1x)
    (setq p2y (- p1y sidea_len))
    (setq p2 (list p2x p2y))
    (setq p3x (+ p2x sideb))
    (setq p3y p2y)
    (setq p3 (list p3x p3y))
    (setq p4x (- p1x ytxt))
    (setq p4y (- p1y (* 0.5 sidea_len)))
    (setq p4 (list p4x p4y))
    (setq p5x (+ p2x (* 0.5 sideb)))
    (setq p5y (- p2y xtxt2))
    (setq p5 (list p5x p5y))
    (setq sideb (rtos (* (/ 1 ds) 24 sideb) 5 4))
    (command "line" pS p2 p3)
    (command "")
    (command "text" "r" p4 txtht 0 12)
    (command "text" "c" p5 txtht 0 sideb)
    )
    ;
    ;
    ;
    ;
    (defun s8 ()
    (setq p2x (+ p1x sidea_len))
    (setq p2y p1y)
    (setq p2 (list p2x p2y))
    (setq p3x p2x)
    (setq p3y (- p2y sidea))
    (setq p3 (list p3x p3y))
    (setq p4x (+ p1x (* 0.5 sidea_len)))
    (setq p4y (+ p1y xtxt1))
    (setq p4 (list p4x p4y))
    (setq p5x (+ p2x xtxt2))
    (setq p5y (- p2y (* 0.5 sidea)))
    (setq p5 (list p5x p5y))
    (setq sidea (rtos (* (/ 1 ds) 24 sidea) 5 4))
    (command "line" pS p2 p3)
    (command "")
    (command "text" "c" p4 txtht 0 12)
    (command "text" p5 txtht 0 sidea)
    )
    ;
    ;
    ;
    ;
    (defun slope-a ()
    (setvar "cmdecho" 0)
    (setq cl (getvar "clayer"))
    (setq ds (getvar "dimscale"))
    (setq st (getvar "textstyle"))
    (if (= lay "T")
    (setvar "clayer" cl)
    (setvar "clayer" lay)
    )
    (if (= sty "T")
    (setvar "textstyle" st)
    (setvar "textstyle" sty)
    )
    (setq sidea_len (* 0.5 ds))
    (setq sideb_len (* 0.5 ds))
    (setq txtht (* ds 0.0625))
    (setq ytxt (* ds 0.125))
    (setq xtxt1 (* ds 0.125))
    (setq xtxt2 (+ txtht (* ds 0.125)))
    (setq a (entsel))
    (setq b (car a))
    (setq c (entget b))
    (setq p1s (assoc 10 c))
    (setq p1 (cdr p1s))
    (setq p2s (assoc 11 c))
    (setq p2 (cdr p2s))
    (setq anga (angle p1 p2))
    (setq an (angtos anga 0 4))
    (setq an (atof an))
    (setq quad1 (/ an 45))
    (if (= quad1 0) (setq quad "1"))
    (if (and (> quad1 0) (<= quad1 1)) (setq quad "1"))
    (if (and (> quad1 1) (<= quad1 2)) (setq quad "2"))
    (if (and (> quad1 2) (<= quad1 3)) (setq quad "3"))
    (if (and (> quad1 3) (<= quad1 4)) (setq quad "4"))
    (if (and (> quad1 4) (<= quad1 5)) (setq quad "5"))
    (if (and (> quad1 5) (<= quad1 6)) (setq quad "6"))
    (if (and (> quad1 6) (<= quad1 7)) (setq quad "7"))
    (if (and (> quad1 7) (<= quad1 8)) (setq quad "8"))
    (if (= quad "0") (setq quad "1"))
    (if (= quad "1") (bD))
    (if (= quad "2") (aE))
    (if (= quad "3") (aE))
    (if (= quad "4") (bD))
    (if (= quad "5") (bD))
    (if (= quad "6") (aE))
    (if (= quad "7") (aE))
    (if (= quad "8") (bD))
    (setq pS (getpoint "Select Point for Slope Start: "))
    (setq p1x (car pS))
    (setq p1y (cadr pS))
    (if (= quad "1") (s5))
    (if (= quad "2") (s2))
    (if (= quad "3") (s3))
    (if (= quad "4") (s8))
    (if (= quad "5") (s5))
    (if (= quad "6") (s2))
    (if (= quad "7") (s3))
    (if (= quad "8") (s8))
    )
    ;
    ;
    ;
    ;
    (defun slope-b ()
    (setvar "cmdecho" 0)
    (setq cl (getvar "clayer"))
    (setq ds (getvar "dimscale"))
    (setq st (getvar "textstyle"))
    (if (= lay "T")
    (setvar "clayer" cl)
    (setvar "clayer" lay)
    )
    (if (= sty "T")
    (setvar "textstyle" st)
    (setvar "textstyle" sty)
    )
    (setq sidea_len (* 0.5 ds))
    (setq sideb_len (* 0.5 ds))
    (setq txtht (* ds 0.0625))
    (setq ytxt (* ds 0.125))
    (setq xtxt1 (* ds 0.125))
    (setq xtxt2 (+ txtht (* ds 0.125)))
    (setq a (entsel))
    (setq b (car a))
    (setq c (entget b))
    (setq p1s (assoc 10 c))
    (setq p1 (cdr p1s))
    (setq p2s (assoc 11 c))
    (setq p2 (cdr p2s))
    (setq anga (angle p1 p2))
    (setq an (angtos anga 0 4))
    (setq an (atof an))
    (setq quad1 (/ an 45))
    (if (= quad1 0) (setq quad "1"))
    (if (and (> quad1 0) (<= quad1 1)) (setq quad "1"))
    (if (and (> quad1 1) (<= quad1 2)) (setq quad "2"))
    (if (and (> quad1 2) (<= quad1 3)) (setq quad "3"))
    (if (and (> quad1 3) (<= quad1 4)) (setq quad "4"))
    (if (and (> quad1 4) (<= quad1 5)) (setq quad "5"))
    (if (and (> quad1 5) (<= quad1 6)) (setq quad "6"))
    (if (and (> quad1 6) (<= quad1 7)) (setq quad "7"))
    (if (and (> quad1 7) (<= quad1 8)) (setq quad "8"))
    (if (= quad "1") (bD))
    (if (= quad "2") (aE))
    (if (= quad "3") (aE))
    (if (= quad "4") (bD))
    (if (= quad "5") (bD))
    (if (= quad "6") (aE))
    (if (= quad "7") (aE))
    (if (= quad "8") (bD))
    (setq pS (getpoint "Select Point for Slope Start: "))
    (setq p1x (car pS))
    (setq p1y (cadr pS))
    (if (= quad "1") (s1))
    (if (= quad "2") (s6))
    (if (= quad "3") (s7))
    (if (= quad "4") (s4))
    (if (= quad "5") (s1))
    (if (= quad "6") (s6))
    (if (= quad "7") (s7))
    (if (= quad "8") (s4))
    )
    ;
    ;
    ;
    (defun set_view ()
    (if (= vw 1)
    (progn
    (setq x (dimx_tile "image")
    y (dimy_tile "image"))
    (start_image "image")
    (fill_image 0 0 x y 0)
    (slide_image 0 0 x y "slope1")
    (end_image)))

    (if (= vw 2)
    (progn
    (setq x (dimx_tile "image")
    y (dimy_tile "image"))
    (start_image "image")
    (fill_image 0 0 x y 0)
    (slide_image 0 0 x y "slope2")
    (end_image)))

    )
    ;
    ;
    ;
    (defun set_tbl_list ()
    (setq elist (tblnext "layer" 1))
    (setq code 2)
    (setq lay_count 0)
    (if (not
    (or (= (cdr (assoc 70 elist)) 65) (= (cdr (assoc 70 elist)) 69)))
    (setq tbl_list (list (cdr (assoc code elist))))
    (setq lay_count (+ lay_count 1))
    )
    ;(setq tbl_list (list (dxf_list 2 (tblnext "layer" 1))))
    (while (setq t (tblnext "layer"))
    (if (not
    (or (= (cdr (assoc 70 t)) 65) (= (cdr (assoc 70 t)) 69)))
    (setq tbl_list (cons (cdr (assoc code t)) tbl_list))
    (setq lay_count (+ lay_count 1))
    )
    ;(setq tbl_list (cons (dxf_list 2 t) tbl_list))
    )
    (setq tbl_list (reverse tbl_list))
    (start_list "la_list")
    (mapcar 'add_list tbl_list)
    (end_list)
    (setq lay_count (strcat (rtos lay_count 2 0) " layers are Frozen"))
    (set_tile "message" lay_count)

    )
    ;
    ;
    ;
    (defun set_lay ()
    (setq count lay_draw)
    (setq tbl_list2 tbl_list)
    (if (= count 0) (setq lay (car tbl_list2)))
    (while (> count 0)
    (setq tbl_list2 (cdr tbl_list2))
    (setq lay (car tbl_list2))
    (setq count (- count 1))
    )
    )
    ;
    ;
    ;
    (defun set_style_list ()
    (setq elist (tblnext "style" 1))
    (setq code 2)
    (setq style_count 0)
    (if (not
    (or (= (cdr (assoc 70 elist)) 65) (= (cdr (assoc 70 elist)) 69)))
    (setq st_tbl_list (list (cdr (assoc code elist))))
    (setq style_count (+ style_count 1))
    )
    ;(setq tbl_list (list (dxf_list 2 (tblnext "style" 1))))
    (while (setq t (tblnext "style"))
    (if (not
    (or (= (cdr (assoc 70 t)) 65) (= (cdr (assoc 70 t)) 69)))
    (setq st_tbl_list (cons (cdr (assoc code t)) st_tbl_list))
    (setq style_count (+ style_count 1))
    )
    ;(setq tbl_list (cons (dxf_list 2 t) tbl_list))
    )
    (setq st_tbl_list (reverse st_tbl_list))
    (start_list "st_list")
    (mapcar 'add_list st_tbl_list)
    (end_list)

    )
    ;
    ;
    ;
    (defun set_style ()
    (setq count sty_draw)
    (setq tbl_list3 st_tbl_list)
    (if (= count 0) (setq sty (car tbl_list3)))
    (while (> count 0)
    (setq tbl_list3 (cdr tbl_list3))
    (setq sty (car tbl_list3))
    (setq count (- count 1))
    )
    )
    ;
    ;
    ;
    (defun c:pitch ()
    (setvar "cmdecho" 0)
    (setq dcl_id (load_dialog "pitch.dcl"))

    (if (not (new_dialog "slope" dcl_id))
    (exit))

    (setq x (dimx_tile "image")
    y (dimy_tile "image"))
    (start_image "image")
    (fill_image 0 0 x y 0)
    (slide_image 0 0 x y "slope1")
    (end_image)

    (setq vw 1)

    (setq lay "T")
    (setq sty "T")

    (mode_tile "aline" 2)

    (set_tbl_list)
    (set_style_list)

    (action_tile "la_list" "(setq lay_draw (atoi $value)) (set_lay)")
    (action_tile "st_list" "(setq sty_draw (atoi $value)) (set_style)")
    (action_tile "aline" "(setq vw 1) (set_view)")
    (action_tile "bline" "(setq vw 2) (set_view)")

    (action_tile "accept" "(done_dialog)")
    (action_tile "cancel" "(done_dialog)")


    (start_dialog)
    (unload_dialog dcl_id)

    (if (= vw 1) (slope-a))
    (if (= vw 2) (slope-b))

    (setvar "clayer" cl)
    (setvar "textstyle" st)
    (princ)

    )
    ;
    ;
    ;

    DCL PART

    dcl_settings : default_dcl_settings { audit_level = 0; }

    slope : dialog {
    label = "SLOPE MARKS";
    :column {
    :image {
    key = "image";
    width = 20;
    aspect_ratio = 0.90;
    }
    : row {
    :text {label = "Layer:";}
    :popup_list {
    key = "la_list";
    width = 20;
    }
    }
    :row {
    :text {label = "Style:";}
    :popup_list {
    key = "st_list";
    width = 20;
    }
    }
    }
    spacer_1;
    : boxed_column {
    label = "Slope Location";
    :radio_button {
    key = "aline";
    label = "Above Line: ";
    }
    :radio_button {
    key = "bline";
    label = "Below Line:";
    }
    }
    spacer_1;
    : boxed_row {
    label = "Messages";
    : text {
    key = "message";
    fixed_width;
    }
    }
    :row {ok_button; cancel_button;}
    }
    //
    //
     
    BParker35, Dec 1, 2004
    #4
  5. BParker35

    GaryDF Guest

    Got Custoner Files and see SLP...it maybe similar to your routine.

    Gary
     
    GaryDF, Dec 1, 2004
    #5
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.