TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: velasquez on June 20, 2009, 07:32:29 AM

Title: command "._rotate" vs vla-Rotate
Post by: velasquez on June 20, 2009, 07:32:29 AM
I have the command Rotate working with the option Reference, see code below.

Code: [Select]
(command "._rotate" "_l" "" pt1 "_R" 270 45)
In vla-rotate this option doesn't exist.
; Rotate (2)

Somebody can me to say how to calculate the Final angle?
See code below.
Code: [Select]
(vla-rotate (vlax-ename->vla-object (entlast)) (vlax-3D-Point pt1) 180)
Title: Re: command "._rotate" vs vla-Rotate
Post by: CAB on June 20, 2009, 10:03:41 AM
Are you asking for angle in Radians?

Code: [Select]
(/ (* degAngle pi) 180.0)
For 90 deg
Code: [Select]
(/ (* 90 pi) 180.0)
Title: Re: command "._rotate" vs vla-Rotate
Post by: gile on June 20, 2009, 11:30:12 AM
Hi,

The angle you want to calculate is : (360° - R) - A
where R is the Reference angle in degrees and A the new angle in degrees.

But as CAB said vla-Rotate needs angles in radians (as getangle, getorient, angle returned values)

Code: [Select]
(setq ent (car (entsel))
      pt  (getpoint "\nBasePoint :")
      r   (getangle "\nReference angle: ")
      a   (getangle pt "\nNew angle: ")
)
(vla-rotate
  (vlax-ename->vla-object ent)
  (vlax-3d-point pt)
  (+ (- (* 2 pi) r) a)
)