Results 1 to 10 of 10

Thread: Request A "Click & Flip" Routine

  1. #1
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Request A "Click & Flip" Routine

    Hi ALL,

    Can anyone let me know if there is a routine which performs the click & flip function at the FORUMS?

    Please see the attached sketch for more details.

    Any help would be greatly appreciated.
    Attached Files Attached Files
    Last edited by BoKirra; 2008-04-21 at 04:57 AM.

  2. #2
    Login to Give a bone
    0

    Smile Re: Request A "Click & Flip" Routine

    I couldn’t get the magic wand to work, but this ought to do the trick.
    Terry

    Code:
    (defun c:CF (/ Dxf41 Dxf50 EntList@ EntName^)
      (princ "\nSelect block to Click and Flip")
      (if (setq EntName^ (car (entsel)))
        (if (= (cdr (assoc 0 (entget EntName^))) "INSERT")
          (progn
            (setq EntList@ (entget EntName^))
            (setq Dxf41 (* -1 (cdr (assoc 41 EntList@))))
            (setq Dxf50 (+ pi (cdr (assoc 50 EntList@))))
            (setq EntList@ (entmod (subst (cons 41 Dxf41) (assoc 41 EntList@) EntList@)))
            (setq EntList@ (entmod (subst (cons 50 Dxf50) (assoc 50 EntList@) EntList@)))
            (entupd EntName^)
          );progn
        );if
      );if
      (princ)
    );defun c:CF
    Here's a version that works better on blocks with attributes.
    Code:
    (defun c:MB (/ Ang~ EntList@ EntName^ P1 P2)
      (princ "\nSelect block to mirror.")
      (if (setq EntName^ (car (entsel)))
        (if (= (cdr (assoc 0 (entget EntName^))) "INSERT")
          (progn
            (setq EntList@ (entget EntName^))
            (setq P1 (cdr (assoc 10 EntList@)))
            (setq Ang~ (cdr (assoc 50 EntList@)))
            (setq P2 (polar P1 Ang~ 1))
            (command "MIRROR" EntName^ "" P1 P2 "Y")
          );progn
        );if
      );if
      (princ)
    );defun c:MB
    Last edited by Terry Cadd; 2008-04-15 at 09:31 PM. Reason: Added c:MB mirror block function

  3. #3
    All AUGI, all the time BCrouse's Avatar
    Join Date
    2003-04
    Location
    Bethlehem, PA
    Posts
    980
    Login to Give a bone
    0

    Default Re: Request A "Click & Flip" Routine

    The MB Lisp is awesome. If you could get text in a block to mirror correctly, you would have a home run.

  4. #4
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: Request A "Click & Flip" Routine

    Quote Originally Posted by Terry Cadd View Post
    I couldn’t get the magic wand to work, but this ought to do the trick.
    Terry
    Hi Terry,

    Thanks for your help. Your codes look cool.

    BUT I want a "Click & Flip" function to be added to a routine flipping a pline entity, instead of a block.

    The following is a simplified routine.

    With the "Click & Flip" function, it should have a procedure like:

    Load Semicircle.lsp then Drawing A Semicircle Facing RIGHT
    (1) Select an insert point on the drawing;
    (2) Then click RIGHT SIDE anywhere of the insert point;
    (3) Finally the routine draws a semicircle facing RIGHT.

    or Drawing A Semicircle Facing LEFT
    (1) Select an insert point on the drawing;
    (2) Then click LEFT SIDE anywhere of the insert point;
    (3) Finally the routine draws a semicircle facing LEFT.

    Code:
    ;;;;;Semicircle.lsp
    (defun DEG (A)
                  (* pi (/ A 180.0))
    ) 
    
    (defun C:CF (/ IPoint Point1 Point2)
    
      (setq IPoint (getpoint "\nSelect Insert Point: "))
    
      (setq Point1 (polar IPoint (DEG 90) 100)
              Point2 (polar Point1 (DEG 180) 50))
    
      (command "pline" IPoint Point1 "arc" "d" Point2 IPoint "")
    
      (princ)
    
      )
    Thanks.
    Last edited by BoKirra; 2008-04-18 at 12:46 AM.

  5. #5
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Request A "Click & Flip" Routine

    Have you tried Dynamic Blocks with a Flip Parameter? Then you can specify which entities inside the block flips - also if you now have text flipping - it stays written in the correct direction. Instead of like the mirror command which only mirrors attributes correctly, not text contained in blocks.

    There's a filpside to the coin though (excuse the pun). DB Filp parameter doesn't then work with normal attributes. You have to Lock Position of these attributes if you want to flip them. Otherwise their actual position is not directly defined by the block - but they're seen as separate entities instead.

  6. #6
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: Request A "Click & Flip" Routine

    Sorry, I haven't give you more info:

    1) I am still living in the past - using an older version of AutoCAD 2005. I can't create any Dynamic Blocks.
    2) I need this function to my routine for a pline entity only, NOT a block.


    Quote Originally Posted by irneb View Post
    Have you tried Dynamic Blocks with a Flip Parameter? Then you can specify which entities inside the block flips - also if you now have text flipping - it stays written in the correct direction. Instead of like the mirror command which only mirrors attributes correctly, not text contained in blocks.

    There's a filpside to the coin though (excuse the pun). DB Filp parameter doesn't then work with normal attributes. You have to Lock Position of these attributes if you want to flip them. Otherwise their actual position is not directly defined by the block - but they're seen as separate entities instead.

  7. #7
    Login to Give a bone
    0

    Default Re: Request A "Click & Flip" Routine

    Still no magic, but try this.

    Code:
    ;Semicircle2.lsp
    (defun c:CF2 (/ InsPt Pt1 Pt2 SideAng SidePt)
      (if (setq InsPt (getpoint "\nSelect Insertion Point: "))
        (setq SidePt (getpoint "\nSelect side for arc: "))
      );if
      (if (and InsPt SidePt)
        (progn
          (setq SideAng (angle InsPt SidePt))
          (if (and (>= SideAng (deg 90))(<= SideAng (deg 270)))
            (setq Pt1 (polar InsPt (deg 90) 100)
                  Pt2 (polar Pt1 (deg 180) 50)
            );setq
            (setq Pt1 (polar InsPt (deg 90) 100)
                  Pt2 (polar Pt1 0 50)
            );setq
          );if
          (command "pline" InsPt Pt1 "arc" "d" Pt2 InsPt "")
        );progn
      );if
      (princ)
    );defun
    (defun deg (D)
     (* pi (/ D 180.0))
    );defun
    You might want to also consider if the user wants to insert the arc at a different angle besides 90 degrees.
    Last edited by Terry Cadd; 2008-04-18 at 12:13 AM. Reason: Added comment.

  8. #8
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: Request A "Click & Flip" Routine

    Thanks, Terry

    With your code I have to create two sets of drawing set points.
    (shown in the following lines in your code.)

    Is it possible to keep one set of the drawing set points so I can reduce the size of lisp file and also save time on the programming.

    It would be good if the object is complicated (not as simple as the semicircle).

    Quote Originally Posted by Terry Cadd View Post
    Still no magic, but try this.

    Code:
    ;Semicircle2.lsp
    ...
          (if (and (>= SideAng (deg 90))(<= SideAng (deg 270)))
            (setq Pt1 (polar InsPt (deg 90) 100)
                  Pt2 (polar Pt1 (deg 180) 50)
            );setq
            (setq Pt1 (polar InsPt (deg 90) 100)
                  Pt2 (polar Pt1 0 50)
            );setq
          );if
          (command "pline" InsPt Pt1 "arc" "d" Pt2 InsPt "")
    ...
    And it is a good point.
    You might want to also consider if the user wants to insert the arc at a different angle besides 90 degrees.

  9. #9
    Login to Give a bone
    0

    Default Re: Request A "Click & Flip" Routine

    Yes, you can condense it shorter as in c:CF3. Also look into c:CF4 regarding other possible user choices. You can make the objects as complicated as you need to.

    Code:
    ;Semicircle3.lsp
    (defun c:CF3 (/ Ang InsPt Pt1 Pt2 SideAng SidePt)
      (if (setq InsPt (getpoint "\nSelect Insertion Point: "))
        (setq SidePt (getpoint "\nSelect side for arc: "))
      );if
      (if (and InsPt SidePt)
        (progn
          (setq SideAng (angle InsPt SidePt))
          (if (and (>= SideAng (deg 90))(<= SideAng (deg 270)))
            (setq Ang (deg 180))
            (setq Ang 0)
          );if
          (setq Pt1 (polar InsPt (deg 90) 100)
                Pt2 (polar Pt1 Ang 50)
          );setq
          (command "pline" InsPt Pt1 "arc" "d" Pt2 InsPt "")
        );progn
      );if
      (princ)
    );defun
    (defun c:CF4 (/ Ang1 Ang2 InsPt Pt1 Pt2 SideAng SidePt)
      (if (setq InsPt (getpoint "\nSelect Insertion Point: "))
        (setq SidePt (getpoint "\nSelect side for arc: "))
      );if
      (if (and InsPt SidePt)
        (progn
          (setq SideAng (angle InsPt SidePt))
          (cond
            ((< SideAng (deg 45))(setq Ang1 0 Ang2 (deg 90)))
            ((< SideAng (deg 90))(setq Ang1 (deg 90) Ang2 0))
            ((< SideAng (deg 135))(setq Ang1 (deg 90) Ang2 (deg 180)))
            ((< SideAng (deg 180))(setq Ang1 (deg 180) Ang2 (deg 90)))
            ((< SideAng (deg 225))(setq Ang1 (deg 180) Ang2 (deg 270)))
            ((< SideAng (deg 270))(setq Ang1 (deg 270) Ang2 (deg 180)))
            ((< SideAng (deg 315))(setq Ang1 (deg 270) Ang2 0))
            ((< SideAng (deg 360))(setq Ang1 0 Ang2 (deg 270)))
          );cond
          (setq Pt1 (polar InsPt Ang1 100)
                Pt2 (polar Pt1 Ang2 50)
          );setq
          (command "pline" InsPt Pt1 "arc" "d" Pt2 InsPt "")
        );progn
      );if
      (princ)
    );defun
    (defun deg (D)
     (* pi (/ D 180.0))
    );defun

  10. #10
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: Request A "Click & Flip" Routine

    Terry,

    Thank you very much.

    On the line of "Pt2" below, I can't see c:CF3 allows me having a single set of set points.
    If the initial Pt2 was NOT set to 0 degree, for example, Pt2 was set to 25 degrees & Ang = 180 degrees, I then have to create another mirror set of set points.

    Any solution?


    Thanks, again.

    Quote Originally Posted by Terry Cadd View Post
    Code:
    ;Semicircle3.lsp
    (defun c:CF3 (/ Ang InsPt Pt1 Pt2 SideAng SidePt)
    ...
                Pt2 (polar Pt1 Ang 50)
    ...
    );defun
    c:CF4 is a good idia as it provides more abilities.
    Last edited by BoKirra; 2008-04-21 at 07:28 AM.

Similar Threads

  1. Lisp routine request: "Draw By Example"
    By matt.bachardy903119 in forum AutoLISP
    Replies: 9
    Last Post: 2016-06-27, 07:02 PM
  2. "Flip" Control in Family Editor 2010
    By Scott Womack in forum Revit Architecture - General
    Replies: 12
    Last Post: 2009-06-23, 09:36 AM
  3. Replies: 5
    Last Post: 2008-02-19, 11:33 PM
  4. Update the "Flip Arrow" Option
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2007-05-25, 05:21 PM
  5. Replies: 10
    Last Post: 2006-04-03, 03:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •