Jump to content

Rename layer by adding suffix with line type and color


balexx

Recommended Posts

I would like to ask if it is possible to rename the layer names in dwg adding also line thickness (0.05, 0.18 etc.) and color number (10, 20, (240,212,230) 56 etc.. )
Example : Wall       To        Wall_0.05_250
                  Water    To       Water _0.18_200_220_160

Thank you.
 

Link to comment
Share on other sites

On 8/29/2019 at 4:40 AM, harinezumi said:

very nice.
but rgb color is translated to indexed color. Possible to have rgb or book color name?
Thank you

Sure .. something like this:

(defun c:foo (/ el)
  (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
    (setq el (entget (vlax-vla-object->ename l)))
    (vl-catch-all-apply
      'vla-put-name
      (list
	l
	(strcat	(vla-get-name l)
		"_"
		(if (minusp (vla-get-lineweight l))
		  "Default"
		  (itoa (vla-get-lineweight l))
		)
		"_"
		(vl-princ-to-string
		  (cond	((cdr (assoc 430 el)))
			((assoc 420 el)
			 (mapcar '(lambda (x) (vlax-get (vla-get-truecolor l) x)) '(red green blue))
			)
			((cdr (assoc 62 el)))
		  )
		)
	)
      )
    )
  )
)
(vl-load-com)

 

  • Like 1
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...