Author Topic: Xlist with Layer Freeze or Change Color  (Read 2616 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Xlist with Layer Freeze or Change Color
« 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


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)
)
« Last Edit: October 03, 2016, 04:52:47 PM by MSTG007 »
Civil3D 2020

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xlist with Layer Freeze or Change Color
« Reply #1 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>
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Xlist with Layer Freeze or Change Color
« Reply #2 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?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xlist with Layer Freeze or Change Color
« Reply #3 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Xlist with Layer Freeze or Change Color
« Reply #4 on: October 03, 2016, 04:52:25 PM »
My bad! so my bad! I'm sorry!
Civil3D 2020

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Xlist with Layer Freeze or Change Color
« Reply #5 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

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Xlist with Layer Freeze or Change Color
« Reply #6 on: October 04, 2016, 08:20:31 AM »
I just want everyone to know... I did fix my mistake! lol.
Civil3D 2020

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xlist with Layer Freeze or Change Color
« Reply #7 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).
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Xlist with Layer Freeze or Change Color
« Reply #8 on: October 04, 2016, 03:21:37 PM »
lol. Hopefully this will help!
Civil3D 2020

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Xlist with Layer Freeze or Change Color
« Reply #9 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

lamarn

  • Swamp Rat
  • Posts: 636
Re: Xlist with Layer Freeze or Change Color
« Reply #10 on: October 06, 2016, 05:51:46 AM »
Cool ! sir mr. T.
Design is something you should do with both hands. My 2d hand , my 3d hand ..

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Xlist with Layer Freeze or Change Color
« Reply #11 on: October 06, 2016, 07:27:02 AM »
Thanks. I will see how much I can mess this up! lol.
Civil3D 2020