The 2016.0923 version of the API finally provides the "ultimate" solution to SSGET with keywords.
SSGET with keywords has always been what LISPER wants, but limited by the functions of LISP, no matter what kind of LISP solution, the SSGET selection cannot be perfectly combined with GETXXX keywords.
Because the API relies on ARX, it combines ARX's acedSSGetKwordPtr() and other functions with LISP usage habits and encapsulates them, bringing the API functions xdrx_initSSGet and xdrx_ssget functions.
Just like the keyword setting of the GETXXX class requires the function initget, xdrx_ssget requires the xdrx_initssget function preset keyword and other information.
Usage of xdrx-initssget function:(xdrx_initSSGet <"Select object prompt string"> ["Keyword"] ["Remove object prompt string"] ["Keyword callback function"] ["Non-keyword input callback function"])
Parameters between
<> are required,
and parameters between
[] are optional.
1. Select object prompt string: SSGET no longer looks at the static "Select object:" prompt string. You can customize your
own prompt string. 2. Keywords: Enter keywords separated by spaces, and do not conflict with SSGET's own "fixed"
keywords, such as W, C, WP, CP, etc.
3. Remove object prompt string: Customize your own prompt string when inputting R in SSGET.
4. Keyword callback function: After entering the keyword, activate the function called to process the keyword (optional)
5. Non-keyword callback function: the processing function called when a non-keyword is entered (optional)
The API has two schemes for handling keywords:1. Give the callback function parameters:
Features: Without interrupting SSGET, the function that needs to be processed after the callback function processes
the keyword completes the required work. After the callback function is executed, the SSGET process continues.
2. No callback function:
Features, just like the keyword processing method we are used to in GETXXX class functions, when keyword parameters are given, if no callback function parameters are given or "" is given to the callback function, then when the keyword is entered, SSGET ends and a string is returned. to LISP.
3. The parameters of the selection set function xdrx_ssget are the same as those of the ordinary SSGET function.
Here are two sets of example programs for processing keywords:
1) In xdrx_initSSGet, give keywords and callback function parameters, process keywords, and enter the distance of the offset polyline without interrupting SSGET. (xdrx_begin)
)
(xdrx_initssget "Select the curve to be offset [Settings (XL)]<Exit>:";;Select object prompt string
"XL" ;;keyword
"" ;;Remove object prompt string
"_callback" ;;Keyword callback function
"_callback1" ;;Non-keyword callback function
)
(if (setq wid
(getreal (xdrx_prompt
"\nPlease enter the offset distance<" #wid
">:" t
))) )
)
)
)
(if (setq ss
(xdrx_ssget '
((0 .
"LWPOLYLINE")(-4 .
"&=")(70 .
1)))) (xdrx_curve_getoffsetcurves ss #wid)
)
)
(xdrx_end)
)
2) The code structure is the same as that of ordinary GETXXX function processing keywords, and is processed according to the returned keywords (SSGET is interrupted during the period) (xdrx_begin)
)
tf
(xdrx_initssget "Select the curve to be offset [Settings (XL)]<Exit>:" "XL" "" "" "")
)
((= tf1 'STR)
(if (setq wid
(getreal (xdrx_prompt
"\nPlease enter the offset distance<" #wid
">:" t
)
)
)
)
)
)
((= tf1 'PICKSET)
(xdrx_curve_getoffsetcurves ss #wid)
)
)
)
(xdrx_end)
)
xdrx_ssget perfectly combines keyword processing and SSGET operations. On the basis of keyword processing, it fully realizes the function of SSGET.================
![](https://www.theswamp.org/index.php?action=dlattach;topic=58806.0;attach=41643;image)
In fact, rewrite the second solution above as follows:
"\nPlease enter the offset distance<"
#wid
">:"
t
)
)
)
)
)
"\nCurrent Setting: ***offset distance ( "
#wid
" )***"
)
)
(xdrx_begin)
)
tf
(_prompt)
(xdrx
-initget "T");;Set input T and press Enter directly (xdrx_initssget
"Select the curve to be offset [Settings(T)] <Exit>:"
"T" ""
"" ""
)
)
((= tf1 'STR)
(_getdist)
;; Call the function (is it equivalent to the callback function of the first solution?)
)
)
((= tf1 'PICKSET)
(setq ss1
(xdrx_curve_getoffsetcurves ss #wid
)) (xdrx-entity-setcolor ss1 1)
)
)
)
(xdrx_end)
)
Compared with the first solution, the first solution is to put the function _getdist() into xdrx_initssget and declare it. The judgment and processing of whether to enter the keyword are all processed inside xdrx_ssget, without interrupting the ssget process, and the code is shorter ( There is no WHILE loop and COND judgment keyword), and the efficiency is higher.
The above code can be omitted:
((= tf1 'STR)
(_getdist)
;; Call the function (is it equivalent to the callback function of the first solution?)
)
)
((= tf1 'PICKSET)
(xdrx_curve_getoffsetcurves ss #wid)
)
)
(if (setq ss
(xdrx_ssget '
((0 .
"LWPOLYLINE")(-4 .
"&=")(70 .
1)))) (xdrx_curve_getoffsetcurves ss #wid)
)
)
Equivalent to:
tf
(xdrx_initssget
"Select the curve to be offset [Settings (XL)] <Exit>:"
"XL" ""
"" ""
)
)
((= tf1 'STR)
(_getdist)
;; Call the function (is it equivalent to the callback function of the first solution?)
)
)
((= tf1 'PICKSET)
(xdrx_curve_getoffsetcurves ss #wid)
)
)
)
=====================
1. Only the selection prompt string is required, the others are optional.
2. If keywords and callback functions are given, then it is the first option.
3. If a keyword is given and the keyword callback function is not given, this is the second option.
4. The non-keyword callback function does not matter, whether it is provided or not does not matter. This is to adapt to the expansion of ARX functions. Currently, it will never be given or "" will be given.