sivapathasunderam Posted February 6, 2018 Share Posted February 6, 2018 help with error code (defun c:somework () (setvar "cmdecho" 0) (command "_.select" "Fence" "-0.6,1.127" "36.9,1.245" " ") (command "_.change" "p" "c" "1") (princ) ) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted February 6, 2018 Share Posted February 6, 2018 Items selected with the fence method need to be visible on the screen. Try something like this to remove command calls. (defun c:foo (/ s) (if (setq s (ssget "_F" '((-0.6 1.127) (36.9 1.245)))) (mapcar '(lambda (x) (entmod (append (entget x) '((62 . 1))))) (mapcar 'cadr (ssnamex s))) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
sivapathasunderam Posted February 7, 2018 Author Share Posted February 7, 2018 Items selected with the fence method need to be visible on the screen. Try something like this to remove command calls. (defun c:foo (/ s) (if (setq s (ssget "_F" '((-0.6 1.127) (36.9 1.245)))) (mapcar '(lambda (x) (entmod (append (entget x) '((62 . 1))))) (mapcar 'cadr (ssnamex s))) ) (princ) ) thanks a lot if I want to add more lines Example: (-0.274,3.183) (11.324,2.947) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 7, 2018 Share Posted February 7, 2018 A fence can be as many points as you like, if two seperate lines look into ssad running ssget as required. (defun c:foo (/ s lst ) (setq lst '((-0.6 -1.127) (36.9 1.245) (-0.274 3.183) (11.324 2.947))) ; note comma removed (if (setq s (ssget "_F" lst )) (mapcar '(lambda (x) (entmod (append (entget x) '((62 . 1))))) (mapcar 'cadr (ssnamex s))) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
sivapathasunderam Posted February 7, 2018 Author Share Posted February 7, 2018 A fence can be as many points as you like, if two seperate lines look into ssad running ssget as required. (defun c:foo (/ s lst ) (setq lst '((-0.6 -1.127) (36.9 1.245) (-0.274 3.183) (11.324 2.947))) ; note comma removed (if (setq s (ssget "_F" lst )) (mapcar '(lambda (x) (entmod (append (entget x) '((62 . 1))))) (mapcar 'cadr (ssnamex s))) ) (princ) ) many thanks Bigal Last question! If I want to add different color, say color number 2 to this line (-0.6 -1.127) (36.9 1.245) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted February 7, 2018 Share Posted February 7, 2018 Try this: (defun c:foo (/ s) ;; List of '((color point point)(color point point)...) (foreach l '((2 (-0.6 1.127) (36.9 1.245)) (1 (-0.274 3.183) (11.324 2.947))) (if (setq s (ssget "_F" (cdr l))) (mapcar '(lambda (x) (entmod (append (entget x) (list (cons 62 (car l)))))) (mapcar 'cadr (ssnamex s)) ) ) ) (princ) ) Do you have an example drawing of what you're trying to accomplish? This process seems a bit odd to me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.