Dj_T_Rex2002 Posted November 1, 2019 Posted November 1, 2019 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 Quote
BIGAL Posted November 2, 2019 Posted November 2, 2019 Have you tried HB hatch boundary it makes separate boundaries. Quote
Dj_T_Rex2002 Posted November 4, 2019 Author Posted November 4, 2019 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. Quote
pkenewell Posted November 4, 2019 Posted November 4, 2019 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. Quote
pkenewell Posted November 4, 2019 Posted November 4, 2019 (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 November 4, 2019 by pkenewell Quote
Dj_T_Rex2002 Posted November 5, 2019 Author Posted November 5, 2019 (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) Edited November 5, 2019 by Dj_T_Rex2002 Quote
pkenewell Posted November 5, 2019 Posted November 5, 2019 (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 November 5, 2019 by pkenewell Quote
BIGAL Posted November 5, 2019 Posted November 5, 2019 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) Quote
pkenewell Posted November 6, 2019 Posted November 6, 2019 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. Quote
Dj_T_Rex2002 Posted November 6, 2019 Author Posted November 6, 2019 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!! Quote
BIGAL Posted November 7, 2019 Posted November 7, 2019 (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 November 7, 2019 by BIGAL 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.