Rotate to set object at angle - using 'getangle' works bad

Rotate to set object at angle - using 'getangle' works bad

Anonymous
Not applicable
1,188 Views
2 Replies
Message 1 of 3

Rotate to set object at angle - using 'getangle' works bad

Anonymous
Not applicable

Here I have something very strange for me.

 

Do you remember my lisps RT2SETNG and RT2SETPOI?

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rotate-selected-object-to-position-gi...

They are now called RTREFNG and RTREFPOI.

; Lisps are here:
; http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rotate-selected-object-to-position-given-1-by-value-or-2-by-two/td-p/5476226

; On ground of:
; http://www.ellenfinkelstein.com/acadblog/rotate-one-object-to-match-another/

; ROTATE, Enter --> BasePoint --> Reference --> Angle
; Ustawiasz, by wybrany obiekt leżał pod kątem wskazanym za pomocą wartośc podanej ręcznie
; RT2SETNG = RoTate TO the SETted aNGle (position)
; RTREFNG = RoTate REFerence aNGle
(DEFUN C:RTREFNG ()
 (setq zbior (ssget))
 (setq pt1 (getpoint "\nClick on a point on the rotated Object (it will be a BasePoint): "))
 (setq pt2 (getpoint "\nClick on the other point on the rotated Object: "))
; These two points (endpt1, endpt2) determine a straight line which Angle (position) will be set to value you type
 (setq angle  (getreal "\nSet angle (position of the selected object after Rotating): "))
 (command "_ROTATE"
  ;Select objects:
   zbior ""
  ;Specify base point:
   pt1
  ;Specify rotation angle or [Copy/Reference] <0>:
   "R" ; Reference
  ;Specify the reference angle
   pt1 pt2
  ;Specify the new angle or [Points] <0>:
   angle
 )
)

;Command: ROTATE nil
;
;Select objects: 1 found
;
;Select objects:
; Wybieram Linię/ Obiekt
;Specify base point:
; Wskazuję Base Point - jeden z Endpointów Linii
;Specify rotation angle or [Copy/Reference] <11>: r
; Reference, Enter
;Specify the reference angle <23>:
; 1x LPMem na punkt, który jest BasePoint'em
;  Specify second point:
; 1x LPMem na Punkt leżący na prostej należącej do Obiektu, na którym leży także BasePoint
;Specify the new angle or [Points] <34>: 56
; I type new value for Angle, Enter
; The Line has such position, that it's Angle is equal to 56

;-------

; ŚWIETNY LISP
; Jak ALIGN, tylko że robisz sam obrót, bez przyciągania jednego obiektu do drugiego.
; Ustawiasz, by wybrany obiekt leżał pod kątem wskazanym za pomocą dwóch punktów.

; GREAT LISP
; Like ALIGN. nut you order only ROTATE, without snap the two Objects to eachother.
;You set the chosen Object to lie at the Angle definied by picking two Points.

; See also lisps: SNAPANG

; Zrobię jeszcze drugą taką komendę.
; Ona będzie wydawać polecenia w takiej kolejności jak ALIGN:
; Pick first source point. Pick first destination point. Pick second source point. Pick second destination point.

; I made one more lisp, very similar to RTREFPOI, but it will be
; give orders in the same order as ALIGN command:
; Pick first source point. Pick first destination point. Pick second source point. Pick second destination point.
; So this lisp will be called RTREFPOIALIGN

; ROTATE, Enter --> BasePoint --> Reference --> Points
; RTREFPOI = RoTate REFerence POInts ; AGG - bo jest jak AliGn
; RT2SETPOI = RoTate TO the SETted angle (position) - which is setted with two POInts
(DEFUN C:RTREFPOI ()
 (setq zbior (ssget))
 (setq ptA1 (getpoint "\nClick on a point on the rotated Object (it will be a BasePoint): "))
 (setq ptA2 (getpoint "\nClick on the other point on the rotated Object: "))
; These two points (ptA1, ptA2) determine a straight line which Angle (position) will be set to value you type
 (setq ptB1 (getpoint "\nDetermine position of the selected Object after Rotate.\nClick on a point you refer to: "))
; "\nDetermine Angle (position) of the selected Object, which will it have after Rotate.
 (setq ptB2 (getpoint "\nClick on the other point you refer to: "))
 (command "_ROTATE"
  ;Select objects:
   zbior ""
  ;Specify base point:
   ptA1
  ;Specify rotation angle or [Copy/Reference] <0>:
   "R" ; Reference
  ;Specify the reference angle
   ptA1 ptA2
  ;Specify the new angle or [Points] <0>:
   "P" ; Points
  ;Specify first point:
   ptB1
  ;Specify second point:
   ptB2
 )
)

