Search the Community
Showing results for tags 'tblsearch'.
-
Insert a block based upon search/found criteria?
ILoveMadoka posted a topic in AutoLISP, Visual LISP & DCL
Up til now I have had 3 separate routines for inserting a block based upon the existence of an inserted block in a drawing. (if (tblsearch "BLOCK" "BlockA") (command "-insert" "Block1" "0,0" "" "" "")) (if (tblsearch "BLOCK" "BlockB") (command "-insert" "Block2" "0,0" "" "" "")) (if (tblsearch "BLOCK" "BlockC") (command "-insert" "Block3" "0,0" "" "" "")) I was wanting to combine them into a single routine similar to this; (defun c:foo () (cond (if (tblsearch "BLOCK" "BlockA") (command "-insert" "Block1" "0,0" "" "" "")) (if (tblsearch "BLOCK" "BlockB") (command "-insert" "Block2" "0,0" "" "" "")) (if (tblsearch "BLOCK" "BlockC") (command "-insert" "Block3" "0,0" "" "" "")) ) (princ)) [Which does not work correctly BTW - it does not go beyond the first step] I also wondered "what if more than one block exists?" Ideally only one of these blocks "should" exist in a drawing in my situation. How can I test for the existence of more than one block first and return an error if found or insert the appropriate block meeting the criteria otherwise? I read about using wcmatch if I set (setq myblks (list "BlockA" "BlockB" "BlockC")) Not sure how to incorporate that if it is the better way I have pieces and parts but cannot put it together Help please.. ps: When using multiple searches, how to you proceed to the next search if the criteria is not met? (if (tblsearch "BLOCK" "BlockA") (command "-insert" "Block1" "0,0" "" "" "")) -
Is it possible to make this more compact? (DEFUN C:TEST () (if (/= (tblsearch "STYLE" "ROMANS")) (COMMAND "-STYLE" "ROMANS" "ROMANS" "" "" "" "N" "N" "N") (if (= (tblsearch "STYLE" "SLDTEXTSTYLE0")) (COMMAND "-STYLE" "SLDTEXTSTYLE0" "ROMANS" "" "" "" "N" "N" "N") (if (= (tblsearch "STYLE" "SLDTEXTSTYLE1")) (COMMAND "-STYLE" "SLDTEXTSTYLE1" "ROMANS" "" "" "" "N" "N" "N") (if (= (tblsearch "STYLE" "SLDTEXTSTYLE2")) (COMMAND "-STYLE" "SLDTEXTSTYLE2" "ROMANS" "" "" "" "N" "N" "N") (if (= (tblsearch "STYLE" "SLDTEXTSTYLE3")) (COMMAND "-STYLE" "SLDTEXTSTYLE3" "ROMANS" "" "" "" "N" "N" "N") (if (= (tblsearch "STYLE" "SLDTEXTSTYLE4")) (COMMAND "-STYLE" "SLDTEXTSTYLE4" "ROMANS" "" "" "" "N" "N" "N") (if (= (tblsearch "STYLE" "SLDTEXTSTYLE5")) (COMMAND "-STYLE" "SLDTEXTSTYLE5" "ROMANS" "" "" "" "N" "N" "N") (if (= (tblsearch "STYLE" "SLDTEXTSTYLE6")) (COMMAND "-STYLE" "SLDTEXTSTYLE6" "ROMANS" "" "" "" "N" "N" "N") (if (= (tblsearch "STYLE" "SLDTEXTSTYLE7")) (COMMAND "-STYLE" "SLDTEXTSTYLE7" "ROMANS" "" "" "" "N" "N" "N") (if (= (tblsearch "STYLE" "SLDTEXTSTYLE8")) (COMMAND "-STYLE" "SLDTEXTSTYLE8" "ROMANS" "" "" "" "N" "N" "N") (PRINC)) Guidance if so please?
- 12 replies
-
- style
- solidworks
-
(and 2 more)
Tagged with: