barristann Posted August 25, 2023 Posted August 25, 2023 (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 21 hours ago by SLW210 Added Code Tags!! Quote
BIGAL Posted August 25, 2023 Posted August 25, 2023 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. Quote
Mostafa hisham Posted Tuesday at 04:37 PM Posted Tuesday at 04:37 PM 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 Quote
Recommended Posts
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.