Jump to content

Needs improvement


RubberDinero

Recommended Posts

(defun c:rb ( / ss ang ) (vl-load-com)
 (setq ss (vlax-ename->vla-object (car (entsel "\nSelect Block to Rotate: "))))
(setq ang (getangle "\nSpecify Rotation Angle: "))
  (vla-put-Rotation ss ang)
)(princ)

I Frankenstien-ed this lisp routine from different posts around the web, and while it works "perfectly" I hate that it doesn't know that something is selected or if I start the command with something selected it will ask me to select it again, it stays selected after the command is done.

I've used other rotate block lisps routines out there, but after the initial run, if I do it again, they seem to add to it's current rotation angle. i.e. if the block is at 23 deg, and you select an angle that is 10 deg, the block will then go to 33 deg. Others would just be completely weird

 

Improvements I would like to implement, but not good enough implement myself:

work on multiple blocks

move to angle prompt if blocks are already selected selected

if I select nothing or wrong object prompt to retry. If possible, if a mix of blocks and other objects are selected, filter out other entities.

 

Thanks ahead of time. I can live with the current setup, but any improvements are always welcomed.

 

Link to comment
Share on other sites

Why do you need code to do this? Filter your blocks then change the rotation in the properties palette.

 

Simple example for filter.

(defun c:foo (/ s)
  (if (setq s (ssget ":L" '((0 . "INSERT"))))
    (progn (sssetfirst nil s) (vl-cmdf "_.properties"))
  )
  (princ)
)

 

Link to comment
Share on other sites

19 minutes ago, ronjonp said:

Why do you need code to do this? Filter your blocks then change the rotation in the properties palette.

 

Simple example for filter.


(defun c:foo (/ s)
  (if (setq s (ssget ":L" '((0 . "INSERT"))))
    (progn (sssetfirst nil s) (vl-cmdf "_.properties"))
  )
  (princ)
)

 

I won't be able to click on two points along a line with the property palette. 

 

I can take a distance, copy the rotation value, select the objects, open properties, paste the rotation value hit enter. That's a long way. 

 

avoiding all those steps is what I was trying to do. 

Link to comment
Share on other sites

Fair enough .. try this:

(defun c:foo (/ a s)
  (if (and (setq a (getangle)) (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

9 minutes ago, ronjonp said:

Fair enough .. try this:


(defun c:foo (/ a s)
  (if (and (setq a (getangle)) (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)
)

 

wow! worked great!

added a prompt for rotation angle.

(defun c:rb (/ a s)
  (if (and (setq a (getangle "\nSpecify Rotation Angle: ")) (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)
)

You guys make it seem so easy! 

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