Visual LISP, AutoLISP and General Customization

Reply
Member
cjm771
Posts: 4
Registered: ‎06-15-2012
Message 1 of 6 (348 Views)

TAB angle lock

348 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!

 

*Expert Elite*
scot-65
Posts: 2,122
Registered: ‎12-11-2003
Message 2 of 6 (341 Views)

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.

 

???

Scot-65
Dyslexia is a permanent physical disability that cannot be seen.
*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 3 of 6 (327 Views)

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

 

*Expert Elite*
Kent1Cooper
Posts: 5,233
Registered: ‎09-13-2004
Message 4 of 6 (314 Views)

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
Member
cjm771
Posts: 4
Registered: ‎06-15-2012
Message 5 of 6 (267 Views)

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!

Valued Mentor
Ian_Bryant
Posts: 362
Registered: ‎06-02-2005
Message 6 of 6 (231 Views)

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


 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community