Jump to content

Existing Hatch used as Boundary for New Hatch


blatz.boy

Recommended Posts

I'm basically trying to create a hatch within a hatch. I have a grid created with ANSI 137, and I'm trying to create a series of solid fill squares withing this grid, but the existing grid/hatch is not being recognized as a boundary at all.

 

I seem to remember having done this in the past without incident, but have recently upgraded to 2012. To get the job off my desk, I'm just exploding the hatch for the moment, but I hate doing this. Any suggestions?

 

Thanks.

Link to comment
Share on other sites

I *beleive* this requires that a copy of the ANSI 137 hatch be copied to a construction / temporary layer, then exploded, then place your new solid fill hatches, then LAYDEL the construction / temporary layer.

Link to comment
Share on other sites

I'm sure there are better ways of doing this (I just don't have time at the moment), but this should provide you a solid start....

 

Example:

 

(defun c:HIH () (c:HatchInsideHatch))
(defun c:HatchInsideHatch  (/ *error* *exit* ss eName oHatchOld activeDoc
                           oldQaflags oldCmdecho oldNomutt layerName)
 ;; © RenderMan 2011, CADTutor.net
 (princ "\rHATCH INSIDE HATCH ")
 (vl-load-com)

 (defun *error*  (msg)
   (cond ((not msg))                                                   ; Normal exit
         ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
         ((princ (strcat "\n** Error: " msg " ** "))))                 ; Fatal error, display it
   (*exit*))

 (defun *exit*  ()
   (if (and layerName (setq ss (ssget "_x" (list (cons 8 layername)))))
     (progn
       (vlax-for x
                 (setq ss (vla-get-activeselectionset activeDoc))
         (vla-delete x))
       (vla-delete ss)
       (vla-delete (vla-item (vla-get-layers activeDoc) layerName))))
   (and oldNomutt (setvar 'nomutt oldNomutt))
   (and oldCmdecho (setvar 'cmdecho oldCmdecho))
   (and oldQaflags (setvar 'qaflags oldQaflags))
   (vla-endundomark activeDoc)
   (princ))

 (vla-startundomark
       (setq activeDoc
              (vla-get-activedocument (vlax-get-acad-object))))
 (terpri)
 (prompt "\nSelect hatch: ")
 (if (and (and (setq oldQaflags (getvar 'qaflags)) (setvar 'qaflags 1))
          (and (setq oldCmdecho (getvar 'cmdecho)) (setvar 'cmdecho 0))
          (and (setq oldNomutt (getvar 'nomutt)) (setvar 'nomutt 1))
          (setq ss (ssget "_:L:S:E" '((0 . "HATCH"))))
          (/= "SOLID" (cdr (assoc 2 (entget (setq eName (ssname ss 0))))))
          (setq oHatchOld (vlax-ename->vla-object eName)))
   (progn
     (vl-cmdf "._-layer"
              "new"
              (setq layerName "Z_HatchInHatch")
              "color"
              (vla-get-color
                (vla-item (vla-get-layers activeDoc)
                          (vla-get-layer oHatchOld)))
              layerName
              "")
     (vla-put-layer (vla-copy oHatchOld) layerName)
     (vl-cmdf "._explode" (entlast) "")
     (setvar 'nomutt 0)
     (prompt "\nPick internal points: ")
     (vl-cmdf "._-hatch" "properties" "solid")
     (while (< 0 (getvar 'cmdactive))
       (command pause)))
   (progn
     (setvar 'nomutt 0)
     (cond (ss (prompt "\n** Solid hatch pattern not allowed ** "))
           ((prompt "\n** Nothing selected ** ")))))
 (*exit*))

 

Note - Resultant hatch objects are created on the current layer.

 

@ Moderator - Would you move this thread to the LISP forum, please?

Edited by BlackBox
Code update - Solid hatch check
Link to comment
Share on other sites

If you just want a boundary search for hatchb.lsp it makes a new pline boundary.

 

I'd be very disappointed if that is all the OP is after.

 

I (mis?)understood the OP to be asking for how to use the line work of the selected hatch as a boundary for subsequent hatch creation (hence the code I posted).

Link to comment
Share on other sites

I'd be very disappointed if that is all the OP is after.

 

I (mis?)understood the OP to be asking for how to use the line work of the selected hatch as a boundary for subsequent hatch creation (hence the code I posted).

 

That's they way I understood it.

 

That code looks good, I will give it a try later on today.

Link to comment
Share on other sites

That's they way I understood it.

 

That code looks good, I will give it a try later on today.

 

It worked well for testing the ANSI 137 hatch the OP specified. Not sure why it would work with other hatch patterns, except for Solid (ohhh, I should add a check for that! :oops:)

 

Edit - Code updated above.

 

I recorded a demo using SnagIt, but sadly that only allows me to save as .AVI - Not sure how to convert to .GIF to post with the (lack of) software installed on my laptop. :(

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