Author Topic: lastpoint on rotate  (Read 4357 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
lastpoint on rotate
« on: November 11, 2009, 09:28:10 AM »
Hi all..

any one have an idea on how to get the last point when we make ROTATE ?   :|
Keep smile...

efernal

  • Bull Frog
  • Posts: 206
Re: lastpoint on rotate
« Reply #1 on: November 11, 2009, 10:11:33 AM »
did you try
(getvar "LASTPOINT")
?

ef
e.fernal

Andrea

  • Water Moccasin
  • Posts: 2372
Re: lastpoint on rotate
« Reply #2 on: November 11, 2009, 10:20:48 AM »
did you try
(getvar "LASTPOINT")
?

ef

LASTPOINT return the rotation basepoint not the last one..

Keep smile...

efernal

  • Bull Frog
  • Posts: 206
Re: lastpoint on rotate
« Reply #3 on: November 11, 2009, 11:25:49 AM »
if the rotation angle is get by clicking another point, this one will be the last...

ef
e.fernal

Andrea

  • Water Moccasin
  • Posts: 2372
Re: lastpoint on rotate
« Reply #4 on: November 11, 2009, 12:09:13 PM »
if the rotation angle is get by clicking another point, this one will be the last...

ef



that what i've thougth...but
.....the LASTPOINT give me the basepoint of rotation
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lastpoint on rotate
« Reply #5 on: November 11, 2009, 02:15:46 PM »
Create your own Rotate command. :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: lastpoint on rotate
« Reply #6 on: November 11, 2009, 04:29:14 PM »
Create your own Rotate command. :)


 :?
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lastpoint on rotate
« Reply #7 on: November 11, 2009, 06:46:11 PM »
Try this, quick & dirty. 8-)
Code: [Select]
;;  CAB 11.11.09
;;  Simulate the rotate command
(defun Rotate (ss BasePoint / ip ObjList i ename ip grr
               ANG BPT LASTROT OBJANG ROT STARTANG)
  (defun GroupRotate (objects bpt ang)
    (setq bpt (vlax-3D-point bpt))
    (mapcar (function (lambda (x) (vla-rotate x bpt ang))) Objects)
  )

  (setq ObjAng 0.0
        rot 0.0
  )
  (setq StartAng ObjAng)      ; save angle before rotation begins
  (setq i -1)
  (while (setq ename (ssname ss (setq i (1+ i))))
    (setq ObjList (cons (vlax-ename->vla-object ename) ObjList))
  )

  (while (progn
           (redraw)
           (cond
             ((eq 3 (car (setq grr (grread T 15 0))))
              (setq ip (cadr grr))
              nil
             )

             ((and (eq 2 (car grr)) (eq 13 (cadr grr)))
              (GroupRotate ObjList BasePoint (- StartAng LastRot))
              (setq ip nil)
             )

             ((eq 5 (car grr)) ; point from mouse, update star
              (setq rot (angle BasePoint (trans (setq ip (cadr grr)) 1 0)))
                              ; pointer angle
              (GroupRotate ObjList BasePoint (- rot ObjAng))
              (setq ObjAng rot) ; update object current angle
              (and (>= ObjAng (* 2 pi)) (setq ObjAng (- ObjAng (* 2 pi))))
                              ; correct if >= 2pi
              (setq LastRot ObjAng)
              t
             )
           )
         )
  )
  ip
)

Code: [Select]
(defun c:MyRotate (/ ss bpt)
  (and
    (princ "\nSelect objects to rotate:")
    (setq ss (ssget))
    (setq bpt (getpoint "\nSpecify base point: "))
    (princ "\nSpecify rotation angle. ")
    (princ (rotate ss bpt))
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: lastpoint on rotate
« Reply #8 on: November 11, 2009, 07:38:28 PM »
Very cool Alan. I knew it was possible, I just wasn't sure what math to apply. I'll have to do a little studying. :)

Added reference line:
Code: [Select]
;;  CAB 11.11.09
;;  Simulate the rotate command
(defun Rotate (ss BasePoint / ip ObjList i ename ip grr
               ANG BPT LASTROT OBJANG ROT STARTANG)
  (defun GroupRotate (objects bpt ang)
    (setq bpt (vlax-3D-point bpt))
    (mapcar (function (lambda (x) (vla-rotate x bpt ang))) Objects)
  )

  (setq ObjAng 0.0
        rot 0.0
  )
  (setq StartAng ObjAng)      ; save angle before rotation begins
  (setq i -1)
  (while (setq ename (ssname ss (setq i (1+ i))))
    (setq ObjList (cons (vlax-ename->vla-object ename) ObjList))
  )

  (while (progn
           (cond
             ((eq 3 (car (setq grr (grread T 15 0))))
              (setq ip (cadr grr))
              nil
             )

             ((and (eq 2 (car grr)) (eq 13 (cadr grr)))
              (GroupRotate ObjList BasePoint (- StartAng LastRot))
              (setq ip nil)
             )

             ((eq 5 (car grr)) ; point from mouse, update star
              (setq rot (angle BasePoint (trans (setq ip (cadr grr)) 1 0)))
              (redraw)
              (grdraw BasePoint ip 7)
                              ; pointer angle
              (GroupRotate ObjList BasePoint (- rot ObjAng))
              (setq ObjAng rot) ; update object current angle
              (and (>= ObjAng (* 2 pi)) (setq ObjAng (- ObjAng (* 2 pi))))
                              ; correct if >= 2pi
              (setq LastRot ObjAng)
              t
             )
           )
         )
  )
  (redraw)
  ip
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lastpoint on rotate
« Reply #9 on: November 11, 2009, 08:51:35 PM »
Excellent, thanks.  :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lastpoint on rotate
« Reply #10 on: November 12, 2009, 12:14:34 AM »
Catches locked layers:
Code: [Select]
;;  CAB 11.12.09
;;  Simulate the rotate command
;;  ss may be a selection set or list of enames or vla objects
(defun Rotate (ss BasePoint / ip ObjList i ename ip grr rot layrs obj doc
              LastRot ObjAng)
  (defun GroupRotate (objects bpt ang)
    (setq bpt (vlax-3D-point bpt))
    (mapcar (function (lambda (x) (vla-rotate x bpt ang))) Objects)
  )
  (defun LayUnLocked (Obj layrs)
   (= :vlax-false (vla-get-Lock (vla-Item  layrs (vla-get-Layer Obj))))
  )
 
  (setq ObjAng 0.0
        rot    0.0
        doc    (vla-get-ActiveDocument (vlax-get-acad-object))
        Layrs  (vla-get-Layers doc)
  )
  (vla-endundomark doc)
  (vla-startundomark doc)
  (cond
    ((= (type ss) 'PICKSET)
      (setq i -1)
      (while (setq ename (ssname ss (setq i (1+ i))))
        (if (LayUnLocked (setq obj (vlax-ename->vla-object ename)) Layrs)
          (setq ObjList (cons obj ObjList))
        )
      ))
    ((= (type (car ss)) 'ENAME)
     (mapcar (function (lambda(x)
        (if (LayUnLocked (setq obj (vlax-ename->vla-object x)) Layrs)
          (setq ObjList (cons obj ObjList))
        )))
      ss)
    )
    (t
     (mapcar (function (lambda(x)
        (if (LayUnLocked x Layrs)
          (setq ObjList (cons x ObjList))
        )))
      ss)
    )
  )

  (while (progn
           
           (cond
             ((eq 3 (car (setq grr (grread T 15 0))))
              (setq ip (cadr grr))
              nil
             )

             ((and (eq 2 (car grr)) (eq 13 (cadr grr)))
              (GroupRotate ObjList BasePoint (- LastRot))
              (setq ip nil)
             )

             ((eq 5 (car grr)) ; point from mouse, update star
              (redraw)
              (setq rot (angle BasePoint (trans (setq ip (cadr grr)) 1 0)))
              (grdraw BasePoint ip 7); pointer angle
              (GroupRotate ObjList BasePoint (- rot ObjAng))
              (setq ObjAng rot) ; update object current angle
              (and (>= ObjAng (* 2 pi)) (setq ObjAng (- ObjAng (* 2 pi)))) ; correct if >= 2pi
              (setq LastRot ObjAng)
              t
             )
           )
         )
  )
  (redraw)
  (vla-endundomark doc)
  ip
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: lastpoint on rotate
« Reply #11 on: November 12, 2009, 06:44:20 PM »
nice Allan !  thanks..

I'll take your code as example.   :wink:


but ..

what about all Osnaps ? ortho ? input ?
I mean...why doing a new existing command only to take the last pickpoint ?
is there realy no way to get it ?

 :|
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lastpoint on rotate
« Reply #12 on: November 12, 2009, 07:35:49 PM »
Not that I know of.

This too is inaccurate if osnaps are used.
Code: [Select]
  (command "_rotate" pause)
  (while (>(getvar "CMDACTIVE")0) (command pause))
  (cadr (grread 1 1))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: lastpoint on rotate
« Reply #13 on: November 12, 2009, 09:27:51 PM »
aaahh.....

there it is...

Code: [Select]
(command "._rotate" (ssget) "")
(while (>(getvar "CMDACTIVE")0) (command pause))
(setq Lastpoint (osnap (cadr (grread 1 1)) "_end"))

Thanks Allan.. :roll:
It miss precision without Osnap..but near the goal.
Keep smile...

Serge J. Gianolla

  • Guest
Re: lastpoint on rotate
« Reply #14 on: November 12, 2009, 09:29:15 PM »
nice Allan !  thanks..

I'll take your code as example.   :wink:


but ..

what about all Osnaps ? ortho ? input ?
I mean...why doing a new existing command only to take the last pickpoint ?
is there realy no way to get it ?

 :|
Salut Andrea,

Is the @ helping you, like in
Command: PL
PLINE
Specify start point: @

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: lastpoint on rotate
« Reply #15 on: November 12, 2009, 11:30:05 PM »
aaahh.....

there it is...

Code: [Select]
(command "._rotate" (ssget) "")
(while (>(getvar "CMDACTIVE")0) (command pause))
(setq Lastpoint (osnap (cadr (grread 1 1)) "_end"))

Thanks Allan.. :roll:
It miss precision without Osnap..but near the goal.
The problem I ran into in my testing is that if the object you snap to is also being moved the rotate command will snap to the phantom object
but when you execute the osnap the object is no longer there & nil is returned.  :?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.