Jump to content

List box from Lee Mac I can not get it to work


j_spawn_h

Recommended Posts

I found Lee Macs list box and i changed it to fit what i need. For the life of me i can not get the value of the list box to populate at the end. I get my radio buttons to get me the text at the end but not the list box. I know it is probably real simple fix but can not figure it out.

 

(defun c:bm1 ( / *error* UpdateList data dclfile dclhandle )


    ;; This program demonstrates how to update a secondary list_box based
  ;; on user selection from a primary list_box.

  ;; Example courtesy of Lee Mac © 2010 (www.lee-mac.com)

  ;; Accompanying DCL File:

   (setq dclFile "newcloudredline.dcl")
  
  ;; Ensure this file resides in an AutoCAD Support Path

  (defun *error* ( msg )

    ;; Error Handler - will unload the dialog
    ;; from memory should the user decide to hit Esc

    (if dclHandle (unload_dialog dclHandle))
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
  )

  (defun UpdateList ( key lst )

    ;; This function updates the list_box associated with the specified key
    ;; using the contents of the supplied lst

    (start_list key)
    (mapcar 'add_list lst)
    (end_list)
  )

  ;; Data used to Populate List_Boxes:
  ;; I've chosen to use this list structure because it suits the data,
  ;; but there are many other possibilities.

  (setq Data
   '(
     ("Roof"    ("Dbl Rafter" "Trpl Rafter" "Flat Valley" "Dbl Rafter Note" "Trpl Rafter Note" "Ext Rafter Note" "Brace" "Purlin" "2x8" "Roof Box" "RB" "Deflect"))
     ("Floor"     ("Beam" "Joist" "Hanger"))
    
    )
  )

  ;; Start of Main Routine
  ;; Lots of Error Trapping to make sure the Dialog Loads:

  (cond
    ( (<= (setq dclHandle (load_dialog dclFile)) 0)

      (princ "\n--> DCL File not Found.")
    )
    ( (not (new_dialog "newcloudredline" dclHandle))

      (setq dclHandle (unload_dialog dclHandle))
      (princ "\n--> Dialog Definition not Found.")
    )
    ( t
      ;; Dialog Loaded Successfully.

      (or *Roof*  (setq *Roof*  "0"))
      (or *Floor* (setq *Floor* "0"))

      ;; Set up some default selections, for the first-time running of the program.
      ;; The variables *Make* & *Model* are intended to be global and hence will
      ;; remember the user's last selections.

      ;; Populate the List_Boxes:

      ;; List_Box 'lst1'
     
      (UpdateList "lst1" (mapcar 'car Data))
      (set_tile "lst1" *Roof*)

      ;; List_Box 'lst2'

      (UpdateList "lst2" (cadr (nth (atoi *Roof*) Data)))
      (set_tile "lst2" *Floor*)

      ;; Action_tile Statements:
      ;; These control what happens when the user interacts with a tile in the dialog.

      (action_tile "lst1"
        (strcat
          "(UpdateList \"lst2\" (setq lst2 (cadr (nth (atoi (setq *Roof* $value)) Data))))"
          "(setq *Floor*"
          "  (set_tile \"lst2\""
          "    (if (< (atoi *Floor*) (length lst2)) *Floor* \"0\")"
          "  )"
          ")"
        )
      )

      ;; Here, when the user selects an item from 'lst1', the UpdateList subfunction
      ;; is fired to update the items in list_box 'lst2'.

      ;; list_box 'lst2' is also set to the value of *Model* if the index is
      ;; available for the selected item, else the first item is selected.

      ;; Note that $value is a string containg the index of the item
      ;; that the user has selected.

      (action_tile "lst2" "(setq *Floor* $value)")
     (action_tile "note6" "(setq note6 $value)")
     (action_tile "note7" "(setq note7 $value)")

      ;; Dialog setup, lets start it:

      (start_dialog)
      (setq dclHandle (unload_dialog dclHandle))
    )
  )

  ;(cond
  ;;Prefix
  (if(= note6 "ts6")(setq label (strcat "Delete")))
  (if(= note6 "ts6.1")(setq label (strcat "Add")))
  (if(= note6 "ts6.11")(setq label "Missing"))
  (if(= note6 "ts6.12")(setq label "Fix"))
  (if(= note6 "ts6.13")(setq label "Wrong"))
  (if(= note6 "ts6.14")(setq label "Update"))
  (if(= note6 "ts6.15")(setq label "New"))
  (if(= note6 "ts6.16")(setq label "Extend"))
  (if(= note6 "ts6.17")(setq label (strcat "")))

  (if (= lst2 "0")(setq label1 (strcat "Beam")))
  ;(if (= lst2 "0")(setq label1 (strcat "Dbl Rafter")))
  ;(if (= lst2 "1")(setq label1 (strcat "Trpl Rafter")))
  ;(if (= lst2 "2")(setq label1 (strcat "Flat Valley")))
  ;(if (= lst2 "3")(setq label1 (strcat "Dbl Rafter Note")))
  ;(if (= lst2 "4")(setq label1 (strcat "Trpl Rafter Note")))  
  ;(if (= lst2 "5")(setq label1 (strcat "Ext Rafter Note")))
  ;(if (= lst2 "6")(setq label1 (strcat "Brace")))
  ;(if (= lst2 "7")(setq label1 (strcat "Purlin")))
  ;(if (= lst2 "8")(setq label1 (strcat "2x8")))
  ;(if (= lst2 "9")(setq label1 (strcat "Roof Box")))
  ;(if (= lst2 "10")(setq label1 (strcat "RB")))
  ;(if (= lst2 "11")(setq label1 (strcat "Deflect")))
  
  (if(= note7 "ts7")(setq label3 (strcat"UWA")))
  (if(= note7 "ts7.1")(setq label3 (strcat"FRB")))
  (if(= note7 "ts7.12")(setq label3 (strcat "")))
  ;);end cond   

  
  (setq finallabel (strcat label label1 label3))
  (print finallabel)
          (command "text" "s" "standard" pause "24" "0" finallabel)
  (princ)
)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...