Jump to content

ssget filter objects that are not hatched


3dwannab

Recommended Posts

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)

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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.

  • Like 2
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...