Jump to content

FLIP SELECT MULTI BLOCK


LITOKARDO_BC

Recommended Posts

 

Good day, I need help please. I got this autolisp, but it only works for a single block. I don't have the knowledge to adapt it and select multiple blocks. thank you very much for your attention.

; Flip block example - with (grread)
(defun C:fb1 ( / e enx g s k itm )
 (and
   (setq e (car (entsel "\nPick a block to flip: "))) 
   (member '(0 . "INSERT") (setq enx (entget e)))
   (princ "\nPress [X/Y/Z] to flip the block <exit>: ")
   (while (not s) (setq g (grread)) 
     (cond 
       ( (or (eq g '(2 13)) (= 25 (car g))) (setq s T) )
       ( (= 2 (car g)) 
         (and
           (setq k (cadr (assoc (strcase (chr (cadr g))) '(("X" 41)("Y" 42)("Z" 43)))))
           (setq itm (assoc k enx))
           (entmod (setq enx (subst (cons k (- (cdr itm))) itm enx)))
         )
       )
     ); cond
   ); while
 ); and
 (princ)
); defun C:test

 

Link to comment
Share on other sites

If your happy to pick pick then change the entsel  by adding a while. Not sure but nothing happened when I ran the code, picked block xyz message came up and nothing after that.

 

(while (setq e (car (entsel "\nPick a block to flip: ")))

Link to comment
Share on other sites

I isolated the user input (selecting multiple blocks, then typing X,Y or Z) from the rest of the function.

 

I removed the while loop.  You can always run the function twice or three times if you wish.

X,Y or Z is for all the selected blocks now

 

; Flip block example - with (grread)
(defun fb1 (e g /  enx  s k itm )
  (and
    (setq enx (entget e))
    (cond
        ( (or (eq g '(2 13)) (= 25 (car g))) (setq s T) )
        ( (= 2 (car g))
          (and
            (setq k (cadr (assoc (strcase (chr (cadr g))) '(("X" 41)("Y" 42)("Z" 43)))))
            (setq itm (assoc k enx))
            (entmod (setq enx (subst (cons k (- (cdr itm))) itm enx)))
          )
        )
    ); cond
  ); and

)

(defun C:fb1 ( / e i ss g)
  (princ "\nSelect blocks to flip: ")
  (setq ss (ssget (list (cons 0 "INSERT") )))
  (princ "\nPress [X/Y/Z] to flip the block <exit>: ")
  (setq g (grread))
  (setq i 0)
  (repeat (sslength ss)
    (setq e (ssname ss i))
    (fb1 e g)
    (setq i (+ i 1))
  )
  (princ)  
)

Edited by Emmanuel Delay
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...