Jump to content
pmxcad

Need help with dcl

Recommended Posts

pmxcad

Good afternoon,
I am working on my first dcl menu.
I started with an example of Lee Mac.
http://www.lee-mac.com/listboxsync.html

It's what I want to get about. Have changed the dcl part to a popup list. The layout looks good. But I am totally lost with the lisp. What I want to achieve is that the first row (Type) controls all other rows. (see excel file).
I do not manage to fill the rules 3,4,5 & 6.
I would not know how to get the ok button working and get all selected values in variables.
Could someone help me or give me some tips?

Thanks in advance.
JM

 

 

(defun c:listbox ( / *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 "listbox.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
   '(

("Dinion 5000 Boxcam" 
("Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None")
("Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None")
("Outdoor Housing" "None")
("FTP" "PoE" "Fiber")
("IR-Straler-25m-tot-156m" "IR-Straler-35m-tot-220m" "IR-Straler-43m-tot-268m" "None")
)

("Dinion 6000 Boxcam" 
("Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None")
("Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None")
("Outdoor Housing" "None")
("FTP" "PoE" "Fiber")
("IR-Straler-25m-tot-156m" "IR-Straler-35m-tot-220m" "IR-Straler-43m-tot-268m" "None")
)

("Dinion 7000 Boxcam" 
("Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None")
("Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None")
("Outdoor Housing" "None")
("FTP" "PoE" "Fiber")
("IR-Straler-25m-tot-156m" "IR-Straler-35m-tot-220m" "IR-Straler-43m-tot-268m" "None")
)
   
("Indoor Dome"
("None")
("Plafondmontageset" "L-vormige-wandmontagebeugel-voor-domecamera")
("Outdoor Housing" "None")
("FTP" "PoE" "Fiber")
("IR-Straler-25m-tot-156m" "IR-Straler-35m-tot-220m" "IR-Straler-43m-tot-268m" "None")
)

("Outdoor Dome"
("None")
("Plafondmontageset" "Wandmontage-buitenhuis-Combineer-met-LTC9213-01-voor-paalmontage" "Maststeun")
("Outdoor Housing" "None")
("FTP" "PoE" "Fiber")
("IR-Straler-25m-tot-156m" "IR-Straler-35m-tot-220m" "IR-Straler-43m-tot-268m" "None")
)


    )
  )

  ;; 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 "listbox" dclHandle))

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

      (or *Type*		(setq *Type*  "0"))
      (or *Lens*		(setq *Lens* "0"))
      (or *Mount*		(setq *Mount* "0"))
      (or *Housing*		(setq *Housing* "0"))
      (or *Cable*		(setq *Cable* "0"))
      (or *IR-Straler*	(setq *IR-Straler* "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" *Type*)

      ;; List_Box 'lst2'
      (UpdateList "lst2" (cadr (nth (atoi *Lens*) Data)))
      (set_tile "lst2" *Lens*)

      ;; List_Box 'lst3'
      (UpdateList "lst3" (cadr (nth (atoi *Mount*) Data)))
      (set_tile "lst3" *Mount*)

      ;; List_Box 'lst4'
      (UpdateList "lst4" (cadr (nth (atoi *Housing*) Data)))
      (set_tile "lst4" *Housing*)

      ;; List_Box 'lst5'
      (UpdateList "lst5" (cadr (nth (atoi *Cable*) Data)))
      (set_tile "lst5" *Cable*)

      ;; List_Box 'lst6'
      (UpdateList "lst6" (cadr (nth (atoi *IR-Straler*) Data)))
      (set_tile "lst6" *IR-Straler*)



      ;; 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 *Type* $value)) Data))))"
          "(setq *Lens*" 
	"  (set_tile \"lst2\""
          "    (if (< (atoi *Lens*) (length lst2)) *Lens* \"0\")"
          "  )"
          ")"
        )
      )


;------- Test -------------------------------------------------
;      (action_tile "lst1"
;        (strcat "(UpdateList \"lst3\" (setq lst3 (cadr (nth (atoi (setq *Type* $value)) Data))))"
;          "(setq *Mount*"
;	"  (set_tile \"lst3\""
;          "    (if (< (atoi *Mount*) (length lst3)) *Mount* \"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 *Type* $value)")
;      (action_tile "lst3" "(setq *Type* $value)")		;test
;      (action_tile "lst4" "(setq *Mount* $value)")	;test

      ;; Dialog setup, lets start it:

      (start_dialog)
      (setq dclHandle (unload_dialog dclHandle))
    )
  )
  (princ)
)
// DCL File to be saved as listbox.dcl
// Example courtesy of Lee Mac © 2012 (www.lee-mac.com)

listbox : dialog { label ="Camera"; spacer;


    : boxed_column {
   { width = 100; fixed_width = true;}


    : row {
      fixed_width = true;
    : column {
      width = 12;
      fixed_width = true;
    : text { label = "Type"; }
    }
     : popup_list { key = "lst1"; width = 20; fixed_width = true; }
    }

      spacer;

    : row {
      fixed_width = true;
    : column {
      width = 12;
      fixed_width = true;
    : text { label = "Lens"; }
    }
     : popup_list { key = "lst2"; width = 55; fixed_width = true; }
    }

      spacer;


    : row {
      fixed_width = true;
    : column {
      width = 12;
      fixed_width = true;
    : text { label = "Mount"; }
    }
     : popup_list { key = "lst3"; width = 22; fixed_width = true; }
    }

      spacer;


    : row {
      fixed_width = true;
    : column {
      width = 12;
      fixed_width = true;
    : text { label = "Housing"; }
    }
     : popup_list { key = "lst4"; width = 22; fixed_width = true; }
    }

      spacer;


    : row {
      fixed_width = true;
    : column {
      width = 12;
      fixed_width = true;
    : text { label = "Cable"; }
    }
     : popup_list { key = "lst5"; width = 22; fixed_width = true; }
    }

      spacer;


    : row {
      fixed_width = true;
    : column {
      width = 12;
      fixed_width = true;
    : text { label = "IR-Straler"; }
    }
     : popup_list { key = "lst6"; width = 22; fixed_width = true; }
    }


      spacer;
      spacer;

  }
      spacer;
      spacer;

  ok_only; width = 30;
}

 

Camera.xlsx

Share this post


Link to post
Share on other sites
rlx

just to get you started


(defun c:t1 ( / fp fn dcl drv i-camera i-lens i-mount i-housing i-cable i-straler cameras-types current-camera-data)
  (init_variables)
  (create_dcl)
  (start_dcl)
  (princ)
)

(defun start_dcl ( / dcl drv)
  (if (and (< 0 (setq dcl (load_dialog fn)))(new_dialog "camera" dcl))
    (progn
      (update_dialog)
      (action_tile "pl_camera" "(setq i-camera (atoi $value))(update_dialog)")
      (action_tile "pl_lens" "(setq i-lens (atoi $value))")
      (action_tile "pl_mount" "(setq i-mount (atoi $value))")
      (action_tile "pl_housing" "(setq i-housing (atoi $value))")
      (action_tile "pl_cable" "(setq i-cable (atoi $value))")
      (action_tile "pl_ir_straler" "(setq i-straler (atoi $value))")
     
      (action_tile "accept" "(done_dialog 1)")
      (action_tile "cancel" "(done_dialog 0)")
      (setq drv (start_dialog))(unload_dialog dcl)(vl-file-delete fn)
    )
  )
  (cond
    ((= drv 0)(princ "\nCanceled by User"))
    ((= drv 1)(show_camera_setup))
    (t (princ "\nOh darn..."))
  )
)

(defun create_dcl ( / fp)
  (if (setq fp (open (setq fn (vl-filename-mktemp ".dcl")) "w"))
    (mapcar ''((x)(princ x fp))
    '("camera:dialog{label=\"PmxCadCamera\";:boxed_row{label=\"Camera Setup\";"
     ":column{:text{label=\"Camera\";}:text{label=\"Lens\";}:text{label=\"Mount\";}"
     ":text{label=\"Housing\";}:text{label=\"Cable\";}:text{label=\"IR-Straler\";}}:column{children_fixed_width=true;"
     ":popup_list{key=\"pl_camera\";width=22;}spacer;:popup_list{key=\"pl_lens\";width=55;}spacer;"
     ":popup_list{key=\"pl_mount\";width=22;}spacer;:popup_list{key=\"pl_housing\";width=22;}spacer;"
     ":popup_list{key=\"pl_cable\";width=22;}spacer;:popup_list{key=\"pl_ir_straler\";width=22;}}}spacer;ok_cancel;}")))
  (if fp (close fp))(gc)
)

