Aftertouch Posted June 5, 2020 Posted June 5, 2020 Hello everybody, Usualy, i create my own lisps and when i get stuck i ask for help. But in this case i got an other type of problem. We used to have a plug-in that we used to create layers from an excelsheet to AutoCAD. The developer has stopped the support of this tool and now, we cannot use it anymore. I managed to create a LSP-code that wil create a layer with the right settings from an EXCEL-database into the DWG. Now i am looking for a way to give the users a selection methode to pick the layer they want to be created. I am thinking of a DCL-format, where i get a scrollable list with all my layer names, and a simple button that wil execute 'my' command to create that layer. That should look something like this, where the user can select a layername, and press a button, that wil execute command: (CREATENEWLAYER "<layername>") The list could be generated from a (setq layerlist (list "layer1" "layer2" "layer3"), i can make the translation from the excel to that format. BUT... I have never done anything with DCL, and to the honest, i find it hard to learn DCL. We are in pretty need of a tool like this, so i am realy hoping somebody can help me fix this last piece of my puzzle... Quote
rlx Posted June 5, 2020 Posted June 5, 2020 just a quicky (before my boss finds out) ; choose from list (defun cfl (l / f p d r) (and (setq p (open (setq f (vl-filename-mktemp ".dcl")) "w")) (princ "cfl:dialog{label=\"Choose\";:list_box{key=\"lb\";}ok_cancel;}" p) (not (setq p (close p)))(< 0 (setq d (load_dialog f)))(new_dialog "cfl" d) (progn (start_list "lb")(mapcar 'add_list l)(end_list) (action_tile "lb" "(setq r (nth (atoi $value) l))(done_dialog 1)") (action_tile "accept" "(setq r (get_tile \"lb\"))(done_dialog 1)") (action_tile "cancel" "(setq r nil)(done_dialog 0)") (start_dialog)(unload_dialog d)(vl-file-delete f) ) ) (cond ((= r "") nil)(r r)(t nil)) ) (defun c:t1 ( / lay-list) (setq lay-list '("layer1" "layer2" "layer3")) (if (setq inp (cfl lay-list)) (alert (strcat "You selected " inp))(alert "You cancelled")) (princ) ) 1 1 Quote
Aftertouch Posted June 5, 2020 Author Posted June 5, 2020 @rlx Thanks for the quicky! This was just what i needed. Quote
rlx Posted June 5, 2020 Posted June 5, 2020 you're welcome Aftertouch its a single selection only but if you want to be able to select multiple options maybe this one helps : ; multiple from list (setq inp (mfl '("A" "B" "C" "D") '("A" "B"))) (defun mfl (%l %df / toggle l f p d r) (setq l (mapcar '(lambda (x)(if (member x %df)(strcat "[X] " x)(strcat "[O] " x))) %l)) (defun toggle (v / s r) (if (eq (substr (setq r (nth (atoi v) l)) 2 1) "X") (setq s "[O] ") (setq s "[X] ")) (setq l (subst (strcat s (substr r 5)) r l))(start_list "lb")(mapcar 'add_list l)(end_list)) (and (setq p (open (setq f (vl-filename-mktemp ".dcl")) "w")) (princ "cfl:dialog{label=\"Choose\";:list_box {key=\"lb\";} ok_cancel;}" p) (not (setq p (close p)))(< 0 (setq d (load_dialog f)))(new_dialog "cfl" d) (progn (start_list "lb")(mapcar 'add_list l)(end_list) (action_tile "lb" "(toggle $value)") (action_tile "accept" "(setq r (get_tile \"lb\"))(done_dialog 1)") (action_tile "cancel" "(setq r nil)(done_dialog 0)") (start_dialog)(unload_dialog d)(vl-file-delete f))) (mapcar '(lambda (y)(substr y 5)) (vl-remove-if '(lambda (x)(eq (substr x 2 1) "O")) l)) ) or his bigger brother : multiple input listbox function 1 Quote
hanhphuc Posted June 6, 2020 Posted June 6, 2020 (edited) @rlx Nice mfl idea though your cfl can ;multiple_select=true my $0.05 BCAD's VLIDE supports unicode (setq s (if (wcmatch (setq r (nth (atoi v) l)) "*☐*") "☑ " ;"\U+2611 " "☐ " ;"\U+2610 " ) ) Edited June 6, 2020 by hanhphuc typo 2610 Quote
rlx Posted June 6, 2020 Posted June 6, 2020 nice idea hanhphuc , maybe time for us all to switch to BCAD Quote
BIGAL Posted June 6, 2020 Posted June 6, 2020 lee-mac has a dual list dcl ideal for this as you "Add" to a blank list so create multiple. Quote
rlx Posted June 7, 2020 Posted June 7, 2020 9 hours ago, BIGAL said: lee-mac has a dual list dcl ideal for this as you "Add" to a blank list so create multiple. I doubt there is anything that master Lee doesn't already have Quote
hanhphuc Posted June 10, 2020 Posted June 10, 2020 On 6/7/2020 at 4:33 PM, rlx said: I doubt there is anything that master Lee doesn't already have i recall Grrr's On 4/7/2018 at 7:32 AM, Grrr said: As for Lee, I always thought he's far ahead of everyone.. (and I still think so) So with my every code attempt I kept the thought "can I even impress this guy with some of my codes?" Then I realised how experienced he is, so perhaps the answer was 'no'.. so my next thought was "can I get close to his skill?" So I learned/practiced, but the thing was every time I ask about something on the forums - and he answers, he reveals how much he knows about the subject.. so instead of thinking that I'm getting closer I realise how much stuff I didn't knew about! So this guy is like the Universe: the more you ask him, the more he reveals, and the more you know how much you don't know. ..and the more scary he becomes (his knowledge). Quote
rlx Posted June 10, 2020 Posted June 10, 2020 I think we are all created equal but some people just have better focus and / or better chances to shine in this world. Even master Lee has his limits its just his is so much higher than most of us. Still , he's (probably?) no rocket engineer else he wouldn't be responding on this site but at Nasa's site Quote
Recommended Posts
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.