Jump to content

Request for 'simple' DCL, as final puzzle piece...


Recommended Posts

Posted

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>")

image.png.12f655507b9da4eeee0829e04f0eb19b.png

 

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

 

 

Posted

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

🐉

  • Like 1
  • Thanks 1
Posted

@rlx

 

Thanks for the quicky!

This was just what i needed. 🙂

Posted

you're welcome Aftertouch :beer:

 

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

 

🐉

  • Like 1
Posted (edited)

 

 

@rlx Nice mfl idea 😎  though your cfl can ;multiple_select=true 

 

my $0.05 

7ednyLV.png

 

BCAD's VLIDE supports unicode 

 
(setq s (if    (wcmatch (setq r (nth (atoi v) l)) "*☐*")
          "☑ " ;"\U+2611 "
          "☐ " ;"\U+2610 "
          )
      )

 

Edited by hanhphuc
typo 2610
Posted

nice idea hanhphuc , maybe time for us all to switch to BCAD :beer:

Posted

lee-mac has a dual list dcl ideal for this as you "Add" to a blank list so create multiple.

 

Posted
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 😁

Posted
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. :lol:

..and the more scary he becomes (his knowledge).

 

 

 

Posted

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 😁

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