Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/01/2024 in all areas

  1. @mhupp, You cannot do (ssadd nil ss3) you will get an " error: bad argument type: lentityp nil". So you need the if clause. ;;SSint by mhupp ;; ;; ;; ;; Return a selection set of Common element to both sets ;; ;; ;; (defun ssint (ss1 ss2 / e ss3) (setq ss3 (ssadd)) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1))) (if (ssmemb e ss2) (ssadd e ss3)) ) ss3 )
    2 points
  2. The C:47 means you can type 47 on the command line, the C + colon means that the lisp defun can be used as a command, a (defun 47 would not work from command line if you type 47, when these defuns were made various users wanted different osnaps so it was easiest to just call the functions names as a number, if you make your own you could use (defun c:zzz as the triple z is easy to type, same as say aaa. Why not c:123, typing Myosnaps is to long for me. You could even do O1, O2 etc for 2 different osnap settings You will see in lots of code here the use of C :
    1 point
  3. As steven suggested I replaced Initget with a library DCl the one to use is Multi Radio Buttons.lsp, you just save it to a support directory so it can autoload. Yes there is Multi getvals, Multi toggles, plus a couple more. (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (setq ans (ah:butts 1 "V" '("Please pick" jeldwin" Brown" "Newmar" "Pollard" ))) Multi radio buttons.lsp
    1 point
  4. You can make bounding boxes from groups and then apply routines like there were only rectangles... You must also have big rectangular sheet where to place bounding boxes, but as far as I remember no rotations by 90 degree were included in solution codes...
    1 point
  5. This is challenge topic, but if you need it, maybe this topic may help... https://www.theswamp.org/index.php?topic=52260.0
    1 point
  6. I think that this: (setq q (getpoint "\nSpecify 2nd point: " p)) Should actually be this: (setq q (getpoint p "\nSpecify 2nd point: "))
    1 point
  7. @dungcan68 The error you are describing could not be coming from the code you have presented, but rather an global error handler made by some other additional code not included in what you have shown. The error itself comes from using the (command) function within an error handler, which causes some issues in newer versions of AutoCAD. the (command-s) function was created to allow command functions from within an error handler when referencing local variables, but older code that was not upgraded may display this error. I recommend you start looking through other AutoLISP functions you have loaded to determine which code is using a global error handler that contains the (command) function. See the following link for more info: https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-5C9DC003-3DD2-4770-95E7-7E19A4EE19A1
    1 point
  8. I see what your saying could be condensed down to. bad code
    1 point
  9. Doesn't ssadd add the entity if it is not there else it ignores it - so not sure you need the(if (ssmemb.....) ? (weekend.... )
    1 point
  10. i would just use I would use ssmemb then. this will create a global selection set SS3 ;;----------------------------------------------------------------------------;; ;; Create a third selection set of values found in both selection sets provied ;; (ssint ss sss) (defun SSInt (SS1 SS2) (setq SS3 (ssadd)) ;create a blank selection set to add entitys to (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS1))) ;generate a list of entity names (if (ssmemb ent SS2) ;test if its in the other selection set (ssadd ent ss3) ;add to the 3rd selection set if true ) ) (princ) )
    1 point
  11. Maybe like this : (defun c:sss-intersection ( / MR:ListsIntersection-sel-sets ss lst ) (defun MR:ListsIntersection-sel-sets ( ll / sel-set->ename-list ename-lists r l1 l2 rr k ) ;;; ll - list of sel.sets (defun sel-set->ename-list ( ss / i r ) (repeat (setq i (sslength ss)) (setq r (cons (ssname ss (setq i (1- i))) r)) ) r ) (setq ename-lists (mapcar (function (lambda ( x ) (sel-set->ename-list x))) ll)) (while (and (setq l1 (car ename-lists)) (setq l2 (cadr ename-lists))) (setq r (vl-remove-if-not '(lambda ( x ) (member x l2)) l1)) (setq ename-lists (subst r l2 ename-lists)) (setq ename-lists (cdr ename-lists)) ) (if r (progn (setq rr (ssadd) k -1) (repeat (length r) (ssadd (nth (setq k (1+ k)) r) rr) ) ) ) (if (and (= (type rr) (quote pickset)) (> (sslength rr) 0)) (sssetfirst nil rr) ) ) (prompt "\nChoose selections - when done press ENTER or right click...") (while (setq ss (ssget)) (setq lst (cons ss lst)) ) (MR:ListsIntersection-sel-sets lst) (princ) ) HTH. M.R.
    1 point
  12. I spent some more time with your drawing, here is the Lisp slightly adjusted. Now it searches only for texts that are at least 4 characters long. Also all the lines are placed on a new layer so you can delete them at once after the job is done. (defun c:pp( / ss ss2) (setq ss (ssget "X" '((0 . "TEXT")))) (setq a8 '(8 . "ConnectLines")) (repeat (setq i (sslength ss)) (setq en1 (ssname ss (setq i (1- i))) el1 (entget en1) a1 (assoc 1 el1)) (cond ((> (strlen (cdr a1)) 3) (setq a10 (assoc 10 el1) ss2 (ssget "X" (list '(0 . "TEXT") a1))) (repeat (setq j (sslength ss2)) (setq a11 (cons 11 (cdr (assoc 10 (entget (ssname ss2 (setq j (1- j)))))))) (cond ((/= a10 a11) (entmake (list '(0 . "LINE") a10 a11 a8)))) ) ) ) ) )
    1 point
  13. My suggestion that works with your example. To use it in other situations you will have to modify the arguments constituting the filters (ssget "_W" and "_X") for it to work. (defun c:FOO ( / ss_o ss_t n dxf_ent lst_o) (setq ss_o (ssget "_W" '(2027.9092 -426.6579) '(2327.9092 373.3421) '((0 . "TEXT") (8 . "TEXT") (62 . 2) (40 . 30.0) (7 . "GHS")))) (cond (ss_o (setq ss_t (ssget "_X" '((0 . "TEXT") (8 . "0") (62 . 7) (6 . "ByBlock") (40 . 3.4) (7 . "Single")))) (cond (ss_t (repeat (setq n (sslength ss_o)) (setq dxf_ent (entget (ssname ss_o (setq n (1- n)))) lst_o (cons (cons (cdr (assoc 1 dxf_ent)) (list (cdr (assoc 10 dxf_ent)))) lst_o) ) ) (repeat (setq n (sslength ss_t)) (setq dxf_ent (entget (ssname ss_t (setq n (1- n))))) (cond ((member (cdr (assoc 1 dxf_ent)) (mapcar 'car lst_o)) (entmake (list (cons 0 "LINE") (cons 10 (cdr (assoc 10 dxf_ent))) (cons 11 (cadr (assoc (cdr (assoc 1 dxf_ent)) lst_o))) ) ) ) ) ) ) ) ) ) (prin1) )
    1 point
  14. It may be easier to try this expects that you are picking 3 field text objects, expects that the destination mtext exists. ; pick multi mtext and paste into another mtext ; By AlanH March 2024 (defun c:wow ( / txt1 txt2 txt3 obj4) (setq txt1 (vlax-ename->vla-object (car (entsel "Pick 1st text object ")))) (setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-objectid txt1)) ">%).TextString>%" ) ) (setq txt2 (vlax-ename->vla-object (car (entsel "Pick 2nd text object ")))) (setq str (strcat str "-" "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-objectid txt2)) ">%).TextString>%" ) ) (setq txt3 (vlax-ename->vla-object (car (entsel "Pick 3rd text object ")))) (setq str (strcat str "-" "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-objectid txt3)) ">%).TextString>%" ) ) (setq obj4 (vlax-ename->vla-object (car (entsel "Pick destination text ")))) (vlax-put obj4 'textstring str) (princ) )
    1 point
×
×
  • Create New...