• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Member
    Posts: 4
    Registered: ‎06-15-2012

    TAB angle lock

    251 Views, 5 Replies
    06-15-2012 02:10 PM

    Hi guys I want to create a shortcut key (like TAB) for example and whenever I start a polyline or move or whatever, I can hit TAB which will grab the angle my cursor is at, and then use the angle lock to lock the cmd into that direction. (This is essentially what can be done in rhino if you are familiar with this). 

     

    The manual way in autocad is typing it ("<45") but I just want to calculate angle from the start point to cursor point. and then once hitting tab or a key or a new command, it will lock with that angle. How can I go about programming this, I have never programmed in autocad but am eager in learning how this might be possible. Thanks so much!

     

    Please use plain text.
    *Pro
    scot-65
    Posts: 1,932
    Registered: ‎12-11-2003

    Re: TAB angle lock

    06-15-2012 03:38 PM in reply to: cjm771

    Look at the available transparent commands - the ones with the 'hyphens in front

    as well as assigning the "F-Keys".

     

    If not mistaken, you will need to set up UCS names, but I do not know if UCS is a

    transparent command.

     

    Would you consider reversing the order?

    Meaning rotate the UCS first, then start the command?

    I know that can be done.

     

    Attached image is a screen capture showing how to assign a F-key.

    You might need to define a command name first (not sure) or write

    the macro: ucs;[your ucs name];...

     

    Command CUI will get you there.

    Drag and drop the command from the lower-left pane into the tree above.

    Highlight the line you just created in the tree and edit in the lower-right pane.

     

    ???

    Please use plain text.
    *Expert Elite*
    Posts: 2,128
    Registered: ‎11-24-2009

    Re: TAB angle lock

    06-15-2012 11:03 PM in reply to: cjm771

    What about Polar Tracking or F10

    At Polar Angle Settings

    -Increment angle 45

     

    HTH

     

    Please use plain text.
    *Expert Elite*
    Kent1Cooper
    Posts: 4,159
    Registered: ‎09-13-2004

    Re: TAB angle lock

    06-16-2012 04:17 AM in reply to: cjm771

    cjm771 wrote:

    Hi guys I want to create a shortcut key (like TAB) for example and whenever I start a polyline or move or whatever, I can hit TAB which will grab the angle my cursor is at, and then use the angle lock to lock the cmd into that direction. (This is essentially what can be done in rhino if you are familiar with this). 

     

    The manual way in autocad is typing it ("<45") but I just want to calculate angle from the start point to cursor point. and then once hitting tab or a key or a new command, it will lock with that angle. How can I go about programming this, I have never programmed in autocad but am eager in learning how this might be possible. Thanks so much!

     


    This does it if you type (sca) [including the parentheses] when a prompt is asking for a next point, such as in Line or Move or Copy.  I leave it to you to assign (sca) to a Function key or Alt-whatever or other key combination.

     

    (defun sca (); = Snap to Crosshair-location Angle
      (setvar 'snapang
        (angle
          (getvar 'lastpoint)
          (cadr (grread T))
        )
      )
      (setvar 'orthomode 1)
      (princ)
    )

    Kent Cooper
    Please use plain text.
    Member
    Posts: 4
    Registered: ‎06-15-2012

    Re: TAB angle lock

    06-17-2012 04:12 PM in reply to: cjm771

    Thanks kent!

     

    Works great!! Only two questions

     

    1) is it possible that upon completion of the next click (if it is a polyline or the end of a move command or whatever..) can it return to the normal non ortho mode? It seems it gets stuck in ortho at that angle forever.that would be awesome!

     

    2) It is posisble that once in this sca mode...that even if i osnap to a point...that it will still conform to the angle and esentially project (like an strack situation) to keep with that angle? 

     

    Also  what is a good documentation to learn this AutoLISP, I very much would like to learn! Thanks, again!

    Please use plain text.
    Valued Mentor
    Posts: 362
    Registered: ‎06-02-2005

    Re: TAB angle lock

    06-18-2012 02:54 AM in reply to: cjm771

    Hi,

    adapting Kent's suggestion you could assign the macro

    ^P(strcat "<" (angtos (angle (getvar 'lastpoint) (cadr (grread T))))) ^P

    to a function key or other shortcut key combination,

    This will handle your 1st request.

    For your 2nd request, you could try turning on osnap tracking

    with the F11 key before or after using the above macro.

    Ian


     

    Please use plain text.