我尝试将catch apply函数的结果收集到单独的列表中,以便返回结果,但这会影响整体性能,因此我得到的最接近的结果是:
- (defun MakeInputLst ( key func arglst mainALst / mainALst expr )
- (if
- (and
- (= 'STR (type key)) (= 'SUBR (type func)) (listp arglst) (listp mainALst)
- (not (vl-catch-all-error-p (setq expr (vl-catch-all-apply 'func arglst))))
- )
- (setq mainALst (cons (cons key expr) mainALst))
- ); if
- mainALst
- );| defun MakeInputLst |; (or vlax-get-acad-object (vl-load-com)) (princ)
- (and
- (not (setq InputList (list)))
- (apply 'and (mapcar 'cdr (setq InputList (MakeInputLst "FirstPt" getpoint (list "\nSpecify first point: ") InputList))))
- (apply 'and (mapcar 'cdr (setq InputList (MakeInputLst "SecondPt" getpoint (list "\nSpecify second point: ") InputList))))
- (apply 'and (mapcar 'cdr (setq InputList (MakeInputLst "ThirdPt" getpoint (list "\nSpecify third point: ") InputList))))
- (apply 'and (mapcar 'cdr (setq InputList (MakeInputLst "ent" entsel (list "\nSelect an entity to get its layer: ") InputList))))
- (mapcar
- '(lambda (x)
- (and
- (member (car x) '("FirstPt" "SecondPt" "ThirdPt"))
- (entmakex (list (cons 0 "POINT") (assoc 8 (entget (car (cdr (assoc "ent" InputList))))) (cons 10 (cdr x))))
- )
- )
- InputList
- )
- ); and
我认为有一个更简单的方法。也许我会为此创建一个新的线程,因为OP的任务已经解决,我把这个问题重定向得太多了。
但正如你所见,我们的想法是跳过任何额外的setq,而是处理一个assoc列表,其中每个点对代表一个setq(为什么?-为什么不?)。 |