+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Jan 2010
    Posts
    56

    Default Lisp to change the rotation of a selected object to another one

    Registered forum members do not see this ad.

    Hi guys,

    So if possible i would like first make a selection of blocks (#1) and then select another block (#2) with a different rotation... and at the end my selection of blocks (#1) have the same rotation as the another block (#2).

    I'll do my best to explain...

    Bono.

  2. #2
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,008

    Default

    Yes, this is possible:
    Code:
    ; Match Block Rotation routine (08-VIII-2012)
    (defun c:MBR( / ssetBlockSource ssetBlockTarget theBlock assocList theRotation )
     (prompt "\nSelect source block to copy rotation from...")
     (if (setq ssetBlockSource (ssget "_:S:E" '((0 . "INSERT"))))
      (progn
       (setq theBlock    (ssname ssetBlockSource 0)
             assocList   (entget theBlock)
             theRotation (assoc 50 assocList))
       (prompt "\nSelect target block to copy rotation to...")
       (while (setq ssetBlockTarget (ssget "_:S:E" '((0 . "INSERT"))))
        (setq theBlock  (ssname ssetBlockTarget 0)
              assocList (entget theBlock))
        (entmod (subst theRotation
                       (assoc 50 assocList)
                       assocList))
       )
      )
     )
     (princ)
    )
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  3. #3
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,633

    Default

    Code:
    (defun c:Test (/ s ss i sn)
      (if (and (setq s (ssget "_+.:S" '((0 . "INSERT"))))
           (setq ss (ssget ":L" '((0 . "INSERT"))))
          )
        (repeat (setq i (sslength ss))
          (setq sn (ssname ss (setq i (1- i))))
          (entmod (subst (assoc 50 (entget (ssname s 0)))
                 (assoc 50 (entget sn))
                 (entget sn)
              )
          )
        )
        (princ)
      )
      (princ)
    )
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  4. #4
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Jan 2010
    Posts
    56

    Default

    Thanks to Msasu and Tharwat!!!!

    It's just wat i need.

    Long live to cadtutor!!!!

  5. #5
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,008

    Default

    Glad to hear that you find it useful!
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  6. #6
    Junior Member
    Using
    AutoCAD 2007
    Join Date
    May 2012
    Posts
    16

    Default

    Hello,
    I am sorry if I break the forum rule adding to this thread, but this is similar idea: have you got an idea for a lisp to add certain angle value to current block angle? I have various blocks inserts of different angle, and I need to rotate some of them by 180 degrees. The idea is to do this by running a command and a single click on the block, to have it rotated by extra angle defined at the beginning of the command, and repeat. Any idea?

  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
    15,744

    Default

    Quote Originally Posted by mikitari View Post
    Have you got an idea for a lisp to add certain angle value to current block angle?
    In this code:

    http://www.cadtutor.net/forum/showth...l=1#post507691

    Change:
    Code:
    "TEXT,MTEXT"
    to:
    Code:
    "INSERT"
    Lee Mac Programming

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

    Just another Swamper

  8. #8
    Junior Member
    Using
    AutoCAD 2007
    Join Date
    May 2012
    Posts
    16

    Default

    Hi Lee Mac,
    Thank you for pointing to this next thread! I will check this out on blocks. Just to be clear: Could you please confirm, that the lisp works by means of rotating and not flipping (not the mirror effect). Best regards!

  9. #9
    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
    15,744

    Default

    Quote Originally Posted by mikitari View Post
    Could you please confirm, that the lisp works by means of rotating and not flipping (not the mirror effect).
    Yes ........
    Lee Mac Programming

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

    Just another Swamper

  10. #10
    Junior Member
    Using
    AutoCAD 2007
    Join Date
    May 2012
    Posts
    16

    Default

    Registered forum members do not see this ad.

    Both rutines from the other thread work great!
    Thank you!

    Best regards,
    M.

Similar Threads

  1. Lisp to change Z value of all selected - request
    By Tom_D in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 10th Aug 2012, 05:46 pm
  2. Looking for a LISP to change selected objects to the color of their layer
    By greatday2882 in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 29th Nov 2011, 03:39 pm
  3. LISP to change UCS rotation
    By oldsoftboss in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 2
    Last Post: 6th Oct 2011, 10:03 am
  4. How to pass a selected object from Lisp to VBA
    By MR_Zeroeffect in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 16th Jun 2009, 12:08 pm
  5. Need Lisp to change Oblique Dim text rotation.
    By catmando in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 31st Mar 2009, 07:39 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