Jump to content

Recommended Posts

Posted (edited)

I've tried the below, but it would not run. Thank you for helping.

 

(defun c:3drx ( )
(3dr "X")
)
;;;;;

(defun 3dr (axs / ang bpt idx ls1 ls2 lst obj pt1 pt2 sel )
   (if (setq sel (ssget "_:L"))
       (progn
           (repeat (setq idx (sslength sel))
               (if
                   (and
                       (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))))
                       (vlax-method-applicable-p obj 'getboundingbox)
                       (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'pt1 'pt2))))
                   )
                   (setq ls1 (cons (vlax-safearray->list pt1) ls1)
                         ls2 (cons (vlax-safearray->list pt2) ls2)
                         lst (cons obj lst)
                   )
               )
           )
           (if (and ls1 ls2)
               (progn
                   (setq ang (/ pi 2.0)
                         bpt
                       (apply 'mapcar
                           (cons '(lambda ( a b ) (/ (+ a b) 2.0))
                               (mapcar '(lambda ( a b ) (apply 'mapcar (cons a b))) '(min max) (list ls1 ls2))
                           )
                       )
                   )
                   ;;(princ "\nRotate about [X/Y/Z] <Exit>: ")
                   ;;(while
                       (setq axs
                           (cdr
                               (assoc (grread nil 10)
                                  '(
                                       ((2 120) 1.0 0.0 0.0)
                                       ((2 088) 1.0 0.0 0.0)
                                       ((2 121) 0.0 1.0 0.0)
                                       ((2 089) 0.0 1.0 0.0)
                                       ((2 122) 0.0 0.0 1.0)
                                       ((2 090) 0.0 0.0 1.0)
                                   )
                               )
                           )
                       )
                       (foreach obj lst
                           (vlax-invoke obj 'rotate3d bpt (mapcar '+ bpt axs) ang)
                       )
                   )
               )
               (princ "\nUnable to determine rotation base point.")
           )
       )
   )
   (princ)
)
(vl-load-com) (princ)

 

Edited by SLW210
Added Code Tags!!
Posted

I am not sure what your trying to do rotate3d, select objects, select point, X or Y or Z then angle.

 

"rotation base point" so pick a end point etc ?

 

I think we need a dwg example before after.

 

 

 

  • 1 year later...
Posted
On 2/24/2014 at 12:19 AM, Lee Mac said:

Welcome to CADTutor Ascension.

 

This seemed interesting - try the following:

(defun c:3dbr ( / ang axs bpt ent obj )
   (while
       (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect block to rotate: ")))
           (cond
               (   (= 7 (getvar 'errno))
                   (princ "\nMissed, try again.")
               )
               (   (/= 'ename (type ent)) nil)
               (   (/= "INSERT" (cdr (assoc 0 (entget ent))))
                   (princ "\nPlease select a block.")
               )
               (   (setq obj (vlax-ename->vla-object ent)
                         bpt (vlax-get obj 'insertionpoint)
                         ang (/ pi 2.0)
                   )
                   (princ "\nRotate about [X/Y/Z] <Exit>: ")
                   (while
                       (setq axs
                           (cdr
                               (assoc (grread nil 10)
                                  '(
                                       ((2 120) 1.0 0.0 0.0)
                                       ((2 088) 1.0 0.0 0.0)
                                       ((2 121) 0.0 1.0 0.0)
                                       ((2 089) 0.0 1.0 0.0)
                                       ((2 122) 0.0 0.0 1.0)
                                       ((2 090) 0.0 0.0 1.0)
                                   )
                               )
                           )
                       )
                       (vlax-invoke obj 'rotate3d bpt (mapcar '+ bpt axs) ang)
                   )
               )
           )
       )
   )
   (princ)
)
(vl-load-com) (princ)
 


Hello mr.mac
now i use this code to make rotate for several blocks (with the same name)
to rotate 90 degree about the axis in the length direction (local axis of each block)
can you make something like this ?
thanks in advance 

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