3dwannab Posted July 2, 2018 Author Share Posted July 2, 2018 I'm having an issue with this select Hatch lisp. See comments in code where the error is occurring. (cons 41 patScale) is at fault. It fails when selecting solid hatches. Others seem fine. Thanks in advance. (defun c:QS_HLPSCB nil (c:QS_HATCH_SAME_Layer_PatternName_PatternScale_Color_&_BkgColor)) (defun c:QS_HATCH_SAME_Layer_PatternName_PatternScale_Color_&_BkgColor ( / bkgCol layColor layer patName patScale ss nSS ssdata ) (while (not (and (setq ss (car (entsel "\nSelect Hatch to get same Hatch entities as:\nLayer, Pattern Name, Pattern Scale, Colour & Background Colour :")) ssdata (if ss (entget ss)) ) (= (cdr (assoc 0 ssdata)) "HATCH") (sssetfirst nil) (setq ss (vlax-ename->vla-object ss)) (progn (princ (vla-get-PatternScale ss)) ; Printing out the scale okay (setq bkgCol (vla-get-backgroundcolor ss) bkgCol (vla-get-ColorIndex (vla-get-BackgroundColor ss)) layColor (vla-get-color ss) layer (vla-get-Layer ss) patName (vla-get-PatternName ss) patScale (vla-get-PatternScale ss) ; (cons 41 patScale) THIS FAILS BELOW ; error: bad argument type: lselsetp nil ss (ssget "X" (list (cons 8 layer) '(0 . "HATCH") (cons 2 patName) (cons 41 patScale) (cons 62 layColor) (cons 410 (getvar 'ctab)))) nSS (ssadd) ) (repeat (setq i (sslength ss)) (and (setq e (ssname ss (setq i (1- i)))) (= bkgCol (vla-get-ColorIndex (vla-get-BackgroundColor (vlax-ename->vla-object e)))) (ssadd e nSS) ) ) (princ (strcat "\n >>> " (itoa (setq len (sslength nSS))) (if (> len 1) " items" " item") " selected <<< ")) (sssetfirst nil nSS) ) ) ) (prompt "\n >>> Nothing selected or not a Hatch ! <<< ") ) (princ) ) (vl-load-com) (princ "\nQS_HATCH_SAME_Layer_PatternName_PatternScale_Color_&_BkgColor.lsp | Version 1.0 | by 3dwannab") (princ "\nType \"QS_HATCH_SAME_Layer_PatternName_PatternScale_Color_&_BkgColor\" OR \"QS_HLPSCB\" to Invoke") (princ) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted July 2, 2018 Share Posted July 2, 2018 Change your SSGET to this: (ssget "X" (vl-remove 'nil (list (cons 8 layer) '(0 . "HATCH") (cons 2 patname) (if (/= "SOLID" patname) (cons 41 patscale) ) (cons 62 laycolor) (cons 410 (getvar 'ctab)) ) ) ) Quote Link to comment Share on other sites More sharing options...
3dwannab Posted July 2, 2018 Author Share Posted July 2, 2018 Change your SSGET to this: Thank you very much. FULL CODE: ;; Select HATCH by: Layer, Pattern Name, Pattern Scale, Colour & Background Colour ;; by 3dwannab on 11.04.17 ;; Rev 1: 02.07.18 - Fix ssget Scale problem with solid hatch. ;; ;; Help by GRRR: http://www.cadtutor.net/forum/showthread.php?100136-Select-Hatch-by-background-color&p=681038&viewfull=1#post681038 ;; Help by ronjonp: http://www.cadtutor.net/forum/showthread.php?94817-Select-Hatch-Pattern-by-Scale-and-pattern&p=704522&viewfull=1#post704522 ;; ;; Known Bugs: None ;; (defun c:QS_HLPSCB nil (c:QS_HATCH_SAME_Layer_PatternName_PatternScale_Color_&_BkgColor)) (defun c:QS_HATCH_SAME_Layer_PatternName_PatternScale_Color_&_BkgColor ( / bkgCol layColor layer patName patScale ss nSS ssdata ) (while (not (and (setq ss (car (entsel "\nSelect Hatch to get same Hatch entities as:\nLayer, Pattern Name, Pattern Scale, Colour & Background Colour :")) ssdata (if ss (entget ss)) ) (= (cdr (assoc 0 ssdata)) "HATCH") (sssetfirst nil) (setq ss (vlax-ename->vla-object ss)) (progn (setq bkgCol (vla-get-backgroundcolor ss) bkgCol (vla-get-ColorIndex (vla-get-BackgroundColor ss)) layColor (vla-get-color ss) layer (vla-get-Layer ss) patName (vla-get-PatternName ss) patScale (vla-get-PatternScale ss) ss (ssget "X" (vl-remove 'nil (list (cons 8 layer) '(0 . "HATCH") (cons 2 patname) (if (/= "SOLID" patname) (cons 41 patscale) ) (cons 62 laycolor) (cons 410 (getvar 'ctab)) ) ) ) nSS (ssadd) ) (repeat (setq i (sslength ss)) (and (setq e (ssname ss (setq i (1- i)))) (= bkgCol (vla-get-ColorIndex (vla-get-BackgroundColor (vlax-ename->vla-object e)))) (ssadd e nSS) ) ) (princ (strcat "\n >>> " (itoa (setq len (sslength nSS))) (if (> len 1) " items" " item") " selected <<< ")) (sssetfirst nil nSS) ) ) ) (prompt "\n >>> Nothing selected or not a Hatch ! <<< ") ) (princ) ) (vl-load-com) (princ "\nQS_HATCH_SAME_Layer_PatternName_PatternScale_Color_&_BkgColor.lsp | Version 1.0 | by 3dwannab") (princ "\nType \"QS_HATCH_SAME_Layer_PatternName_PatternScale_Color_&_BkgColor\" OR \"QS_HLPSCB\" to Invoke") (princ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.