I need a little assistance on this lisp. Below is code for checking all entities in the drawings for Color/Linetype/Lineweight for BYLAYER. The problem I'm having is I want it to report to the user what the findings are as well as write the findings to a TEXT file only if there are any. If there are not any, then do not create a TEXT file.
Let's say it searched and found that there was only 3 objects with the linetype not set to BYLAYER. I need it to report and write to the text file the findings. If it found 3 objects with the linetype not set to BYLAYER and 5 objects with lineweights not BYLAYER, then I want it to report and write those findings etc....
Thanks for any help on this....
Don
(defun c:chkobjprops ()
(drawinginfo)
(getdate)
(setq badcolor 0)
(setq badlinetype 0)
(setq badlineweight 0)
(setq set1 (ssget "X"))
(setq setcount 0)
(repeat (sslength set1)
(setq entityX (ssname set1 setcount))
(setq entlistX (entget entityX))
(if (null (cdr (assoc 62 entlistX)))
(progn)
(setq badcolor (+ badcolor 1))
)
(if (null (cdr (assoc 6 entlistX)))
(progn)
(setq badlinetype (+ badlinetype 1))
)
(if (null (cdr (assoc 370 entlistX)))
(progn)
(setq badlineweight (+ badlineweight 1))
)
(setq setcount (+ setcount 1))
)
;;**Items Color BYLAYER or not**
(if (= badcolor 0)
(princ "\nAll object colors are BYLAYER.")
(progn
(alert (strcat "\nLocated "
(itoa badcolor)
" objects with a color assigned."
);end strcat
)
(setq openval (findfile valname))
(if (null openval)
(setq valfile (open valname "w"))
(setq valfile (open valname "a"))
)
(princ (strcat "VAL FILE CREATED ON: " DateTime) valfile)
(princ "\n\nThere are " valfile)
(princ badcolor valfile)
(princ " objects with a color assigned." valfile)
(princ "\n" valfile)
(close valfile)
)
)
;;**Items Color BYLAYER or not**
;;**Items Linetype BYLAYER or not**
(if (= badlinetype 0)
(princ "\nAll object linetypes are BYLAYER.")
(progn
(alert (strcat "\nLocated "
(itoa badlinetype)
" objects with a linetype assigned."
);end strcat
)
(setq openval (findfile valname))
(if (null openval)
(setq valfile (open valname "w"))
(setq valfile (open valname "a"))
)
(princ (strcat "VAL FILE CREATED ON: " DateTime) valfile)
(princ "\n\nThere are " valfile)
(princ badlinetype valfile)
(princ " objects with a linetype assigned." valfile)
(princ "\n" valfile)
(close valfile)
)
)
;;**Items Linetype BYLAYER or not**
;;**Items Lineweight BYLAYER or not**
(if (= badlineweight 0)
(princ "\nAll object lineweights are BYLAYER.")
(progn
(alert (strcat "\nLocated "
(itoa badlineweight)
" objects with a lineweight assigned."
);end strcat
)
(setq openval (findfile valname))
(if (null openval)
(setq valfile (open valname "w"))
(setq valfile (open valname "a"))
)
(princ (strcat "VAL FILE CREATED ON: " DateTime) valfile)
(princ "\n\nThere are " valfile)
(princ badlineweight valfile)
(princ " objects with a lineweight assigned." valfile)
(princ "\n" valfile)
(close valfile)
)
)
;;**Items Lineweight BYLAYER or not**
(progn)
)
(defun drawinginfo ()
(setq drawname (getvar "dwgname"));get dwg name
(setq drawpath (getvar "dwgprefix"));get dwg path
(setq justname (substr drawname 1 (- (strlen drawname) 4)));get just the drawing name without extension
(setq valname (strcat drawpath justname ".val"));set path and val file name
)
(defun getdate ()
(setq D (rtos (getvar "CDATE") 2 6)
YR (substr D 3 2)
MO (substr D 5 2)
DAY (substr D 7 2))
(setq P_DATE (strcat MO "/" DAY "/" YR))
(setq D (rtos (getvar "CDATE") 2 6)
MT (substr D 10 2)
MT (atoi MT))
(if (> MT 12)
(setq HR (- MT 12))
(setq HR MT)
)
(if (>= MT 12)
(setq TOD " PM")
(setq TOD " AM")
)
(setq HR (rtos HR 2 0))
(setq M (substr D 12 2)
S (substr D 14 2))
(setq P_TIME (strcat HR ":" M ":" S TOD))
(setq DateTime (strcat p_date P_time))
)