Jump to content

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


Recommended Posts

Posted

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

 

Bono.

Posted

Yes, this is possible:

; 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)
)

Posted
(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)
)

Posted

Thanks to Msasu and Tharwat!!!!

 

It's just wat i need.

 

Long live to cadtutor!!!!

  • 3 months later...
Posted

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?

Posted

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!

Posted
Could you please confirm, that the lisp works by means of rotating and not flipping (not the mirror effect).

 

Yes ........

  • 2 weeks later...
Posted

Both rutines from the other thread work great!

Thank you!

 

Best regards,

M.

Posted
Both rutines from the other thread work great!

Thank you!

 

Excellent, you're welcome :)

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