jammer
Deze sectie stelt je in staat om alle bijdragen van dit lid te bekijken. Je kunt alleen de bijdragen zien waar je op dit moment toegang toe hebt.
Toon bijdragen MenuSAMPLE7 : dialog {
label = "Sample Dialog Box Routine - Part 7";
: column {
: row {
: boxed_column {
: radio_column {
key = "radios";
: radio_button {
label = "Draw Circle";
key = "drawcir";
value = "1";
}
: radio_button {
label = "Draw Polygon";
key = "drawpol";
value = "0";
}
}
: popup_list {
key = "numsides";
label = "Number of Sides";
width = 25;
fixed_width_font = true;
}
: toggle {
key = "saveset";
label = "Save settings";
}
}
: row {
: list_box {
label ="Select Layer";
key = "layerList";
height = 5;
width = 15;
multiple_select = false;
fixed_width_font = true;
value = "";
}
}
}
: row {
: button {
key = "accept";
label = " Okay ";
is_default = true;
}
: button {
key = "cancel";
label = " Cancel ";
is_default = false;
is_cancel = true;
}
}
}
}
(defun C:SAMPLE7()
(defun saveVars()
(setq radios(get_tile "radios"))
;;;--- Get the number of sides selected from the list
(setq sStr(get_tile "numsides"))
(if(= sStr "")
(setq numSides nil)
(setq numSides(nth (atoi sStr) numSides))
)
;;;--- See if the user wants to save the settings
(setq saveSet(atoi(get_tile "saveset")))
;;;--- Get the selected item from the layer list
(setq sStr(get_tile "layerlist"))
;;;--- If the index of the selected item is not "" then something was selected
(if(/= sStr "")
(progn
;;;--- Something is selected, so convert from string to integer
(setq sIndex(atoi sStr))
;;;--- And get the selected item from the list
(setq layerName(nth sIndex layerList))
)
;;;--- Else, nothing is selected
(progn
;;;--- Set the index number to -1
(setq sIndex -1)
;;;--- And set the name of the selected item to nil
(setq layerName nil)
)
)
)
(defun toggleRadio(a)
;if circle is selected
(if(= a 1)
(mode_tile "numsides" 1) ;disable
;else
(mode_tile "numsides" 0) ;enable
)
)
;;;--- Load the dcl file from disk into memory
(if(not(setq dcl_id (load_dialog "SAMPLE7.dcl")))
(progn
(alert "The DCL file could not be loaded!")
(exit)
)
;;;--- Else, the DCL file was loaded
(progn
;;;--- Load the definition inside the DCL file
(if (not (new_dialog "SAMPLE7" dcl_id))
(progn
(alert "The SAMPLE7 definition could not be loaded!")
(exit)
)
;;;--- Else, the definition was loaded
(progn
(setq layerList(list "0" "DIM" "HIDDEN" "STR" "TX" "WELD"))
(setq numSides(list "4" "6" "8" "12" "16"))
;;;--- Add the layer names to the dialog box
(start_list "layerlist" 3)
(mapcar 'add_list layerList)
(end_list)
;;;--- Add the number of sides to the dialog box
(start_list "numsides" 3)
(mapcar 'add_list numSides)
(end_list)
(if(/= (getvar "USERS1") "")
(progn
(setq radios (getvar "users1"))
(setq numStr (getvar "users2"))
(setq saveSet(getvar "users3"))
(setq layerIndex(getvar "users4"))
(set_tile "radios" radios)
(set_tile "numsides" numStr)
(set_tile "saveset" saveSet)
(set_tile "layerlist" layerIndex)
)
)
;;;--- Only disable the numSides popup_list if a circle is being drawn
(if(= radios "drawcir")
(mode_tile "numsides" 1)
)
;;;--- If an action event occurs, do this function
(action_tile "drawcir" "(toggleRadio 1)")
(action_tile "drawpol" "(toggleRadio 2)")
(action_tile "cancel" "(done_dialog 1)")
(action_tile "accept" "(saveVars)(done_dialog 2)")
;;;--- Display the dialog box
(start_dialog)
;;;--- Unload the dialog box
(unload_dialog dcl_id)
;;;--- If the cancel button was pressed - display message
(if (= ddiag 1)
(princ "\n \n ...SAMPLE7 Cancelled. \n ")
)
;;;--- If the "Okay" button was pressed
(if (= ddiag 2)
(progn
;;;--- Save the old layer and reset to new layer
(setq oldLay(getvar "clayer"))
(setvar "clayer" layerName)
;;;--- See what needs to be drawn
(if(= radios "drawcir")
(progn
(setq pt(getpoint "\n Center point: "))
(command "circle" pt pause)
)
;;;--- Else draw a polygon
(progn
(setq pt(getpoint "\n Center Point: "))
(command "polygon" numSides pt "C" pause)
)
)
;;;--- See if we need to save the settings
(if(= saveSet 1)
(progn
;;;--- Add code here to save the settings as defaults
(setvar "USERS1" radios)
(setvar "USERS2" numStr)
(setvar "USERS3" (itoa saveSet))
(setvar "USERS4" sSTR)
)
)
)
)
)
)
)
)
;;;--- Suppress the last echo for a clean exit
(princ)
)