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
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.
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.
I feel like I'm writing chinese
Bigal, I really do know my Euclides.
Let's try it with german AutoCAD
This is: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*
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.Code:r3 = rotate 3d select objects choose point on axis or define axis by [... X-axis/Y-axis/Z-axis ...]
Should work like this:
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 ...Code:rx select objects define rotation base point objects are rotated around x-parallel through base point.
Ok, I'll give you a little help:
That's one way to do it.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) )
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.
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"))
(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
Last edited by Randolph; 18th Jan 2011 at 05:59 pm.
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.