OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: Emiliano on March 26, 2012, 10:58:44 PM

Title: Read and write color in Combobox
Post by: Emiliano on March 26, 2012, 10:58:44 PM
I just can not understand how to use the combobox with style "4 - Color".  :'(
I simply want to understand how to read and set a color.

- To read the color set, use the following code
Code (autolisp) Select

(setq col (dcl_ComboBox_GetTBText Applic_Form_ComboCol)))


However, in this way, the revenue of the color string in the language of AutoCAD (English, Italian, German, etc..)
how can I get the number of colors selected to avoid checking the language of AutoCAD?

- To set a color using the lisp code, I tried using
Code (autolisp) Select

(setq num_color "3") ;<--Green
(dcl_ComboBox_SetCurSel Applic_Form_ComboCol (+ (atoi num_color) 1))


This code works, until the list of the colors, is added, at the top the last color used.  :'(

I'm confused  ???
Can you help me?
Thanks in advance.
Title: Re: Read and write color in Combobox
Post by: owenwengerd on March 27, 2012, 10:10:57 AM
See if this function retrieves the color value:
http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/ComboBox/GetItemData.htm (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/ComboBox/GetItemData.htm)
Title: Re: Read and write color in Combobox
Post by: Emiliano on March 27, 2012, 10:05:50 PM
Hi
Thanks for the reply.
Now I understand that finding the number of selected color in combox.

However the most difficult problem is to select, using the lisp code, a certain color.
I have a combobox that contains eg. the following list of colors:

Color71
Color73
Color96
Red
Yellow
Green <--Current Selection
Cian
Blue
Magent

How do I select the color "Blue" using Lisp code?
Thanks in advance
Title: Re: Read and write color in Combobox
Post by: owenwengerd on March 27, 2012, 10:29:13 PM
See if this helps:
http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/ComboBox/FindColor.htm (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/ComboBox/FindColor.htm)
Title: Re: Read and write color in Combobox
Post by: Emiliano on March 28, 2012, 07:13:53 AM
Thanks again for your reply.
I hope it is useful to someone, with your help I wrote the following functions:

Code (autolisp) Select

(defun TTComboGetColor (control / col)
  (setq col (dcl_ComboBox_GetItemData control (dcl_ComboBox_GetCurSel control)))
  col
)

(defun TTComboSetColor (control col / findel)
  (setq findel (dcl_ComboBox_FindColor control col))
  (if (= findel nil)
    (progn
      (dcl_ComboBox_AddColor control col)
      (setq findel (dcl_ComboBox_FindColor control col))
    )
  )
  (dcl_ComboBox_SetCurSel control findel)
)
Title: Re: Read and write color in Combobox
Post by: Peter2 on March 20, 2015, 05:37:26 PM
Is this solution still the current way to get the selected color in OpenDCL 8?

I looked around, found old examples with "GetTBText" (which seem to be outdated ...), tried with GetLBText and GetCurSel, and at the moment I'm a little bit confused ....
Title: Re: Read and write color in Combobox
Post by: owenwengerd on March 20, 2015, 05:59:15 PM
Yes, this is the correct way to get the selected color value. If you want the displayed text, GetLBText should work.