+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Senior Member
    Using
    AutoCAD 2011
    Join Date
    Sep 2009
    Location
    Austria / Europe
    Posts
    181

    Default 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. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,878

    Default

    vla-Rotate3D function?
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Senior Member
    Using
    AutoCAD 2011
    Join Date
    Sep 2009
    Location
    Austria / Europe
    Posts
    181

    Default

    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. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,878

    Default

    Quote Originally Posted by Randolph View Post
    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.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  5. #5
    Luminous Being
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    5,348

    Default

    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. #6
    Senior Member
    Using
    AutoCAD 2011
    Join Date
    Sep 2009
    Location
    Austria / Europe
    Posts
    181

    Default

    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. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,878

    Default

    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
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  8. #8
    Senior Member
    Using
    AutoCAD 2011
    Join Date
    Sep 2009
    Location
    Austria / Europe
    Posts
    181

    Default

    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
    Last edited by Randolph; 18th Jan 2011 at 05:59 pm.

  9. #9
    Luminous Being
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    5,348

    Default

    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.

Similar Threads

  1. Rotate in 3D (Z Axis)
    By Primal Scientist in forum AutoCAD General
    Replies: 5
    Last Post: 25th Nov 2009, 11:46 am
  2. Unable to rotate around Y axis with RMB
    By deangelis in forum Rhino
    Replies: 0
    Last Post: 1st Jan 2008, 07:10 am
  3. Error: The UCS X axis and Y axis must be perpendicular
    By Gerardus in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 24th Jan 2006, 01:02 am
  4. isolating an object to rotate on 3d axis
    By ethrim in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 1st Nov 2005, 05:08 pm
  5. Rotate with Multiple Axis? 2D
    By fewer_98 in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 10th Nov 2004, 08:56 pm

Bookmarks

Posting Permissions

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