Jump to content

Hatch Associativity and Separate isse


Recommended Posts

Posted

Hi, ok so I am trying to write a small lisp that will allow me to select a hatch that is Associative and has Multiple Hatches. I want to be able to separate them and not have associative but I'm still learning how to write small lisps. Been searching and figured it is time to see if maybe someone can help me out. Thank you in advance


(Defun C:FH ()
 (Command "-BHATCH" "S" PAUSE "" "" "A" "A" "_N" "H" "_Y" "")
)

 

All I get back is a "Unknown command "h" "y" etc

Posted

Hi Bigal, what I am trying to do is combine two separate commands to modify a current hatch to separate and un-associate but all I get are errors

On ‎11‎/‎1‎/‎2019 at 8:04 PM, BIGAL said:

Have you tried HB hatch boundary it makes separate boundaries.

 

Posted

Perhaps post an example drawing to show what you are trying to do. At first glance - I don't see what (2) commands you are trying to combine. The BHATCH command does not have the extra prompts you are applying to it. USE the "-HATCH" command rather than "BHATCH". Then I suggest you walk through the command manually and review what you entered in the text screen.

 

 

Posted (edited)

Try this:

(command "-Hatch" "_A" "_H" "_Y" "_A" "_N" "" "_S")
(while (= (logand (getvar "cmdactive") 1) 1)
	(command pause)
)
(command "")

(EDIT: Updated to add remove Associativity option)

Edited by pkenewell
Posted (edited)

What I am trying to do is click on the Hatches (top picture) and separate hatches and not have any associative on them (bottom picture)

 

 

From This.JPG

To This.JPG

Edited by Dj_T_Rex2002
Posted (edited)

If you want to edit an existing Hatch, use the "-HATCHEDIT" Command. Try the following:

(defun c:HSEP (/ ss)
   (princ "\nSelect hatches to Separate and Disassociate: ")
   (if (setq ss (ssget ":S" '((0 . "HATCH"))))
      (progn
         (command "-HATCHEDIT" ss "_DI")
         (command "-HATCHEDIT" ss "_H")
      )
   )
   (princ)
)

This will both Disassociate and Separate a Hatch.

 

EDIT: Note this only works with single selection. A bit more extensive code will be needed to do multiple hatches.

Edited by pkenewell
Posted
Quote

only works with single selection

 

Pretty easy to fix, you can add more filters if required like layer and "X" which will do all.

(defun c:HSEP (/ ss hat)
   (princ "\nSelect hatches to Separate and Disassociate: ")
   (if (setq ss (ssget '((0 . "HATCH"))))
      (progn
	  (repeat (setq x (sslength ss))
	  (setq hat (ssname ss (setq x (- x 1))))
         (command "-HATCHEDIT" hat "_DI")
         (command "-HATCHEDIT" hat "_H")
	  )
      )
   )
   (princ)
)
(c:hsep)

 

Posted
1 hour ago, BIGAL said:

Pretty easy to fix, you can add more filters if required like layer and "X" which will do all.

Thanks Big Al. I knew it was something along those lines but was distracted by work LOL.

Posted

THAT'S IT!!!! Thank you so much guys. I guess now I'll have to break it down to see what you did so I can learn lol. Thank you so much!!

Posted (edited)

A deeper explanation

 

(defun c:HSEP (/ ss hat) 					; a defun the c: implys a command line call
   (princ "\nSelect hatches to Separate and Disassociate: "); print message on command line
   (if (setq ss (ssget '((0 . "HATCH"))))			; make a slection of Hatch items only add "X" to get all
      (progn							; if ss is successful run the next steps in code
	  (repeat (setq x (sslength ss))		; repeat the process for the number of items in the selection set ss
	  (setq hat (ssname ss (setq x (- x 1))))		; get the X entity hatch details from the selection set note starts at 0 item
         (command "-HATCHEDIT" hat "_DI")			; disassociate hatch
         (command "-HATCHEDIT" hat "_H")			; seperate hatchs
	  )
      )
   )
   (princ)													; exit defun quitely
)
(c:hsep)

 

Edited by BIGAL

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