Jump to content

Select texts & change color


sivapathasunderam

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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)

)

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...