TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MSTG007 on October 03, 2016, 03:19:59 PM

Title: Xlist with Layer Freeze or Change Color
Post by: MSTG007 on October 03, 2016, 03:19:59 PM
I found this really cool routine BY Willey did awhile ago. Which from the Command Line would xlist a layer selected and allow you to either change the layer color or freeze it in the current view.

http://forums.augi.com/showthread.php?39499-envoke-layer-dialogue-box-with-xlist (http://forums.augi.com/showthread.php?39499-envoke-layer-dialogue-box-with-xlist)


I was wondering how I could get this to be populated with a dialog box like the traditional express tool xlist command acts with either buttons under the name where you can click.

Not that its a big deal the way it works now. But all in all, great routine...

Code: [Select]
(defun C:ChangeXrefLayer (/ ActDoc LayCol Sel Ent LayName Opt)

(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq LayCol (vla-get-Layers ActDoc))
(setvar "errno" 0)
(while (/= (getvar "errno") 52)
 (if
  (and
   (setq Sel (nentsel "\n Select layer in xref: "))
   (> (length Sel) 2)
   (equal (logand 4 (cdr (assoc 70 (entget (tblobjname "block" (cdr (assoc 2 (entget (last (last Sel)))))))))) 4)
   (if (= (car (last Sel)) (last (last Sel)))
    (setq Ent (car Sel))
    (setq Ent (car (last Sel)))
   )
  )
  (progn
   (setq LayName (cdr (assoc 8 (entget Ent))))
   (initget "Freeze Color")
   (setq Opt (getkword (strcat "\n " Layname " - <F>reeze, Change color: ")))
   (if (= Opt "Color")
    (vla-put-Color (vla-Item LayCol LayName) (acad_colordlg 7))
    (vla-put-Freeze (vla-Item LayCol LayName) :vlax-true)
   )
  )
 )
)
(princ)
)
Title: Re: Xlist with Layer Freeze or Change Color
Post by: T.Willey on October 03, 2016, 03:40:35 PM
No help right now, but I don't know how I like being referred to as your Willey...

I found this really cool routine my Willey did awhile ago. ...<snip>
Title: Re: Xlist with Layer Freeze or Change Color
Post by: alanjt on October 03, 2016, 03:51:33 PM
No help right now, but I don't know how I like being referred to as your Willey...

I found this really cool routine my Willey did awhile ago. ...<snip>
Does it make you feel randy, baby?
Title: Re: Xlist with Layer Freeze or Change Color
Post by: T.Willey on October 03, 2016, 04:38:14 PM
No help right now, but I don't know how I like being referred to as your Willey...

I found this really cool routine my Willey did awhile ago. ...<snip>
Does it make you feel randy, baby?

Not sure about randy.  But dirty.... yes.  Definitely.
Title: Re: Xlist with Layer Freeze or Change Color
Post by: MSTG007 on October 03, 2016, 04:52:25 PM
My bad! so my bad! I'm sorry!
Title: Re: Xlist with Layer Freeze or Change Color
Post by: nobody on October 04, 2016, 01:56:57 AM
No help right now, but I don't know how I like being referred to as your Willey...

I found this really cool routine my Willey did awhile ago. ...<snip>

lol
Title: Re: Xlist with Layer Freeze or Change Color
Post by: MSTG007 on October 04, 2016, 08:20:31 AM
I just want everyone to know... I did fix my mistake! lol.
Title: Re: Xlist with Layer Freeze or Change Color
Post by: T.Willey on October 04, 2016, 03:13:30 PM
I just want everyone to know... I did fix my mistake! lol.
That is why I had to quote it before the change.


I do not have express tools, and do not know the xlist command or what it looks like.  Maybe a little explanation about what you want (picture maybe).
Title: Re: Xlist with Layer Freeze or Change Color
Post by: MSTG007 on October 04, 2016, 03:21:37 PM
lol. Hopefully this will help!
Title: Re: Xlist with Layer Freeze or Change Color
Post by: T.Willey on October 06, 2016, 04:35:32 AM
Here is a quick example of how you could do this.

The dcl code
Code: [Select]
QuickTest
: dialog { label = "Smalll example";
    : column {
        : spacer {}
        : text { key = "txt01"; }
        : text { key = "txt02"; }
        : text { key = "txt03"; }
        : spacer {}
    }
    : row {
        : spacer {}
        : button { label = "Button 1"; key = "btn01"; }
        : button { label = "Button 2"; key = "btn02"; }
        : button { label = "Button 3"; key = "btn03"; is_cancel = true; }
        : spacer {}
    }
}

Save to a file, <you name it>.dcl, and place within your search paths.

Then load the lisp code below, change the name from 'MyDialogs.dcl' to the name you saved the above dcl code to.

Code: [Select]
(defun c:diatest ( / dia opt )
   
    (setq dia (load_dialog "MyDialogs.dcl"))
    (if (not (new_dialog "QuickTest" dia))
        (exit)
    )

    (set_tile "txt01" "this is a text sting.")
    (set_tile "txt02" "With multiple lines.")
    (set_tile "txt03" "Again.")
    (action_tile "btn01" "(done_dialog 1)")
    (action_tile "btn02" "(done_dialog 2)")
    (action_tile "btn03" "(done_dialog 3)")

    (setq opt (start_dialog))
    (cond
        ((equal opt 1) (prompt "\nButton 1 pressed."))
        ((equal opt 2) (prompt "\nButton 2 pressed."))
        ((equal opt 3) (prompt "\nButton 3 pressed."))
        (t print opt)
    )
    (princ)
)

All this is going to do is print out which button you pressed, but it will give you an idea of how to code it up so that you can have those button be the options you want, and then execute that portion of the code.  I hope that makes sense.  Later you can worry about making the dialog look prettier and those things, but get a feel for working with dialogs and their associated lisp codes.
Title: Re: Xlist with Layer Freeze or Change Color
Post by: lamarn on October 06, 2016, 05:51:46 AM
Cool ! sir mr. T.
Title: Re: Xlist with Layer Freeze or Change Color
Post by: MSTG007 on October 06, 2016, 07:27:02 AM
Thanks. I will see how much I can mess this up! lol.