;------

; # THE BEST !
; ALIGN, bo wydaje polecenia w takiej kolejności, co ALIGN
; ALIGN, because it gives orders in the same order as the ALIGN command
(DEFUN C:RTREFPOIALIGN ()
 (setq zbior (ssget))
 (setq ptA1 (getpoint "\nPick first source point: "))
 (setq ptB1 (getpoint "\nPick first destination point: "))
 (setq ptA2 (getpoint "\nPick second source point: "))
 (setq ptB2 (getpoint "\nPick second destiation point: "))
 (command "_ROTATE"
  ;Select objects:
   zbior ""
  ;Specify base point:
   ptA1
  ;Specify rotation angle or [Copy/Reference] <0>:
   "R" ; Reference
  ;Specify the reference angle
   ptA1 ptA2
  ;Specify the new angle or [Points] <0>:
   "P" ; Points
  ;Specify first point:
   ptB1
  ;Specify second point:
   ptB2
 )
)

 

 

 

In one of the topics I created somebody wrote to me that I wrote in lisp

(setq Angle (getreal "\nType value..."))

and that is maybe not so bad, but certainly not properly.

That is because I should write 'getangle' instead of 'getreal' - with 'getangle' the user can as well type value by keyboard as well pick two points.

 

I remember this today and I wanted to create lisp such as RTREFNG and RTREFPOI in one, and that's thanks to using 'getangle'.

So I used 'getangle':

 

; Nie działa jak należy
; W wyniku obrotu linia nie znajdzie się
; pod wybraym kątem.

; It doesn't works like I expected.
; In result of rotate, the chosen Line will be
; not positioned at definied angle.

; RTREFNG oraz RTREFPOI w jednym
; możesz zdefiniować pozycję wybranego odcinka Obiektu po obrocie
; i przez podanie wartości z klawiatury, i przez kliknięcie w dwa punkty

; It is RTREFNG and RTREFPOI in one
; You can define position of chosen Segment from the Object, which will it have after rotate.
; You can define its position as well by typing the value by keyboard,
; as well by picking two Points


;RTREFNGPOI = RoTate REFerence aNGle POInts
;RTREFAG = RoTate REFerence AliGn
(DEFUN C:RTREFAG ()
 (setq zbior (ssget))
 (setq pt1 (getpoint "\nClick on a point on the rotated Object (it will be a BasePoint): "))
 (setq pt2 (getpoint "\nClick on the other point on the rotated Object: "))
; These two points (endpt1, endpt2) determine a straight line which Angle (position) will be set to value you type
 (setq ang  (getangle "\nSet POSITION of the selected object after Rotating - TYPE value OR PICK two Points: "))
 (command "_ROTATE"
  ;Select objects:
   zbior ""
  ;Specify base point:
   pt1
  ;Specify rotation angle or [Copy/Reference] <0>:
   "R" ; Reference
  ;Specify the reference angle
   pt1 pt2
  ;Specify the new angle or [Points] <0>:
   ang
 )
)

 But it doesn't work... All I described in code.

It works on the same rule as RTREFNG and RTREFPOI, which both work properly. Where are differences from?

 

0 Likes
1,189 Views
2 Replies
Replies (2)
Message 2 of 3

Kent1Cooper
Consultant
Consultant

Without studying it in depth, I suspect it's because (getangle) returns radians, but Rotate command's rotation-angle prompt is going to want it in the current angular units [typically degrees].  Use (angtos ang) to answer that prompt, and it won't matter what the current angular units settings are.

Kent Cooper, AIA
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you, your advice is something new for me; I didn't know that 'angtos' is great and makes no difference; regardless to current angle units.

 

Now my lisp works good.

Thank you once again.

 

 

;RTREFNGPOI = RoTate REFerence aNGle POInts
;RTREFAG = RoTate REFerence AliGn
(DEFUN C:RTREFAG ()
 (setq zbior (ssget))
 (setq pt1 (getpoint "\nClick on a point on the rotated Object (it will be a BasePoint): "))
 (setq pt2 (getpoint "\nClick on the other point on the rotated Object: "))
; These two points (endpt1, endpt2) determine a straight line which Angle (position) will be set to value you type
 (setq ang  (getangle "\nSet POSITION of the selected object after Rotating - TYPE value OR PICK two Points: "))
 (setq ang2s (angtos ang))
 (command "_ROTATE"
  ;Select objects:
   zbior ""
  ;Specify base point:
   pt1
  ;Specify rotation angle or [Copy/Reference] <0>:
   "R" ; Reference
  ;Specify the reference angle
   pt1 pt2
  ;Specify the new angle or [Points] <0>:
   ang2s
 )
)

 

 

0 Likes