Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Rotate Command with a sinlge command

I'm trying to get a single key to register a rotate command, so far this is where I've gotten:

Under CUI
Create new shortcut
Command: ^C^C_ROTATE ; @ 90

I'm using F9 as a shortcut key, this works fairly well but the rotation point seems randomly placed so the object (lines, text, etc) doesn't rotate on itself. Any thoughts or adjustments to the command line?

Comments

  • With '@' you are using the last point that was selected as the rotation point. I am not sure what you mean by 'rotate on itself', but perhaps something like this?:
    [code]^c^c^p(command "_rotate" (ssget) "" "_non" (mapcar '* '(0.5 0.5 0.5) (apply 'mapcar (cons '+ (vle-getboundingbox (ssget "_P"))))) 90.0)(princ)^p[/code]
    Note: this is a single line of code.
  • Roy,

    When I use your provided command the object goes far out of the viewable area.  By "rotate on itself" I mean the center point of the object, it would pinwheel on the middle of itself.
  • Alternative version using acet-geom-mid-point:
    [code]^c^c^p(command "_rotate" (ssget) "" "_non" (apply 'acet-geom-mid-point (vle-getboundingbox (ssget "_P"))) 90.0)(princ)^p[/code]
  • @ David:
    Well my code does use the geometric center of the object (as determined by its bounding box). In my tests it works as expected. Try testing with a 'simple' object such as a line.
  • With this command the rotated objects move 36,000 ft away from the start point.
  • FWIW both of Roy's examples work for me. Like Roy said, I would try on some simple entities first. Also use a new drawing based on one of the default templates. Perhaps on your current drawing you are not on the WCS?  vle-getgeomextents returns WCS points.

    Regards,
    Jason Bourhill

  • Updated Roy's example to take UCS into account

    [code]^c^c^p(command "_rotate" (ssget) "" "_non" (apply 'acet-geom-mid-point (mapcar '(lambda (pt) (trans pt 0 1)) (vle-getboundingbox (ssget "_P")))) 90.0)(princ)^p[/code]

    Same code as command
    [code](defun C:R90 ()
        (command "_rotate" (ssget) "" "_non" (apply 'acet-geom-mid-point (mapcar '(lambda (pt) (trans pt 0 1)) (vle-getboundingbox (ssget "_P")))) 90.0)
        (princ)
    )[/code]

    @Roy nice example of use for vle-getboundingbox

    Regards,
    Jason Bourhill

  • Jason analysis is correct. I forgot to add (trans).
    [code]^c^c^p(command "_rotate" (ssget) "" "_non" (trans (apply 'acet-geom-mid-point (vle-getboundingbox (ssget "_P"))) 0 1) 90.0)(princ)^p[/code]

  • Thanks all, the UCS change seems to have done it.
This discussion has been closed.
Origami
Origami is the Japanese word for paper folding. ORI means to fold and KAMI means paper and involves the creation of paper forms usually entirely by folding.

Powered by VanillaForums, Designed by Steam