(defun init_variables ()
  (mapcar '(lambda (x)(set x 0)) '(i-camera i-lens i-mount i-housing i-cable i-straler))
  (setq Data
   '(("Dinion 5000 Boxcam"
       ("Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None")
       ("Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None")
       ("Outdoor Housing" "None") ("FTP" "PoE" "Fiber") ("IR-Straler-25m-tot-156m" "IR-Straler-35m-tot-220m" "IR-Straler-43m-tot-268m" "None"))
     ("Dinion 6000 Boxcam"
      ("Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None")
      ("Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None")
      ("Outdoor Housing" "None") ("FTP" "PoE" "Fiber") ("IR-Straler-25m-tot-156m" "IR-Straler-35m-tot-220m" "IR-Straler-43m-tot-268m" "None"))
     ("Dinion 7000 Boxcam"
      ("Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None")
      ("Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None")
      ("Outdoor Housing" "None") ("FTP" "PoE" "Fiber") ("IR-Straler-25m-tot-156m" "IR-Straler-35m-tot-220m" "IR-Straler-43m-tot-268m" "None"))
     ("Indoor Dome"
      ("None")
      ("Plafondmontageset" "L-vormige-wandmontagebeugel-voor-domecamera")
      ("Outdoor Housing" "None") ("FTP" "PoE" "Fiber") ("IR-Straler-25m-tot-156m" "IR-Straler-35m-tot-220m" "IR-Straler-43m-tot-268m" "None"))
     ("Outdoor Dome"
      ("None")
      ("Plafondmontageset" "Wandmontage-buitenhuis-Combineer-met-LTC9213-01-voor-paalmontage" "Maststeun")
      ("Outdoor Housing" "None") ("FTP" "PoE" "Fiber") ("IR-Straler-25m-tot-156m" "IR-Straler-35m-tot-220m" "IR-Straler-43m-tot-268m" "None"))
    )
  )
  (setq cameras-types (mapcar 'car Data) current-camera-data (nth i-camera Data))
)

(defun update_dialog ()
  (setq current-camera-data (nth i-camera Data))
  (start_list "pl_camera")(mapcar 'add_list cameras-types)(end_list)(set_tile "pl_camera" (itoa i-camera))
  (start_list "pl_lens")(mapcar 'add_list (nth 1 current-camera-data))(end_list)(set_tile "pl_lens" (itoa i-lens))
  (start_list "pl_mount")(mapcar 'add_list (nth 2 current-camera-data))(end_list)(set_tile "pl_mount" (itoa i-mount))
  (start_list "pl_housing")(mapcar 'add_list (nth 3 current-camera-data))(end_list)(set_tile "pl_housing" (itoa i-housing))
  (start_list "pl_cable")(mapcar 'add_list (nth 4 current-camera-data))(end_list)(set_tile "pl_cable" (itoa i-cable))
  (start_list "pl_ir_straler")(mapcar 'add_list (nth 5 current-camera-data))(end_list)(set_tile "pl_ir_straler" (itoa i-straler))
)

(defun show_camera_setup ()
  (princ (strcat "\nCamera = " (car current-camera-data)))
  (princ (strcat "\nLens = " (nth i-lens (nth 1 current-camera-data))))
  (princ (strcat "\nMount = " (nth i-mount (nth 2 current-camera-data))))
  (princ (strcat "\nhousing = " (nth i-housing (nth 3 current-camera-data))))
  (princ (strcat "\nCable = " (nth i-cable (nth 4 current-camera-data))))
  (princ (strcat "\nIR-straler = " (nth i-straler (nth 5 current-camera-data))))
)

; (c:t1)

Share this post


Link to post
Share on other sites
pmxcad

Great rlx, works perfectly.
I did not know that you could use lisp and dcl together in a lisp
I  go study the lisp to see if I understand how you made it.
Must only adjust it for use with block attributes, but that will be fine.
Thank you.
Jaap M.
PmxCAD

Share this post


Link to post
Share on other sites
rlx

graag gedaan Jaap...

 

If you understand the first code , this second code is a little more streamlined


(defun c:t2 ( / fp fn dcl drv main-camera-data-record camera-types current-camera-data
                i-camera i-lens i-mount housing-data i-housing cable-data i-cable straler-data i-straler)
  (init_variables) (create_dcl) (start_dcl) (princ "\n\n") (princ)
)

 

(defun init_variables ()(vl-load-com)
  (defun *error* (s)(if dcl (unload_dialog dcl))(if fp (close fp))(if (and fn (setq fn (findfile fn))) (vl-file-delete fn))
     (or (wcmatch (strcase s) "*BREAK,*CANCEL*,*EXIT*")(princ (strcat "\n** Error: " s " **")))(princ))
  (mapcar '(lambda (x)(set x 0)) '(i-camera i-lens i-mount i-housing i-cable i-straler))
  (setq main-camera-data-record
   '(("Dinion 5000 Boxcam"
      ("Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None")
      ("Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None"))
     ("Dinion 6000 Boxcam"
      ("Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None")
      ("Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None"))
     ("Dinion 7000 Boxcam"
      ("Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None")
      ("Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None"))
     ("Indoor Dome" ("None") ("Plafondmontageset" "L-vormige-wandmontagebeugel-voor-domecamera"))
     ("Outdoor Dome" ("None") ("Plafondmontageset" "Wandmontage-buitenhuis-Combineer-met-LTC9213-01-voor-paalmontage" "Maststeun"))
    )
  )
  (setq camera-types (mapcar 'car main-camera-data-record) current-camera-data (nth i-camera main-camera-data-record)
        housing-data '("Outdoor Housing" "None") cable-data '("FTP" "PoE" "Fiber")
        straler-data '("IR-Straler-25m-tot-156m" "IR-Straler-35m-tot-220m" "IR-Straler-43m-tot-268m" "None"))
)

 

(defun create_dcl ( / fp)
  (if (setq fp (open (setq fn (vl-filename-mktemp ".dcl")) "w"))
    (mapcar '(lambda (x)(princ x fp))
    '("camera:dialog{label=\"PmxCadCamera\";:boxed_row{label=\"Camera Setup\";"
     ":column{:text{label=\"Camera\";}:text{label=\"Lens\";}:text{label=\"Mount\";}"
     ":text{label=\"Housing\";}:text{label=\"Cable\";}:text{label=\"IR-Straler\";}}:column{children_fixed_width=true;"
     ":popup_list{key=\"pl_camera\";width=22;}spacer;:popup_list{key=\"pl_lens\";width=55;}spacer;"
     ":popup_list{key=\"pl_mount\";width=22;}spacer;:popup_list{key=\"pl_housing\";width=22;}spacer;"
     ":popup_list{key=\"pl_cable\";width=22;}spacer;:popup_list{key=\"pl_ir_straler\";width=22;}}}spacer;ok_cancel;}")))
  (if fp (close fp))(gc)
)

 

(defun start_dcl ( / dcl drv)
  (if (and (< 0 (setq dcl (load_dialog fn)))(new_dialog "camera" dcl))
    (progn (update_dialog)(init_dialog_actions)(setq drv (start_dialog))(unload_dialog dcl)(vl-file-delete fn)))
  (cond ((= drv 0)(princ "\nCanceled by User")) ((= drv 1)(show_camera_setup)) (t (princ "\nOh darn...")))
)

 

(defun select_camera (#i) (if (/= #i i-camera)(setq i-camera #i i-lens 0 i-mount 0)))

 

(defun update_dialog ()
  (setq current-camera-data (nth i-camera main-camera-data-record))
  (start_list "pl_camera")(mapcar 'add_list camera-types)(end_list)(set_tile "pl_camera" (itoa i-camera))
  (mapcar '(lambda (x y z) (start_list x)(mapcar 'add_list (nth y current-camera-data))(end_list)(set_tile x (itoa (eval z))))
          '("pl_lens""pl_mount") '(1 2) '(i-lens i-mount))
  (mapcar '(lambda (x y z) (start_list x) (mapcar 'add_list (eval y))(end_list)(set_tile x (itoa (eval z))))
          '("pl_housing""pl_cable""pl_ir_straler") '(housing-data cable-data straler-data) '(i-housing i-cable i-straler))
)

 

(defun init_dialog_actions ()
  (mapcar '(lambda (x)(action_tile (car x) (cadr x)))
          '(("cancel" "(done_dialog 0)") ("accept" "(done_dialog 1)") ("pl_camera" "(select_camera (atoi $value))(update_dialog)")
            ("pl_lens" "(setq i-lens (atoi $value))") ("pl_mount" "(setq i-mount (atoi $value))")
            ("pl_housing" "(setq i-housing (atoi $value))") ("pl_cable" "(setq i-cable (atoi $value))")
            ("pl_ir_straler" "(setq i-straler (atoi $value))"))
  )
)

 

(defun show_camera_setup ()
  (princ (strcat "\nCamera = " (car current-camera-data)))
  (mapcar '(lambda (x y z / s) (princ (strcat "\n" x " = " (if (setq s (nth (eval y) (nth z current-camera-data))) s " - "))))
          '("Lens" "Mount" ) '(i-lens i-mount ) '(1 2))
  (mapcar '(lambda (x y z / s) (princ (strcat "\n" x " = " (if (setq s (nth (eval y) (eval z))) s " - "))))
          '("Housing" "Cable" "IR-straler") '(i-housing i-cable i-straler) '(housing-data cable-data straler-data))
)

;(c:t2)

 

In your main data record the list for housing, cable & straler are always the same so in above code I have each given them their own seperate list with their own pointer that operates seperate from the pointer to the camera name. Else you would need to reset all your (pop-up-list) pointers to zero whenever you select a new camera because when you first select for example the "Dinion 5000 Boxcam" (the first camera in the list , so i-camera = 0) with the "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" (i-lens = 1) and then you select the "Indoor Dome"  , which has no lense , your lens pointer (which is still 1 at that time) would given an error since the lenses list for "Indoor Dome" contains only 1 element ("None") so in the second code , whenever you select a new camera the lense and the mount pointers are set to 0. This is handeld by the function 'select_camera'.

 

Hope this helps in your understanding and further developping of your appie .

 

gr. Rlx

 

🐉

 

Share this post


Link to post
Share on other sites
pmxcad

Rlx,

it gives a dcl error line1 and line2.

 

 

 

Maakt niet uit. Ik ga eerst de eerste, T1 uitvogelen. Is voor mij al lastig genoeg.

Tks,

 

Jaap 

PmxCAD

Share this post


Link to post
Share on other sites
rlx

copied c:t2 code from this forum back in empty lisp file and it works just fine... ? oh well... if you're happy with c:t1 , I'm happy 😋

Share this post


Link to post
Share on other sites
pmxcad

Hello rlx,

I changed the lisp code to my needs, but I still have one question:
Can the lisp be adjusted so that the OK button is greyed out or switched off until everything is filled?

 

;	RLx 2019		J. Marchal  edit: 09-03-2019


(defun c:camset ( / fp fn dcl drv i-camera i-lens i-mount i-housing i-cable i-straler cameras-types current-camera-data)

  (init_variables)
  (create_dcl)
  (start_dcl)
  (c:setcodes)
; (c:putcodes)
  (princ)
)

(defun start_dcl ( / dcl drv)
  (if (and (< 0 (setq dcl (load_dialog fn)))(new_dialog "camera" dcl))
    (progn
      (update_dialog)
      (action_tile "pl_camera" "(setq i-camera (atoi $value))(update_dialog)")
      (action_tile "pl_lens" "(setq i-lens (atoi $value))")
      (action_tile "pl_mount" "(setq i-mount (atoi $value))")
      (action_tile "pl_housing" "(setq i-housing (atoi $value))")
      (action_tile "pl_cable" "(setq i-cable (atoi $value))")
      (action_tile "pl_ir_straler" "(setq i-straler (atoi $value))")
     
      (action_tile "accept" "(done_dialog 1)")
      (action_tile "cancel" "(done_dialog 0)")
      (setq drv (start_dialog))(unload_dialog dcl)(vl-file-delete fn)
    )
  )
  (cond
    ((= drv 0)(princ "\nCanceled by User"))
    ((= drv 1)(show_camera_setup))
    (t (princ "\nOh darn..."))
  )
)

;------- Create dcl -------------------
(defun create_dcl ( / fp)
  (if (setq fp (open (setq fn (vl-filename-mktemp ".dcl")) "w"))
    (mapcar ''((x)(princ x fp))
     '("camera:dialog
       {label=\"  Unica Security\";spacer_1;
       :boxed_row{
        width = 75;
        fixed_width = true;
        label=\"Camera Setup\";"

     ":column{
       spacer_1;
      :text{label=\"Camera\";}
      :text{label=\"Objectief\";}
      :text{label=\"Mount\";}"
     ":text{label=\"Housing\";}
      :text{label=\"Cable\";}
      :text{label=\"IR-Straler\";}
       spacer_1;}

      :column{
       spacer_1;
       children_fixed_width=true;"
     ":popup_list{key=\"pl_camera\";width=24;}spacer;
      :popup_list{key=\"pl_lens\"	;width=60;}spacer;"
     ":popup_list{key=\"pl_mount\";width=60;}spacer;
      :popup_list{key=\"pl_housing\";width=24;}spacer;"
     ":popup_list{key=\"pl_cable\";width=24;}spacer;
      :popup_list{key=\"pl_ir_straler\";width=24;}
       spacer_1;}}
       spacer_1;
       ok_cancel;}"
   )))
  (if fp (close fp))(gc)
);end create_dcl

;------- Init Variables -------------------
(defun init_variables ()
  (mapcar '(lambda (x)(set x 0)) '(i-camera i-lens i-mount i-housing i-cable i-straler))
  (setq Data
'(
("Maak keuze")
("Dinion 5000 Boxcam"
       ("Maak keuze" "Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None")
       ("Maak keuze" "Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None")
       ("Maak keuze" "Outdoor Housing" "None") ("Maak keuze" "FTP" "PoE" "Fiber" "None") ("Maak keuze" "IR-Straler 25m tot 156m" "IR-Straler 35m tot 220m" "IR-Straler 43m tot 268m" "None"))
("Dinion 6000 Boxcam"
      ("Maak keuze"" "Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None)
      ("Maak keuze" "Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None")
      ("Maak keuze" "Outdoor Housing" "None") ("Maak keuze" "FTP" "PoE" "Fiber" "None") ("Maak keuze" "IR-Straler 25m tot 156m" "IR-Straler 35m tot 220m" "IR-Straler 43m tot 268m" "None"))
("Dinion 7000 Boxcam"
      ("Maak keuze" "Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5" "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor" "None")
      ("Maak keuze" "Wall mount cable feed through 30cm" "Wall mount cable feed through 18cm" "J mount for camera housing 40cm" "Pole mount maststeun" "None")
      ("Maak keuze" "Outdoor Housing" "None") ("Maak keuze" "FTP" "PoE" "Fiber" "None") ("Maak keuze" "IR-Straler 25m tot 156m" "IR-Straler 35m tot 220m" "IR-Straler 43m tot 268m" "None"))
("Indoor Dome"
      ("")
      ("Maak keuze" "Plafondmontageset" "L-vormige-wandmontagebeugel-voor-domecamera" "None")
      ("Maak keuze" "Outdoor Housing" "None") ("Maak keuze" "FTP" "PoE" "Fiber" "None") ("Maak keuze" "IR-Straler 25m tot 156m" "IR-Straler 35m tot 220m" "IR-Straler 43m tot 268m" "None"))
("Outdoor Dome"
      ("")
      ("Maak keuze" "Plafondmontageset" "Wandmontage-buitenhuis-Combineer-met-LTC9213-01-voor-paalmontage" "Maststeun" "None")
      ("Maak keuze" "Outdoor Housing" "None") ("Maak keuze" "FTP" "PoE" "Fiber" "None") ("Maak keuze" "IR-Straler 25m tot 156m" "IR-Straler 35m tot 220m" "IR-Straler 43m tot 268m" "None"))
    )
  )
  (setq cameras-types (mapcar 'car Data) current-camera-data (nth i-camera Data))
);init_variables

;------- Update dialog -------------------
(defun update_dialog ()
  (setq current-camera-data (nth i-camera Data))
  (start_list "pl_camera")(mapcar 'add_list cameras-types)(end_list)(set_tile "pl_camera" (itoa i-camera))
  (start_list "pl_lens")(mapcar 'add_list (nth 1 current-camera-data))(end_list)(set_tile "pl_lens" (itoa i-lens))
  (start_list "pl_mount")(mapcar 'add_list (nth 2 current-camera-data))(end_list)(set_tile "pl_mount" (itoa i-mount))
  (start_list "pl_housing")(mapcar 'add_list (nth 3 current-camera-data))(end_list)(set_tile "pl_housing" (itoa i-housing))
  (start_list "pl_cable")(mapcar 'add_list (nth 4 current-camera-data))(end_list)(set_tile "pl_cable" (itoa i-cable))
  (start_list "pl_ir_straler")(mapcar 'add_list (nth 5 current-camera-data))(end_list)(set_tile "pl_ir_straler" (itoa i-straler))
); end update_dialog

;------- Camera Setup to setq -------------------
(defun show_camera_setup ()
 	(setq Camera (car current-camera-data))
	(setq Lens (nth i-lens (nth 1 current-camera-data)))
	(setq Mount (nth i-mount (nth 2 current-camera-data)))
 	(setq Housing (nth i-housing (nth 3 current-camera-data)))
 	(setq Cable (nth i-cable (nth 4 current-camera-data)))
	(setq IR-Straler (nth i-straler (nth 5 current-camera-data)))

;  (alert (strcat camera "  -  " lens "  -  " mount "  -  " housing "  -  " cable "  -  " ir-straler))
);end show_camera_setup


;--------------------- Set Recept/Artikel codes ---------------------------------------------------------
(defun c:setcodes ( / ARTICLECODE00 RECEPTCODE00 ARTICLECODE01 RECEPTCODE01 ARTICLECODE02 RECEPTCODE02 ARTICLECODE03 RECEPTCODE03 RECEPTCODE03 ARTICLECODE04 RECEPTCODE04 ARTICLECODE05 RECEPTCODE05)

;----- camera -------
														(setq ARTICLECODE00 "" RECEPTCODE00 "" WINDCHILL_ARTICLECODE "")
(if (= Camera "Dinion 5000 Boxcam")						(setq ARTICLECODE00 "NBN-50022-C" RECEPTCODE00 "CAM00007" WINDCHILL_ARTICLECODE ""))
(if (= Camera "Dinion 6000 Boxcam")						(setq ARTICLECODE00 "NBN-63023-B" RECEPTCODE00 "CAM00006" WINDCHILL_ARTICLECODE ""))
(if (= Camera "Dinion 7000 Boxcam")						(setq ARTICLECODE00 "NBN-73023-BA" RECEPTCODE00 "CAM00002" WINDCHILL_ARTICLECODE ""))
(if (= Camera "Indoor Dome")							(setq ARTICLECODE00 "NIN-50022-V3" RECEPTCODE00 "CAM00001" WINDCHILL_ARTICLECODE ""))
(if (= Camera "Outdoor Dome")							(setq ARTICLECODE00 "NDN-50022-A3" RECEPTCODE00 "CAM00003" WINDCHILL_ARTICLECODE ""))

;----- objectief -------
																					(setq ARTICLECODE01 "" RECEPTCODE01 "")
(if (= Lens "Varifocal SR Megapixel Lens 9 40mm IR corrected lens with 1.5")		(setq ARTICLECODE01 "LVF-5005SC-S0940" RECEPTCODE01 "OBJ00001"))
(if (= Lens "Varifocal SR Megapixel Lens 3.8 13mm 0.5 sensor")						(setq ARTICLECODE01 "LVF-5003N-S3813" RECEPTCODE01 "OBJ00002"))
(if (= Lens "None")																	(setq ARTICLECODE01 "" RECEPTCODE01 ""))
(if (= Lens "")																		(setq ARTICLECODE01 "" RECEPTCODE01 ""))

;----- Mount -------
																					(setq ARTICLECODE02 "" RECEPTCODE02 "")
(if (= Mount "Wall mount cable feed through 30cm")									(setq ARTICLECODE02 "LTC-9215/00" RECEPTCODE02 "CAM00004"))
(if (= Mount "Wall mount cable feed through 18cm")									(setq ARTICLECODE02 "LTC-9215/00S" RECEPTCODE02 "CAM00014"))
(if (= Mount "J mount for camera housing 40cm")										(setq ARTICLECODE02 "LTC-9219/01" RECEPTCODE02 "CAM00015"))
(if (= Mount "Pole mount maststeun")												(setq ARTICLECODE02 "LTC-9213-01" RECEPTCODE02 "CAM00013"))
(if (= Mount "Universal wall ceilling mount")										(setq ARTICLECODE02 "TC9210U" RECEPTCODE02 "CAM00016"))
(if (= Mount "Plafondmontageset")													(setq ARTICLECODE02 "NDA-FMT-DOME" RECEPTCODE02 "CAM00010"))
(if (= Mount "L vormige wandmontagebeugel voor domecamera")							(setq ARTICLECODE02 "NDA-LWMT-DOME" RECEPTCODE02 "CAM00011"))
(if (= Mount "Wandmontage buitenhuis Combineer met LTC9213-01 voor paalmontage")	(setq ARTICLECODE02 "VDA-WMT-AODOME" RECEPTCODE02 "CAM00012"))
(if (= Mount "Maststeun")															(setq ARTICLECODE02 "LTC9213/01" RECEPTCODE02 "CAM00013"))
(if (= Mount "None")																(setq ARTICLECODE02 "" RECEPTCODE2 ""))
(if (= Mount "")																	(setq ARTICLECODE02 "" RECEPTCODE02 ""))

;----- Housing -------
																					(setq ARTICLECODE03 "" RECEPTCODE03 "")
(if (= Housing "Outdoor Housing") 													(setq ARTICLECODE03 "UHO-HGS-51" RECEPTCODE03 "CAM00005"))
(if (= Housing "None")																(setq ARTICLECODE03 "" RECEPTCODE03 ""))
(if (= Housing "")																	(setq ARTICLECODE03 "" RECEPTCODE03 ""))

;----- Cable -------
																					(setq ARTICLECODE04 "" RECEPTCODE04 "")
(if (= Cable "FTP") 																(setq ARTICLECODE04 "FTP" RECEPTCODE04 ""))
(if (= Cable "PoE") 																(setq ARTICLECODE04 "PoE-class-3" RECEPTCODE04 ""))
(if (= Cable "Fiber") 																(setq ARTICLECODE04 "Fiber" RECEPTCODE04 ""))
(if (= Cable "None")																(setq ARTICLECODE04 "" RECEPTCODE04 ""))
(if (= Cable "")																	(setq ARTICLECODE04 "" RECEPTCODE04 ""))

;----- IR-Straler -------
																					(setq ARTICLECODE05 "" RECEPTCODE05 "")
(if (= IR-Straler "IR-Straler 25m tot 156m") 										(setq ARTICLECODE05 "IIR-50850-SR" RECEPTCODE05 "IRL00006"))
(if (= IR-Straler "IR-Straler 35m tot 220m") 										(setq ARTICLECODE05 "IIR-50850-MR" RECEPTCODE05 "IRL00005"))
(if (= IR-Straler "IR-Straler 43m tot 268m") 										(setq ARTICLECODE05 "IIR-50850-LR" RECEPTCODE05 "IRL00004"))
(if (= IR-Straler "None")															(setq ARTICLECODE05 "" RECEPTCODE05 ""))
(if (= IR-Straler "")																(setq ARTICLECODE05 "" RECEPTCODE05 ""))

(c:showcodes)	;test
);end setcodes



;----- Show Codes------- (test) ---
(defun c:showcodes ()
(alert (strcat "ARTICLECODE00:  " ARTICLECODE00 "\n" "RECEPTCODE00:  " RECEPTCODE00 "\n" "ARTICLECODE01:  " ARTICLECODE01 "\n" "RECEPTCODE01:  "RECEPTCODE01 "\n" "ARTICLECODE02:  " ARTICLECODE02 "\n" "RECEPTCODE02:  "RECEPTCODE02 "\n" "ARTICLECODE03:  " ARTICLECODE03 "\n" "RECEPTCODE03:  "RECEPTCODE03 "\n" "ARTICLECODE04:  " ARTICLECODE04 "\n" "RECEPTCODE04:  " RECEPTCODE04 "\n" "ARTICLECODE05:  " ARTICLECODE05 "\n" "RECEPTCODE05:  "RECEPTCODE05))
);end showcodes


;--------------------- Put Recept/Artikel codes ---------------------------------------------------------		 external lisp to put data to block attributes
(defun c:putcodes ()
(load "//REDAPP02/Program/05 - AutoCAD/20 - Toolpalettes/00 - Tools/Invullen receptcodes.lsp")	;load external lisp
	(C:ARTICLECODE0)
	(C:RECEPTCODE0)
	(C:ARTICLECODE1)
	(C:RECEPTCODE1)
	(C:ARTICLECODE2)
	(C:RECEPTCODE2)
	(C:ARTICLECODE3)
	(C:RECEPTCODE3)
	(C:ARTICLECODE4)
	(C:RECEPTCODE4)
	(C:ARTICLECODE5)
	(C:RECEPTCODE5)
     (command "qsave")
);end putcodes



 

 

 



thank you in advance,
Jaap

Share this post


Link to post
Share on other sites
rlx

well that depends on your definition of when everything is filled. When you select a different camera certain lists are changed and their index reset to 0 so automatically the first item in the list is selected. Only way to prevent this is to start every list with "select item" for example and then you can simply test all your variables to not contain this string. If they are all ok you can use (mode_tile "accept" 0) to enable the button.

Share this post


Link to post
Share on other sites
rlx

try this one... succes!

 

gr. Rlx

camset.lsp

Share this post


Link to post
Share on other sites
pmxcad

Perfect rlx.

 

I could never made the lisp work with my knowledge.

 

Thanks.........

Share this post


Link to post
Share on other sites
rlx
7 minutes ago, pmxcad said:

Perfect rlx.

 

I could never made the lisp work with my knowledge.

 

Thanks.........

 

couple of years ago neither could I 😋

 

graag gedaan Jaap

 

gr. Rlx

Share this post


Link to post
Share on other sites
pmxcad
by following training or self study?

Share this post


Link to post
Share on other sites
rlx
Posted (edited)
1 hour ago, pmxcad said:

by following training or self study?

 

totally autodidact : learning = stealing knowledge / examples from others like Lee, Tharwat, Grrr, Bigal, Gile,Tony Tanzillo just to name a few and there are many others.

 

It does come at a price : I am a super drafstman but a lousy engineer meaning I know something about electricity and instrumentation but actually designing an installation or doing calculations I leave for the engineers to do. They put all their time in keeping up to date with the latest technical stuf and techniques and little me tries to keep up with the rest. Things like updating cable lists or the document control system or making all the drawings for the contractor is boring for them. Well , its boring for #metoo but generating thousands of loops from a excel file makes it a little bit more interesting for me. And after all these years working with xrefs , doing it the right way , also still seems to be problematic for most of them so they are all too happy I'm too dumb to be a thread to them but clever enough to do all the work they don't want to do themselves. Ok , they make more money than me , but how much do you really need. I get from a to b with my little car just they same way they do with their bigger car. I'm just a little mouse amongst the dinosaurs (and we all know how that ended, now don't we 😁 )

Edited by rlx

Share this post


Link to post
Share on other sites
pmxcad
Posted (edited)

Wow  this is funny, iam doing exact the same. Making al the tools for the engineers. They have to draw. Toolpalletes, Lisp tools.....etc etc...

Was a technician in the field until 1996 and got the diagnosis ms, then went to the office and then started with AutoCAD 12 DOS.

 

Edited by pmxcad

Share this post


Link to post
Share on other sites
rlx
33 minutes ago, pmxcad said:

Wow  this is funny, iam doing exact the same. Making al the tools for the engineers. They have to draw. Toolpalletes, Lisp tools.....etc etc...

Was a technician in the field until 1996 and got the diagnosis ms, then went to the office and then started with AutoCAD 12 DOS.

 

 

wow , ms , that's some heavy s***. Beeing able to make tools for the engineers can be a big boost for productivity though because the human mind is (for now) still the most powerfull tool there is. Respect!

I started with autocad 2.x , around 1986. Began drawing by hand , pencil & ink youknow. Then I heard about AutoCad and wanted to learn this. Asked for the manual , read it from start to end without having a computer yet. Then I would get a 'training' ... they put me in a corner at a kitchentable with a pc and said 'good luck' and the rest so to say is history.

Share this post


Link to post
Share on other sites
pmxcad

Rlx, one small thing with the dcl/lsp.

When choose domecamera, the next row is turned off. That's ok. But the ok button stays grey. Because nothing is selected in that row.

Share this post


Link to post
Share on other sites
rlx

hoi Jaap , alles kits?

 

probeer dit :


(defun chk_ok ()
  (if (or (vl-every '(lambda (x)(> x 0)) (list i-camera i-lens i-mount i-housing i-cable i-straler))
          (and (wcmatch (strcase (car current-camera-data) t) "*dome")(vl-every '(lambda (x)(> x 0)) (list i-mount i-housing i-cable i-straler))))
    (mode_tile "accept" 0)(mode_tile "accept" 1)))

 

(replace original chk_ok function with this version)

 

gr. RLX

Share this post


Link to post
Share on other sites
pmxcad

Hallo RLX,

Het gaat wel goed met me. Ik wel betere tijden gekend, maar er zijn mensen die het slechter hebben.

Your replacment works wel.

Do you not have a kind of template from a kind of equal lisp / dcl with 6 items that I can remove items or modify through?.
I am trying to figure out how I can I remove the option in the above version that row 2 is no longer dependent on row 1.

 

Do you have experience with VBA? Is that easier than lisp?

Share this post


Link to post
Share on other sites
rlx

Hi Jaap,

 

Sorry to hear about the uppers and downers, can only try to imagine...

 

Glad to hear the updated works. I have done very little VBA. Was about to try to learn it , like 10 or 15 years ago, when Autodesk suddenly pulled the plug on installing it standard with AutoCad so it was no longer interesting for me to pursue. It had a few things going for it , first there was the dcl editor and secondly the fact VBA's environment isn't limited to the active drawing (a lisp routine only functions in the drawing its loaded in). Thing I didn't like was the fact you have to declare every single variable in advance and after that you're a stuck with it. In lisp you can recycle , reuse , bend , shape , rape every variable as much and as often as you like. The price is of course your soul , I mean , speed. But to say which one is best... I think visual lisp has pretty much everything you need.

 

A template... mm , I think most of my lisp routines kinda have the same signature or structure. Some people like to capture as much of their code in one big mapcar / lambda dingding where I prefere a separate sub for almost every button I use in a dialog. This approach actually came from the VBA editor which did (does?) the same. You added a button in the dcl editor and VBA automaticaly added a sub. But its not a matter of one size fits all unfortunately... Often when I have an idea for a new program I look if I have one that looks roughly the same , saveas , change a few things , throw out what I don't need and that's basically about it. So often my last program becomes the template for the next one. So saveas your last appie , delete all buttons except ok & cancel and start adding your new buttons and toggles and other dingdings...

Share this post


Link to post
Share on other sites
pmxcad

Hi Robert,
I am working on a modified version of the lisp.
Have already made a number based on the lisp of this topic. Works wel.
Now I made one but I only get it working if I applied the following for example.

 

	("Elektrische-sluitplaat-incl-schootcontact"
	("Maak een keuze" "None")
	("Maak een keuze" "None")
	("Maak een keuze" "None"))



But I don't want to choose  "None" in these rows.
But if I choose one of the single lines, I want to immediately press OK.
Where do I have to make adjustments? In the "defun chk_ok" function?
Thanks in advance.

gr. Jaap

E-slot.lsp

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...