Jump to content

rotate3d Lisp, Need help


Ascension

Recommended Posts

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)

Link to comment
Share on other sites

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.

 

 

 

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