Jump to content

Prefix Layer name with Lineweight


loudy000

Recommended Posts

Hi All,

 

I have existing layers that i need to rename based from current layer property (line weight and color) example

 

image.thumb.png.17305d5b01d58ef3f659bc4b4e562b07.png

 

the new name would be:

 

0.50-alu-profile

 

any help would be much appreciated.

 

 

Thanks.

Link to comment
Share on other sites

I don't see where the color fits in...

(defun c:test ( / dmz ly lynm obj wgt)
    (setq dmz (getvar 'dimzin))
    (setvar 'dimzin 0)
    (while (setq ly (tblnext "layer" (null ly)))
	(setq ly (cdr (assoc 2 ly))
	      obj (tblobjname "layer" ly)
	      wgt (cdr (assoc 370 (entget obj)))
	      lynm (strcat (rtos (* wgt 0.01) 2 2) "-" ly)
	      )
	(entmod
	    (subst
		(cons 2 lynm)
		(assoc 2 (entget obj))
		(entget obj)
		)
	    )
	)
    (setvar 'dimzin dmz)
    )

 

The above should do it (I think... because I don't know how in my computer the line weight reads 50 instead of 0.50, so I just divide by 100)

  • Like 1
Link to comment
Share on other sites

38 minutes ago, Jonathan Handojo said:

I don't see where the color fits in...


(defun c:test ( / dmz ly lynm obj wgt)
    (setq dmz (getvar 'dimzin))
    (setvar 'dimzin 0)
    (while (setq ly (tblnext "layer" (null ly)))
	(setq ly (cdr (assoc 2 ly))
	      obj (tblobjname "layer" ly)
	      wgt (cdr (assoc 370 (entget obj)))
	      lynm (strcat (rtos (* wgt 0.01) 2 2) "-" ly)
	      )
	(entmod
	    (subst
		(cons 2 lynm)
		(assoc 2 (entget obj))
		(entget obj)
		)
	    )
	)
    (setvar 'dimzin dmz)
    )

 

The above should do it (I think... because I don't know how in my computer the line weight reads 50 instead of 0.50, so I just divide by 100)

 

Thank you very much!

Link to comment
Share on other sites

@loudy000 Like this?

(defun c:test ( / dmz ly lynm obj pat wgt)
    (setq dmz (getvar 'dimzin))
    (setvar 'dimzin 0)
    (while (setq ly (tblnext "layer" (null ly)))
	(setq ly (cdr (assoc 2 ly))
	      obj (tblobjname "layer" ly)
	      wgt (cdr (assoc 370 (entget obj)))
	      pat (cdr (assoc 6 (entget obj)))
	      lynm (strcat (rtos (* wgt 0.01) 2 2) "-" pat "-" ly)
	      )
	(entmod
	    (subst
		(cons 2 lynm)
		(assoc 2 (entget obj))
		(entget obj)
		)
	    )
	)
    (setvar 'dimzin dmz)
    )
  • 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...