Jump to content

Rotate around x,y,z-axis


Randolph

Recommended Posts

Hi,

 

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

 

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

and 

ry, rz

 

 

Thanx!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

(vla-rotate3D <object> <point1> <point2> <angle>)

 

Where and are the two points defining your axis of rotation.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

I feel like I'm writing chinese :(

Bigal, I really do know my Euclides.

Let's try it with german AutoCAD

 

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:

 

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:

 

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 ...

Link to comment
Share on other sites

Ok, I'll give you a little help:

 

(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

Link to comment
Share on other sites

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

Edited by Randolph
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...