Trying to get BACKCOLOR from colored Graphic Button

Started by RGUS, February 10, 2013, 09:32:12 PM

Previous topic - Next topic

RGUS

See I knew it would be simple... I just need another 40 years in this stuff to begin to see the wood from the trees.

hanslammerts

#16
When try to use this, (AutoCAD 2017)

files Reply #13 with
command comment Reply #14 Roy..

this is what happens..

Figure this line is breaking the party
Command: ; error: AutoCAD command rejected: "color"
change it to (command "-color".. ) and that should work..? *EDIT * Not..

*EDIT*
Added opendcl directory for files as trusted directory in AutoCAD, restart, .. negative
I find it strange that in the odcl nothing is defined when i check 'event' 'onclick'(?), none of the numbers have (?)
Only esc at some point does give me a way out..

RGUS

#17
Quote from: hanslammerts on January 31, 2017, 01:24:29 PM
When try to use this, (AutoCAD 2017)
this is what happens..

Just tried the code provided earlier with AutoCAD 2017 and it displays perfectly. I couldn't get the error you are having.

hanslammerts

#18
I think this dialog is very good. I model / draw all with thé most simple layernames onw can think of ;-)..:
1,2,3,4,5 ..following colorcode.

Great stuff!
With some tweaks i would like it to turn into this this..

(..replacement for..)
command:1
command:2
command:3
etc.

(> if layers is not available, make layer > then layer current + start function to select object to make turn it this layer..)


Code (autolisp) Select

;;; either change current selection to current layer or start drawing line on current layer
(defun XYZ_laycmnd ( lyr / ss1 p1 idx)
  ;(c:makel)
  (if (and (tblsearch "LAYER" lyr)
           (setq ss1 (ssget "_I"))
      )
    ;; if selection, change to layer
    (repeat (setq idx (sslength ss1))
      (vla-put-layer
        (vlax-ename->vla-object (ssname ss1 (setq idx (1- idx))))
        lyr
      )
    )
    ;; if no selection, start drawing line on layer
    (progn
      (command "layer" "set" lyr "on" lyr "")
      (c:lac)
     
;;;      (if (setq p1 (getpoint "LINE From point: "))
;;;        (command "line" p1)
;;;      ) ;if
    ) ;progn
  ) ;if
)


Code (autolisp) Select

(defun c:1 (/ p1)  (XYZ_laycmnd "1") (princ))
(defun c:2 (/ p1)  (XYZ_laycmnd "2") (princ))
(defun c:3 (/ p1)   (XYZ_laycmnd "3") (princ))








hanslammerts

#19
Trying to get this routine started, but failing in more then one way..

- noticed that Autolisp file path was assigned to a local c:\ drive from the author. How to get rid of this? i don't how this can be set to <none>
- See that none of the index number have event  'clicked' assigned, shouldn't that be?
- BBlock was not there i believe.
- did some editing in the code. I have the feeling something in the code that is ;;;commented is failing and giving errors.

If someone can help me a little in the right direction, i would appriciate that.
The errors do not seem as normal behaviour for a beginner..
thanks

roy_043

Fixed files attached.

Modifications to the .odcl file:
1.
Menu > Project > Set AutoLISP File Name > select .lsp file
I don't know how to remove this file name, but it is only used in the Studio.
See: Menu > Tools > Write Events to Lisp File
2.
Menu > Tools > Clear Lisp Symbol Names > OK
3.
Menu > Tools > Reset Event Names > OK

Note 1:
It is important that you do not call AutoCAD commands in event handlers.
Note 2:
The dialog is not finished. Only the buttons on top row and the last three buttons on the bottom row have an OnClicked event. So there is still some work to do.
Note 3:
Why don't you use the built-in color dialog?:
Code (autolisp) Select
(acad_colordlg 1 T)

hanslammerts

#21
Nice of you to take a look Roy! :)

Sofar i made it to this. It's not quite finished yet and i bet you have some findings on my coding..

done this:
- buttons work
- make layer if not available
- functions "select layer" combined with "change elements" work (user can use escape, or tune it to use it only as colornumber..)

- a bottom part to expand , *EDIT*
- works, review the code if you like....  12-2-2017 *EDIT*  see animated gif
- needs better handling support : select objects first  17-2-2017 *EDIT*
- defun c:lac handles select objects first 17-2-2017 *EDIT*
- defun c:lac handles select objects first better 22-2-2017 *EDIT*

For now, i like it ..


hanslammerts

I made the dialog a modeless one.
Somehow i can get the button down / expand turn the real unfolding good.. hmmm  :-\

it has height 45 / 450 
width 750

Code (autolisp) Select


(defun c:color_swatch/COLOR_SWATCH/cmdExpand#OnClicked ( / );_ expand
(if (< (Cadr (dcl-Form-GetControlArea color_swatch/COLOR_SWATCH)) 400)
(progn
(dcl-Form-Resize color_swatch/COLOR_SWATCH 750 450)
(dcl-Control-SetPicture color_swatch/COLOR_SWATCH/cmdExpand 100)
) ());_ if
   

(if (> (Cadr (dcl-Form-GetControlArea color_swatch/COLOR_SWATCH)) 400)
(progn
(dcl-Form-Resize color_swatch/COLOR_SWATCH 750 45)
(dcl-Control-SetPicture color_swatch/COLOR_SWATCH/cmdExpand 101)
) ());_if
)

(princ)



See last previous post for code..

roy_043

#23
Hans, in the example you refer to (c:FormMover/Form1/cmdExpand#OnClicked) there is only a single 'if', why are there two in your code?
BTW 1:
At least 25 buttons still do not have an OnClicked event.
BTW 2:
The dcl-Form-Show method behaves differently for a modeless from. So you will have to revise the current logic of the c:CSW function.

hanslammerts

I updated the code. #21
Think its working a lot better now.
Thanks for your feedback Roy_043!