3dwannab Posted December 6, 2023 Posted December 6, 2023 Is there a method to select the objects in the ssget filter below that don't have hatches associated with them? I was to incorporate it into this lisp that hatches each object with the layer and other props of each of the objects in the selection set. (vl-load-com) ;; See thread here: https://www.cadtutor.net/forum/topic/77467-hatch-to-each-of-the-closed-polylines-match-the-colour-layer/ ;; Program to hatch objects in the ssget filter below to match the layer, colour and transparency of each object. ;; Answer by fuccaro and added undo handling and changed the selection method by myself (3dwannab) ;; First written on 2023.05.11 (defun c:HBC nil (c:HH_Boundary_Colour)) (defun c:HH_Boundary_Colour (/ *error* acDoc var_cmdecho var_osmode s sp h f) (defun *error* (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>\n")) ) (setvar 'cmdecho var_cmdecho) (setvar 'osmode var_osmode) ) (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)) (setq var_cmdecho (getvar "cmdecho")) (setq var_osmode (getvar "osmode")) (setvar 'cmdecho 0) (setvar 'osmode 0) ;; RJP » 2023-05-18 (cond ((setq s (ssget '((0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE")))) (setq sp (vlax-ename->vla-object (cdr (assoc 330 (reverse (entget (ssname s 0))))))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (cond ((vlax-curve-isclosed e) (setq h (vlax-invoke sp 'addhatch achatchobject "SOLID" :vlax-true)) (vlax-invoke h 'appendouterloop (list (vlax-ename->vla-object e))) (setq f (vl-remove-if-not '(lambda (x) (member (car x) '(8 62 420 430 440))) (entget e))) ;; Match layer and byobject colors (entmod (append (entget (vlax-vla-object->ename h)) f)) (vla-evaluate h) ) ) ) ) ) (*error* nil) (princ) ) ; (c:HBC) (princ (strcat " \n: ------------------------------\n'Hatch_Boundary_Colour.lsp' Loaded | Invoke by typing 'HH_Boundary_Colour' or 'HBC'.\n: ------------------------------\n")) (princ) Quote
Steven P Posted December 6, 2023 Posted December 6, 2023 Might be wrong but the hatch borders are separate from the hatch itself, the link is made in the hatch definition? You'd probably need to filter for hatches and polyline / circles / ellipse etc., then loop through the hatch definitions and remove the entity definition from the selection sets that the hatch refer to? Not something I've thought about doing - but could be handy to some to exclude hatch boundaries or include them. Quote
Tharwat Posted December 6, 2023 Posted December 6, 2023 If a hatch is associated to an object then you can find it attached in the dxf codes of the host object between the reactor opened & closed brackets. Happy digging. 1 Quote
3dwannab Posted December 8, 2023 Author Posted December 8, 2023 Thanks @Tharwat, is it the 102 one? Quote
Steven P Posted December 8, 2023 Posted December 8, 2023 I make it the last 330 (assoc 330 (reverse.....)) 1 1 Quote
Tharwat Posted December 8, 2023 Posted December 8, 2023 4 hours ago, 3dwannab said: Thanks @Tharwat, is it the 102 one? As Steven stated earlier , it's the 330 GC and this is if the object associated with hatch object otherwise the 330 will be only one and related to the session where the object positioned / located. 2 Quote
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.