1. ## Rotate around x,y,z-axis

Registered forum members do not see this ad.

Hi,

does anybody have a (presumably short) piece of code doing the following:

Code:
```Command: rx (rotate aoround x-axis)
does: rotate3d with x-axis pre-chosen as rotation axis

and

ry, rz```

Thanx!

2. vla-Rotate3D function?

3. Sorry Lee Mac, I don't get the point in vla-rotation.
I'm talking about rotation around the 3 main axis.

rx shall rotate around x-axis, ry around the y-axis, rz ...
You just choose 1 point to rotate around.

It's just about sparing 1 option in the rotate3d command.

4. Originally Posted by Randolph
Sorry Lee Mac, I don't get the point in vla-rotation.
I'm talking about rotation around the 3 main axis.
I know you are, which is why I suggested vla-Rotate3D

Code:
`(vla-rotate3D <object> <point1> <point2> <angle>)`
Where <point1> and <point2> are the two points defining your axis of rotation.

5. I think you should look at the command version first "Rotate3d" understand how that works and then re-read Lee's answer particuarly using points rather than X Y Z

0,0,0 1,0,0 is a direction in the x axis but you need a point on your object to start.

6. I feel like I'm writing chinese
Bigal, I really do know my Euclides.
Let's try it with german AutoCAD

Code:
```Befehl: r3
_ROTATE3D
Aktueller positiver Winkel: ANGDIR=Gegen den Uhrzeigersinn  ANGBASE=0.00
Objekte wählen: nil
Objekte wählen: 1 gefunden
Objekte wählen:
Ersten Punkt auf Achse angeben oder Achse definieren nach
[Objekt/Letztes/ANsicht/X-achse/Y-achse/Z-achse/2Punkte]: *Abbruch*```
This is:

Code:
```r3 = rotate 3d
select objects
choose point on axis or define axis by
[... X-axis/Y-axis/Z-axis ...]```
And this what I want to spare - just a simple rotate 3d with X-axis preselected ... and one with Y-axis preselected and one with Z-axis preselected.

Should work like this:

Code:
```rx
select objects
define rotation base point
objects are rotated around x-parallel through base point.```
It's really something very simple. I JUST want to spare the one step of entering "x" in the rotat3d command. For the lisp-pros this should be something extremely simplistic ...

7. Ok, I'll give you a little help:

Code:
```(defun c:rx ( / e p a )

(if
(and
(setq e (car (entsel)))
(setq p (getpoint "\nBase Point: "))
(setq a (getangle p "\nAngle: "))
)
(vla-Rotate3D
(vlax-ename->vla-object e)
(vlax-3D-point (trans p 1 0))
(vlax-3D-point (mapcar '+ (trans p 1 0) '(1. 0. 0.)))
a
)
)

(princ)
)```
That's one way to do it.

Note that if you want to rotate a selection set, you wil need to iterate through it, rotating each object in turn. Also note that the above will rotate about the WCS X-Axis, not the UCS X-Axis.

Lee

8. Thanx, I'll try this. May I ask you what your reason is for preferring vla-rotate3d to rotate3d?
I know how to preselect an option which appear 1st instance like:

(DEFUN C:BX ()(COMMAND "_UCS" "X"))

whereas

(DEFUN C:RX ()(COMMAND "_ROTATE3D" "_X"))

doesn't work: wrong selection, point required.

So I tried to figure out how to preselect options which appear only 2nd or 3d row when working through a command.

BECAUSE next thing would be mx, my, mz:

MX mirror3d on YZ-parallel plane
MY mirror3d on ZX-parallel plane

9. Registered forum members do not see this ad.

The first thing rotate3d does is asks for object to be rotated! You cant jump 2 steps ahead and then go back.

Lee has posted the answer you just change the reference in (vlax-3D-point (mapcar '+ (trans p 1 0) '(1. 0. 0.))) for the y axis '(0. 1. 0.) he even called it "rx" once loaded automaticaly at start up it doesn't matter how much code is involved. You just type rx.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts