Lisp routine help!!!

Discussion in 'AutoCAD' started by kyeric, Feb 21, 2005.

  1. kyeric

    kyeric Guest

    Hello all,
    I was wondering if there was a routine or a macro that could be written to rotate an object/block 45 degrees from its base point with one click?

    I would like to use that command in conjunction with another that mirrors an object instantly in the horizontal direction and deletes the original and another that mirrors and deletes in the vertical. These commands would be helpful in saving a couple of keystrokes for me...

    I hope this is possible! Thanks for any help or advice.

    -Eric
     
    kyeric, Feb 21, 2005
    #1
  2. Hi Eric,

    It is easily possible.

    Do a web search and it is quite likely you will find a program to do this,
    or one which is that close to what you want, that you can modify it.

    --

    Regards,


    Laurie Comerford
    www.cadapps.com.au
     
    Laurie Comerford, Feb 21, 2005
    #2
  3. kyeric

    Adesu Guest

    Hi kyeric,try this

    (defun c:ro (/ p1 p2 ss ssn ang opt)
    ;(setq p1 (getpoint "\nCLICK FIRST CORNER: ")) ; use it if you want by
    window
    ;(setq p2 (getcorner p1 "\nCLICK SECOND CORNER: "))
    (setq ss (ssget))
    ;(setq ss (ssget "w" p1 p2))
    (setq ssn (ssname ss 0))
    (redraw ssn 3)
    (setq ang 45)
    (setq opt (getpoint "\nENTER AS BASE POINT: "))
    (command "_rotate" ssn "" opt ang "")
    (princ)
    )

    rotate an object/block 45 degrees from its base point with one click?
    an object instantly in the horizontal direction and deletes the original
    and another that mirrors and deletes in the vertical. These commands would
    be helpful in saving a couple of keystrokes for me...
     
    Adesu, Feb 22, 2005
    #3
  4. Do you really mean ONLY block objects? (The term "object/block" is
    unclear.) That would be easy with (assoc 10), the insertion point from the
    association list. That could also work for text-type objects, which also
    have a "base point". Many kinds don't (well, circles do, but there' not
    much point in rotating a circle), and for some that do, there are problems
    (e.g. you can't tell by looking at text what it's justification is,
    therefore where its insertion point is). Other things have an (assoc 10),
    but for example in a line, it's one of the end points, and you wouldn't be
    able to foretell which one on-screen. A hatch pattern can have many of
    them.

    If you want to do other kinds of objects than blocks, do you mean to use the
    pick point as the rotation base point? I can't picture any other way to do
    it with one pick.
     
    Kent Cooper, AIA, Feb 22, 2005
    #4
  5. kyeric

    kyeric Guest

    Kent,
    Let me clarify a little bit. I do want to rotate 45 degrees and also mirror more than just blocks. I thought that the lisp could do this by taking whatever selection I picked, chose a base point on the selection, or selections (midpoint of the two?) and flip them vertically or horizontally automatically. The base point could be arbitrary, I don't really care, as long as the selection gets flipped or rotated 45 degrees with a fewer mouse clicks.

    Maybe even the lisp could stay active as to keep rotating objects another 45 degrees until the user escapes out of the command. Same with the flip (mirror) command, just keeps flipping the object back and forth? I apologize for my lack of understanding, I just thought that these commands could help out users like me who don't want to have to use the keyboard any more than you have to.

    Thanks again for everyone's help and suggestions!

    Sincerely,
    Eric
     
    kyeric, Feb 22, 2005
    #5
  6. An "arbitrary" base point or mirror line location could be pretty difficult,
    especially if the number of selections isn't always the same. If it's
    always two, it's easy to find halfway between them, and if it's always one,
    it's easy to use that point. But if it's three, or four, or.... I'm having
    a hard time figuring out how you would determine a middlish point if you
    don't know the number of points you're going to figure from ahead of time.
    Computers are fast, but really dumb, and need to be told exactly what to
    do -- they can't do "oh, anywhere around here", but need to be told
    something specific, so you need some way to come up with that. Maybe make a
    temporary region from the points, which you can find the centroid of?

    [Would you be zoomed in close enough when you do this that the center of the
    screen could be used? (getvar "VIEWCTR")]

    Or, do what someone else (Ade? -- I didn't keep the earlier messages)
    suggested, and build in a prompt for user input for the base point. It's an
    "extra step", but a lot easier than accounting for all possibilities to
    calculate a point.

    You can make it repeat until you cancel out, by doing it as a menu-pick item
    (without "defun") starting with *^C^C, though for some reason I've had
    trouble in recent releases with those, if the routine saves a point for
    reuse later -- it seems that kind of routine that worked for us up through
    R14 has not worked in A2000 or A2004. If it's defun'd and loaded, you can
    use MULTIPLE before it for that.
     
    Kent Cooper, AIA, Feb 22, 2005
    #6
  7. You can also do what you're looking for without any routine or command at
    all, and even using the same approach for both rotating and mirroring, using
    grips and selecting entities with no command active. Select whatever you
    want, latch on to one of the grips on any of the entities (which will give
    you several choices within the "arbitrary" area of the selected entities),
    and whap the space bar a few times, until the prompt line gets around to
    Rotate or Mirror, depending on which you're after. With Polar turned on and
    set appropriately, you're there. It could even save you steps, if your
    reason for wanting it to "stay active" is that you might want to rotate
    something through more than one 45-degree turn. You can do it however far
    you want the first time with the grips-and-polar approach. (This kind of
    thing is just what grips are for.)
     
    Kent Cooper, AIA, Feb 24, 2005
    #7
  8. kyeric

    kyeric Guest

    Kent,
    *WACK* (Sound of hand slapping forehead)...

    You are a lifesaver, man. Thanks for your suggestions and help. I appreciate it!

    Sincerely,
    Eric
     
    kyeric, Feb 24, 2005
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.