Jump to content

Question regarding ('CECOLOR), ('CELTYPE), and ('CELWEIGHT)


Recommended Posts

Posted

Hello Folks,

 

Hope y'all are safe.

 

I have a question regarding getting colors, line types, and line weights.

 

If I use (getvar 'CECOLOR), (getvar 'CELTYPE), or (getvar 'CELWEIGHT) it gives me the CURRENT values.

 

Is there a way to get values when multiples are selected? (i.e. two lines that are set as bylayer and byblock)

 

(defun C:test ();  
   (princ (getvar 'cecolor))
   (princ "\n")
   (princ (getvar 'celweight))
   (princ "\n")
   (princ (getvar 'celtype))
   (princ)
)

 

The main reason I'm asking this is, i need to store dwg files into a different location if the drawing contains anything but bylayer property.

 

Please help, and Thank you in advance.

Posted

Firstly, welcome to CADTutor :D

 

To find out if "Anything" is not bylayer you would have to iterate through every entity in the drawing. Or do you mean something else?

Posted
7 minutes ago, dlanorh said:

Firstly, welcome to CADTutor :D

 

To find out if "Anything" is not bylayer you would have to iterate through every entity in the drawing. Or do you mean something else?

 

Thank you dlanorh,

 

Uhm Sorry, I'm kind of new to this AutoLISP programming, I'm not sure if I understood you correctly. XD

 

I'm assuming you meant i would have to have multiple if statements?

 

Basically, what I'm trying to do is to hit [Ctrl+A] and see if properties are set to "bylayers" as shown below

image.png.631cc5e14b2adae4d279870d436501d8.png

 

If they are not set to "bylayers" I'd have to save them in a different location.

 

Since I have almost 100k+ dwg to go through, it'd be very helpful to use AutoLISP.

Posted (edited)
2 hours ago, Alex_0518 said:

 

Thank you dlanorh,

 

Uhm Sorry, I'm kind of new to this AutoLISP programming, I'm not sure if I understood you correctly. XD

 

I'm assuming you meant i would have to have multiple if statements?

 

Basically, what I'm trying to do is to hit [Ctrl+A] and see if properties are set to "bylayers" as shown below

image.png.631cc5e14b2adae4d279870d436501d8.png

 

If they are not set to "bylayers" I'd have to save them in a different location.

 

Since I have almost 100k+ dwg to go through, it'd be very helpful to use AutoLISP.

 

So you're only interested in whether CECOLOR, CELTYPE and CELWEIGHT are set bylayer, or do you also need CELTSCALE & CETRANSPARENCY?

 

The lisp is the simple part, you could also use ODBX to process multiple drawings in a folder and move them, although I'm not au fait with ODBX

 

(defun c:isbylayer ( / sv_lst sv_vals clst)
  (setq sv_lst (list 'cecolor 'celtype 'celweight) sv_vals (list "BYLAYER" "BYLAYER" -1))
  (mapcar '(lambda (x y) (if (= (type y) 'STR) (setq clst (cons (= y (strcase (getvar x))) clst)) (setq clst (cons (= y (getvar x)) clst)))) sv_lst sv_vals)
  (princ (if (vl-every '(lambda (x) x) clst) "All ByLayer" "NOT ByLayer"))
  (princ)
)

 

Edited by dlanorh
Posted
1 hour ago, dlanorh said:

 

So you're only interested in whether CECOLOR, CELTYPE and CELWEIGHT are set bylayer, or do you also need CELTSCALE & CETRANSPARENCY?

 

The lisp is the simple part, you could also use ODBX to process multiple drawings in a folder and move them, although I'm not au fait with ODBX

 


(defun c:isbylayer ( / sv_lst sv_vals clst)
  (setq sv_lst (list 'cecolor 'celtype 'celweight) sv_vals (list "BYLAYER" "BYLAYER" -1))
  (mapcar '(lambda (x y) (if (= (type y) 'STR) (setq clst (cons (= y (strcase (getvar x))) clst)) (setq clst (cons (= y (getvar x)) clst)))) sv_lst sv_vals)
  (princ (if (vl-every '(lambda (x) x) clst) "All ByLayer" "NOT ByLayer"))
  (princ)
)

 

Thank you for your reply.

 

I'll do more digging.

Posted

Here's one way ( nothing nested checked )

(if (and (setq s (ssget "_X"))
	 (vl-some '(lambda (r) (vl-some '(lambda (j) (assoc j (entget r))) '(6 62 370)))
		  (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	 )
    )
  (alert "Something not bylayer!")
  (alert "All good!")
)

 

Posted (edited)

Another way unfortunately as mentioned need to check every object, erase the objects that match what you want or don't want, then saveas but be careful as you are erasing, or move the objects a fixed distance say to the right and use wblock then move them all back.

Edited by BIGAL

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