Need help to create custom shortcut command.

Need help to create custom shortcut command.

Anonymous
Not applicable
840 Views
3 Replies
Message 1 of 4

Need help to create custom shortcut command.

Anonymous
Not applicable

I don't know how to create a combination of keys, for example(shift+F8), to rotate an object in 15degrees,30degrees,45degrees,60degrees,.....360degrees, every time when I press shift+F8 on a selected object, is this clear? I mean when I select an object an press for the first time shift+F8 the program ask me for a base point then shift+F8 again rotate 15, again 30,again 45....and so on.
How to write a macro for that? I have no idea!!

thanks Vladimir

 

0 Likes
841 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant

Try this... 

 

Spoiler
(defun c:R15+ (/ ss pt)

  (if (setq ss (cond ((ssget "_I"))
		     ((and *r15*last*
			   (> 0.0001 (- (getvar 'CDATE) (car *r15*last*)))
			   (cadr *r15*last*))
		      (setq pt (last *r15*last*))
		      (cadr *r15*last*))
		     ((ssget))))
    (progn
      (or pt
	  (setq pt (getpoint "\nReference point: ")))
      (command "_.ROTATE" ss "" "_none" pt +15)
      (setq *r15*last* (list (getvar 'CDATE) ss pt))))
  (princ)
)

It's a lisp, so use _APPLOAD and add this in the suitcase. Then go to _CUI, create new command with ^C^CR15+ macro.

 

First time you run this it asks for a point.

If the second time you run this follows in less than 1 minute, it takes the previous selection and the point.

If you need to run another selection in less than 1 minute, then use pre-selection a you will asked for a point.

 

If you want to make this lisp for rotation in another direction, copy paste the code a change red + to -.

 

 

EDIT:

Or maybe I wasn't paying enough attention, then try this version.

 

Spoiler
(defun c:R15 (/ ss pt)

  (if (setq ss (ssget))
    (progn
      (if (and *r15*lastpt*
	       (> 0.0001 (- (getvar 'CDATE) (car *r15*lastpt*)))
	       )
	(setq pt (cadr *r15*lastpt*)
	      ro (last *r15*lastpt*)))
      (or pt
	  (setq pt (getpoint "\nReference point: ")))
      (setq ro (if ro
		 (+ 15 ro)
		 15))
      (command "_.ROTATE" ss "" "_none" pt ro)
      (setq *r15*lastpt* (list (getvar 'CDATE) pt ro))))
  (princ)
)

 

0 Likes
Message 3 of 4

Anonymous
Not applicable

thanks, but this not help me too much, because I'm "analphabet" in LISP and macros,I think the simple way to do that is write a small MACRO and assign to a new shortcut keys (shift+F8), How the macro will look alike? and how to assign to a combination of keys?

thanks

0 Likes
Message 4 of 4

ВeekeeCZ
Consultant
Consultant

Read my previous post, there are some hints. Or maybe not enough, then use this LINK

Or this LINK about how to use a LISP.

 

Good luck though!

 

 

0 Likes