arka69 Posted November 19, 2008 Posted November 19, 2008 I´ve made a little function for changing easily attributes in entities It goes like this (defun atribsubst (valorcambiado grupocodigo nombreobjeto) (entmod (subst (cons grupocodigo valorcambiado) (assoc grupocodigo (entget nombreobjeto)) (entget nombreobjeto) ) ) ) Works pretty well , but for dxf group codes which are on default (for which there's no entry in entities atribute's list to be SUBStituted doesn´t work. So I added one fix with IF function... (defun atribsubst2 (valorcambiado grupocodigo nombreobjeto) (entmod (if (not (assoc grupocodigo (entget nombreobjeto))) ;;;so if there are no entry I add it (cons (cons grupocodigo valorcambiado) (entget nombreobjeto)) ;;;otherwise It works with same routine (subst (cons grupocodigo valorcambiado) (assoc grupocodigo (entget nombreobjeto)) (entget nombreobjeto)) ) ) ) Which seem to work, no error, return the list. But after that, nothing changes... I´ve used it to change color (dxf code 62) to red (n 1) of one poly wich was on "bylayer" (default, so there's no entry in its atrib list) (atribsubst2 1 62 (car (entsel))) It returns ((62 . 1) (-1 . ) (0 . "LWPOLYLINE") (330 . ) (5 . "1B0") (100 . "AcDbEntity") so on... But no color change, and doing (entget (car (entsel))) on same object returns (-1 . ) (0 . "LWPOLYLINE") (330 . ) (5 . "1B0") (100 . "AcDbEntity") so on... :? What am I doing wrong? I´m using acad 2008 :wink: Quote
Lee Mac Posted November 19, 2008 Posted November 19, 2008 have you included the following code in your LISP: (defun c:colourtest (/ ent1) (setq ent1 (entget (car (entsel)))) (if (assoc 62 ent1) (setq ent1 (subst (cons 62 1) (assoc 62 ent1) ent1)) (setq ent1 (cons (cons 62 1) ent1)) ) ; end if [color=Red][b](entmod ent1)[/b][/color] (princ) ) Quote
arka69 Posted November 19, 2008 Author Posted November 19, 2008 Yes, Check it, "entmod" it's just before the "if" function, so I don't have to write it two times it works with the "if"output case. I'm checking if your code works on my ACAD2008... I'll let you know instantly Quote
arka69 Posted November 19, 2008 Author Posted November 19, 2008 Aha, it doesn´t work neither. Guess it´s supossed to change the enitity color to red, even if it was set on "bylayer", but in this case doesn´t work. Maybe it needs to have its right position on atrib list? I mean in acad 2008...? Quote
Lee Mac Posted November 19, 2008 Posted November 19, 2008 ahh, sorry Arka - didnt spot the "entmod" in there. All I can think is that it must be an ACAD 08 thing, because the LISP I posted works fine on ACAD 04. Quote
arka69 Posted November 19, 2008 Author Posted November 19, 2008 Yeah, I think so, it's one of the many advantages of having a too recent version... Anyway, just for confirmation purposes... anybody can test the code "colortest" on an entity with color "bylayer" and running autocad 2008? Quote
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.