If you do an amount of property switching for visibility, enabled, color etc
think about doing the process in a foreach block ..
note necessarily faster, but sure is easier on the eyes ..
;;;------------------------------------------------------------
(DEFUN _HighlightControl (Control)
(FOREACH item (LIST CTA17-GridBalloons_F_Single12
CTA17-GridBalloons_F_Crossover
CTA17-GridBalloons_F_FullGrid
)
(ODCL_CONTROL_SETBACKCOLOR item -16)
)
(ODCL_CONTROL_SETBACKCOLOR Control -14)
)
;;;------------------------------------------------------------
;;;------------------------------------------------------------
(DEFUN _SetoutTablesOn ()
(FOREACH control (LIST
CTA17-GridBalloons_F_X-Label
CTA17-GridBalloons_F_X-Grid
CTA17-GridBalloons_F_Addx
CTA17-GridBalloons_F_ClearX
;;
CTA17-GridBalloons_F_Y-Label
CTA17-GridBalloons_F_Y-Grid
CTA17-GridBalloons_F_AddY
CTA17-GridBalloons_F_ClearY
;;
CTA17-GridBalloons_F_AddDimensions
CTA17-GridBalloons_F_DimensionCombo
CTA17-GridBalloons_F_DimensionFrame
;;
CTA17-GridBalloons_F_ReadDataFile
CTA17-GridBalloons_F_SaveDataFile
)
(ODCL_CONTROL_SETVISIBLE control T)
)
;;
(Odcl_Control_SetCaption CTA17-GridBalloons_F_X-Label "X ... Setout")
(Odcl_Control_SetCaption CTA17-GridBalloons_F_Y-Label "Y ... Setout")
;;
)
;;;------------------------------------------------------------
(DEFUN _SetoutX-TablesOff ()
(FOREACH control (LIST
CTA17-GridBalloons_F_X-Label
CTA17-GridBalloons_F_X-Grid
CTA17-GridBalloons_F_AddX
CTA17-GridBalloons_F_ClearX
CTA17-GridBalloons_F_ReadDataFile
CTA17-GridBalloons_F_SaveDataFile
)
(ODCL_CONTROL_SETVISIBLE control nil)
)
)
;;;------------------------------------------------------------
;; and the calling code looks something like this ..
;;;------------------------------------------------------------
(DEFUN c:CTA17-GridBalloons_F_Crossover_OnClicked (/)
(_HighlightControl CTA17-GridBalloons_F_Crossover)
(_SetoutX-TablesOff)
(_SetoutY-TablesOff)
(_Setout-DimsOff)
(ODCL_FORM_RESIZE CTA17-GridBalloons_F 295 335)
(SETQ gvar:BalloonStyle 2)
)
;;;------------------------------------------------------------
For anyone who is using the GridControl and wants to save the data.
This code reads the data from 2 columns in each of 2 GridControls ...
;;;------------------------------------------------------------
(DEFUN _extractGridData ()
(SETQ
;;.............. removed for clarity
)
(SETQ RowCount (ODCL_GRID_GETROWCOUNT CTA17-GridBalloons_F_X-Grid)
RowIndex 0
g:dataListX '()
)
(WHILE (< RowIndex RowCount)
(SETQ g:dataListX
(CONS (CONS (ODCL_GRID_GETITEMTEXT CTA17-GridBalloons_F_X-Grid RowIndex 1)
(ODCL_GRID_GETITEMTEXT CTA17-GridBalloons_F_X-Grid RowIndex 2)
)
g:dataListX
)
)
(SETQ RowIndex (1+ RowIndex))
)
(setq g:dataListX (reverse g:dataListX))
;;--
(SETQ RowCount (ODCL_GRID_GETROWCOUNT CTA17-GridBalloons_F_Y-Grid)
RowIndex 0
g:dataListY '()
)
(WHILE (< RowIndex RowCount)
(SETQ g:dataListY
(CONS (CONS (ODCL_GRID_GETITEMTEXT CTA17-GridBalloons_F_Y-Grid RowIndex 1)
(ODCL_GRID_GETITEMTEXT CTA17-GridBalloons_F_Y-Grid RowIndex 2)
)
g:dataListY
)
)
(SETQ RowIndex (1+ RowIndex))
)
(setq g:dataListY (reverse g:dataListY))
)
;;;------------------------------------------------------------
... and then writes it to disk using (ODCL_WRITEBIN <fnHandle> <data>) in the
c:CTA17-GridBalloons_F_SaveDataFile_OnClicked function.
Note that this uses the version of ODCL_WRITEBIN updated and posted here by dan yesterday ( should be included in Build Beta17 )
(DEFUN c:CTA17-GridBalloons_F_SaveDataFile_OnClicked (/ documentpath data fnHandle)
(_extractGridData)
(SETQ documentpath (GETFILED "Source File" (GETVAR "dwgprefix") "data" 1)
data (LIST g:dataListX g:dataListY)
fnHandle (ODCL_OPENBIN documentpath "w")
)
(ODCL_WRITEBIN fnHandle data)
(ODCL_CLOSEBIN fnHandle)
)
... and this is the data.
((("1" . "2000")
("2" . "3000")
("3" . "2000")
("3a" . "1000")
("3b" . "1200")
("4" . "1500")
("5" . "2500")
("6" . "2800")
("7" . "2000")
)
(("A" . "3000")
("B" . "3000")
("C" . "3000")
("D" . "3000")
("E" . "3000")
("F" . "3000")
)
)
... and the obligatory piccy ..