Author Topic: Add Mirror Option  (Read 5495 times)

0 Members and 1 Guest are viewing this topic.

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #15 on: October 26, 2010, 08:01:13 PM »
I am not getting the desired function from the code below. This is not the 'block' method.
I though acet-ss-drag-move honored initget settings so I tried to add a flip keyword and have that flip my selection set, but I am not getting it. Help please  :cry:

Code: [Select]
(defun c:cShape (/ dynPT Thick Wide sWide Tall sTall tPT InsPT PT1 PT2 PT3 PT4 PT5 PT6 PT7 ss)
(defun DTR (A) (* pi (/ A 180.0)))
(setvar "CMDECHO" 0)
(setvar "OSMODE" 0)
(setq Thick 0.5
Wide (getint "\nEnter C Shape Width in Inches: ")
sWide (- Wide Thick)
Tall (getint "\nEnter C Shape Height in Inches: ")
sTall (- Tall (* 2 Thick))
tPT (list 0. 10000. 0.)
PT1 (polar tPT (DTR 90) Tall)
PT2 (polar PT1 (DTR 0) Wide)
PT3 (polar PT2 (DTR 270) Thick)
PT4 (polar PT3 (DTR 180) sWide)
PT5 (polar PT4 (DTR 270) sTall)
PT6 (polar PT5 (DTR 0) sWide)
PT7 (polar PT6 (DTR 270) Thick)
)
(vl-cmdf "pline" tPT PT1 PT2 PT3 PT4 PT5 PT6 PT7 tPT "")
(setvar "OSMODE" saOSM)
(setq ss (ssadd))
(ssadd (entlast) ss)
(initget 2 "Flip")
(setq InsPT (acet-ss-drag-move ss tPT "\nSelect base point <Flip>: " ))
(if (= InsPT "Flip")
((vl-cmdf "_mirror" ss "" tPT PT1 "Y")(setq InsPT (acet-ss-drag-move ss tPT "\nSelect base point: " ))(vl-cmdf "_.Move" ss "" tPT InsPT))
(vl-cmdf "_.Move" ss "" tPT InsPT)
)
(princ)
)

*Edited by Oak3s 10.26.10

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Add Mirror Option
« Reply #16 on: October 26, 2010, 08:13:31 PM »
I'm with ronjonp on this a dynamic Block with a FLIP option built in would be a good thing.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #17 on: October 26, 2010, 08:28:40 PM »
 :lol: Either way would be fine with me as long as the flip option can occur before placement. How to accomplish such a thing is where my problem is.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Add Mirror Option
« Reply #18 on: October 26, 2010, 10:53:54 PM »
:lol: Either way would be fine with me as long as the flip option can occur before placement. How to accomplish such a thing is where my problem is.

Is this an extension from this post?

http://www.theswamp.org/index.php?topic=34714.msg399534#msg399534

There is your placement sans the snaps  :-P

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #19 on: October 28, 2010, 01:44:24 PM »
Not exactly but in the example you posted you show the type of effect I am looking for...except grread kills the osnaps I need. What I learned from that thread was acet-ss-drag-move. Now only if I can get a 'flip' option.

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #20 on: October 29, 2010, 04:46:11 PM »
No new ideas? Bummer  :oops:

I was thinking that if acet-ss-drag-move got something other than a point it would in a sense cancel the move. The idea seems good to me. I just dont know how to write the code for it.

Code: [Select]
(initget 2 "Flip")
(setq InsPT (acet-ss-drag-move ss tPT "\nSelect base point <Flip>: " ))
(if (= InsPT "Flip")
((vl-cmdf "_mirror" ss "" tPT PT1 "Y")(setq InsPT (acet-ss-drag-move ss tPT "\nSelect base point: " ))(vl-cmdf "_.Move" ss "" tPT InsPT))
(vl-cmdf "_.Move" ss "" tPT InsPT)
)

This is a snip from the code. The idea is to 'preview' the move with acet-ss-drag-move but if flip is activated cancel the drag-move - mirror the ss - start the drag-move again but with a 'flipped' preview. Is this though process doable?

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Add Mirror Option
« Reply #21 on: October 29, 2010, 07:06:30 PM »
Do you have a sample drawing? I'm having a hard time thinking about this order of input when you have so many other tools at your advantage.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add Mirror Option
« Reply #22 on: October 30, 2010, 10:12:48 AM »
You need to use (initget 128 )  for your option to work.
I added a Flip option to this routine for you to try. Did not do much error checking.
Code: [Select]
;;; MOCOROSC.lsp
;;;   Move, Copy, Rotate, Scale the selection set.
;;;
;;;   This routine makes use of the express tools routines acet-ss-drag-move,
;;;   acet-ss-drag-rotate, acet-ss-drag-scale, found in "acetutil.arx" and
;;;   assumes it has been loaded with (arxload "acetutil").
;;;   Parameters passed to this routine are the selection set of objects and
;;;   a base point. Nothing is returned by this routine.
;;;
(defun mocorosc (ss p1 / na p2 n d p lst j p3)
  (setq p2 t)
  (setq n 0)
  ;;  *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  ;;                   Main Loop                   
  ;;  *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  (while p2
    (setq na (entlast))
    (if (not lst)
      (setq lst (list (list ss p1)))
    ) ;if
    (setvar "lastpoint" p1)
    (acet-ss-redraw ss 3)
    (initget 128 "Rotate Scale Base Undo eXit")
    (setq p2 (acet-ss-drag-move
               ss
               p1
               "\nSecond point or \n[Rotate/Scale/Base/Flip/Undo] <exit>: "
               nil
             ) ;acet-ss-drag-move
    ) ;setq
    (acet-ss-redraw ss 4)
    ;;  if p2 is a point a copy is made
    (if (= p2 "eXit")
      (setq p2 nil)
    ) ;if
    (cond
      ((= p2 "Undo")
       (if (= n 0)
         (princ "\nNothing to undo.")
         (progn
           (command "_.undo" "1")
           (setq n   (- n 1)
                 lst (cdr lst)
                 ss  (car lst)
                 p1  (cadr ss)
                 ss  (car ss)
           ) ;setq
         ) ;progn else
       ) ;if
      ) ;cond #1
      ;;===================   SCALE  ======================
      ((= p2 "Scale")
       (initget 128 "Rotate Scale Base Undo eXit")
       (setq p2 (acet-ss-drag-scale
                  ss
                  p1
                  "\nSecond point or \n[Rotate/Scale/Base/Undo] <exit>: "
                  nil
                ) ;acet-ss-drag-move
       ) ;setq
       (if (and (= (type p2) 'real) (/= p2 0))
         (progn
           (command "_.scale" ss "" p1 p2)
           (setq n   (+ n 1)
                 lst (cons (list ss p1) lst)
           ) ;setq
         )
       )
      ) ;cond #2

      ;;===================   COPY  ======================
      ((equal 'list (type p2))
       (command "_.copy" ss "" p1 p2)
       (setq n   (+ n 1)
             ss  (acet-ss-new na)
             p1  p2
             lst (cons (list ss p1) lst)
       ) ;setq
      ) ;cond #3

      ;;===================   ROTATE  ======================
      ((= p2 "Rotate")
       (initget 128 "Rotate Scale Base Undo eXit")
       (setq p2 (acet-ss-drag-rotate
                  ss
                  p1
                  "\nSecond point or \n[Rotate/Scale/Base/Undo] <exit>: "
                  nil
                ) ;acet-ss-drag-move
       ) ;setq
       (if (= (type p2) 'real)
         (progn
           (command "_.rotate" ss "" p1 (* 180.0 (/ p2 pi)))
           (setq n   (+ n 1)
                 lst (cons (list ss p1) lst)
           ) ;setq
         )
       )
      ) ;cond #4

      ;;===================   BASE  ======================
      ((= p2 "Base")
       (setq p (getpoint "\nPick a new Base Point."))
       (if (and p (= (type p) 'list))
         (setq p1  p
               n   (+ n 1)
               lst (cons (list ss p1) lst)
         )
       )
      ) ;cond #5

      ;;===================   FLIP  ======================
      ((member p2 '("f" "F"))
       (command "_.mirror" ss "" "non" p1 "non" (polar p1 (/ pi 2) 10) "Y")
       )
     
      ;;===================   ERROR  ======================
      (p2
       (princ "\nInvalid input.")
      ) ;cond #6

    ) ;cond close
  ) ;while
  ;;  *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

) ;defun

(defun c:test (/ ss p)
  (prompt "\nSelect objects:")
  (if (and (setq ss (ssget))
           (setq p (getpoint "\Pick base point:"))
      )
    (mocorosc ss p)
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Oak3s

  • Guest
Re: Add Mirror Option
« Reply #23 on: November 02, 2010, 01:49:40 PM »
Thats CAB. I did a quick test of what you posted and it looks like it does exactly what I am looking for. I may post again on this topic once I get some time to dig into the code again. I am kinda busy at the moment.

Thank you again.