Jump to content

Match rotate angel to another block


sivapathasunderam

Recommended Posts

Lisp to match rotation angel to another block (first click on a block that rotation pick then another click on another block apply)

cad tutor ask on 21-Apr-2021.jpg

Link to comment
Share on other sites

This has nothing to do with a higher power, but it will match the ANGLE of a picked block to a selection. 😇

(defun c:foo (/ a e s)
  (if (and (setq e (car (entsel "\nPick a block to match rotation: ")))
	   (setq a (cdr (assoc 50 (entget e))))
	   (setq s (ssget ":L" '((0 . "INSERT"))))
      )
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (vla-put-rotation (vlax-ename->vla-object e) a)
    )
  )
  (princ)
)

 

  • Like 1
Link to comment
Share on other sites

8 minutes ago, sivapathasunderam said:

@ronjonp & @tombu

 

many thanks to both of you and your valuable contributions ... both of your suggestions work perfectly !

 

thanks again

Glad to help 🍻

 

Here is a version to rotate all objects with a rotation property:

(defun c:foo (/ a e o s)
  (if (and (setq e (car (entsel "\nPick something to match rotation: ")))
	   (setq a (cdr (assoc 50 (entget e))))
	   (setq s (ssget ":L"))
      )
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (if (vlax-property-available-p (setq o (vlax-ename->vla-object e)) 'rotation)
	(vla-put-rotation o a)
      )
    )
  )
  (princ)
)

 

  • Like 1
  • Thanks 1
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...