sivapathasunder 发表于 2022-7-5 15:36:02

Select texts & change color

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))

ronjonp 发表于 2022-7-5 15:53:30

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))

sivapathasunder 发表于 2022-7-5 16:11:38

 
thanks a lot
 
if I want to add more lines
Example:   (-0.274,3.183)(11.324,2.947)

BIGAL 发表于 2022-7-5 16:15:14

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)
)

sivapathasunder 发表于 2022-7-5 16:30:52

 
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)

ronjonp 发表于 2022-7-5 16:47:12

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.
页: [1]
查看完整版本: Select texts & change color