Jump to content

Recommended Posts

Posted

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. :huh:

 

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... :unsure:

 

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:

Posted

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

Posted

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

Posted

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...?

Posted

ahh, sorry Arka - didnt spot the "entmod" in there. :oops:

 

All I can think is that it must be an ACAD 08 thing, because the LISP I posted works fine on ACAD 04.

Posted

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?

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