Author Topic: command "._rotate" vs vla-Rotate  (Read 4753 times)

0 Members and 1 Guest are viewing this topic.

velasquez

  • Newt
  • Posts: 195
command "._rotate" vs vla-Rotate
« 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)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: command "._rotate" vs vla-Rotate
« Reply #1 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)
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.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: command "._rotate" vs vla-Rotate
« Reply #2 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)
)
Speaking English as a French Frog