Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Show only
|
Search instead for
Did you mean:
This page has been translated for your convenience with an automatic translation service. This is not an official translation and may contain errors and inaccurate translations. Autodesk does not warrant, either expressly or implied, the accuracy, reliability or completeness of the information translated by the machine translation service and will not be liable for damages or losses caused by the trust placed in the translation service.Translate
I'm trying to write a lisp routine where I can click on an item (all I get are ASSURFACE to work with) and it pulls the color off that item. Then it needs to select all entities with that color to a certain layer (I've been using DATA_01, DATA_02, etc.). Then I want to freeze that layer.
The problem I'm having is the select by color and set that group to a layer.
If you can help me I'd appreciate it. I'm using MDT 2007.
Here's what I have so far:
(DEFUN C:S1 ()
(COMMAND "UNDO" "M")
(PRINC "\nSELECT THE COLOR YOU WANT TO PUT ON LAYER DATA_01... ")
(SETQ GROUP (SSGET)); <-- I think I need help here
(COMMAND "CHPROP" GROUP "" "LA" "DATA_01" "")
(COMMAND "-LAYER" "F" "DATA_01" "")
(PRINC "\nTHESE ITEMS HAVE BEEN PUT ON LAYER DATA_01.")
(PRINC)
)
Reply From: A_LOTA_NOTA:
You are wanting everything in the drawing that is the same color as the selected entity to be moved to layer "Data_01"?
Me:
The drawings I'm dealing with have the same color on multiple layers (don't ask me why) so yes everything in the drawing that is the same color to be moved to layer "DATA_01".
If the selected entity is color "ByLayer" and the Lisp didn't work, then I would probably leave that until the very last one.
Thanks for any help you can give. I really appreciate it. I'm going crazy with this one.
This should get you started. This gets the color of the entity you select. Post what you add & somone here will help!
(defun c:S1 (/ Source Entz CLR)
(while (not Source); checks to make sure something was selected
(setq Source (entsel "\nSELECT THE COLOR YOU WANT TO PUT ON LAYER DATA_01... ")); pick entity
(setq Entz (car Source)); entity name
(if (not (setq CLR (cdr (assoc 62 (entget Entz))))); entity color
(setq CLR (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 (entget Entz))))))); layer color
); end if
); end while
); end defun
(defun c:S1 (/ Source Entz CLR Ent SS1 Lngth Count Ent EntList)
(while (not Source); checks to make sure something was selected
(setq Source (entsel "\nSELECT THE COLOR YOU WANT TO PUT ON LAYER DATA_01... ")); pick entity
(setq Entz (car Source)); entity name
(if (not (setq CLR (cdr (assoc 62 (entget Entz))))); entity color
(setq CLR (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 (entget Entz))))))); layer color
); end if
); end while
(setq SS1 (ssget "X")); get all entitys
(setq Lngth (sslength SS1)); list length
(setq Count 0)
(while (< Count Lngth)
(setq Ent (ssname SS1 Count)); get next item from selection set
(if (not (or (eq 9 (cdr (assoc 62 (entget Ent))))
(eq 9 (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 (entget Ent)))))))
); end or
); end not
(progn
(ssdel Ent SS1); remove from selection set
); progn
(progn
(setq EnList (entget Ent)); group codes
(setq EnList (subst (cons 8 "DATA_01") (assoc 8 EnList) EnList)); replaces the old with the new
(entmod EnList); Changes the old
(entupd Ent); Regenerates the entity
); end prog
); end if
(setq Count (1+ Count)); add to count
); end while
); end defun
I tried what you gave me and it didn't work for this lisp. It kept giving me the error
error: bad argument
type: lentityp nil
Some of your code did work in another lisp I was trying to create. Thanks again for all your help.
This wont change the color of a line that is not set to bylayer. But that can be changed if thats the way you want it!
(defun c:S1 (/ Source Entz CLR Ent SS1 Lngth Count Ent EntList)
(while (not Source); checks to make sure something was selected
(setq Source (entsel "\nSELECT THE COLOR YOU WANT TO PUT ON LAYER DATA_01... ")); pick entity
(setq Entz (car Source)); entity name
(if (not (setq CLR (cdr (assoc 62 (entget Entz))))); entity color
(setq CLR (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 (entget Entz))))))); layer color
); end if
); end while
(setq SS1 (ssget "X")); get all entitys
(setq Lngth (sslength SS1)); list length
(setq Count 0)
(while (< Count Lngth)
(setq Ent (ssname SS1 Count)); get next item from selection set
(if (not (or (eq CLR (cdr (assoc 62 (entget Ent))))
(eq CLR (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 (entget Ent)))))))
); end or
); end not
(progn
(ssdel Ent SS1); remove from selection set
); progn
(progn
(setq EnList (entget Ent)); group codes
(setq EnList (subst (cons 8 "DATA_01") (assoc 8 EnList) EnList)); replaces the old with the new
(entmod EnList); Changes the old
(entupd Ent); Regenerates the entity
); end prog
); end if
(setq Count (1+ Count)); add to count
); end while
); end defun
Message was edited by: A_LOTA_NOTA