Ascension Posted February 23, 2014 Share Posted February 23, 2014 Hello everyone! I want to make lisp, that will use "rotate3d" command. After you select some block, you can press "x", "y" or "z" (several times), and lisp will rotate this block using insertion point as base point by 90 deg. clockwise (around corresponding axis), and when you finish rotating you press Enter and exit from lisp. For example, you select some block and then press "x" three times, block rotated by 270 deg. around X axis, then press "z" two times, and block rotated by 180 deg., then press Enter and exit from lisp. Is it possible, maybe there are some similar lisps? If anyone could give advice it would be greatly appreciated. Thank you in advance. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 23, 2014 Share Posted February 23, 2014 (edited) 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) Edited January 23, 2021 by Lee Mac Quote Link to comment Share on other sites More sharing options...
Ascension Posted February 23, 2014 Author Share Posted February 23, 2014 Lee Mac, Thank you so much for your quick response! It's exactly what i needed, You make my day! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 23, 2014 Share Posted February 23, 2014 You're welcome! - It was fun to write Quote Link to comment Share on other sites More sharing options...
hmsilva Posted February 23, 2014 Share Posted February 23, 2014 This seemed interesting - try the following: Nicely coded, Lee. Henrique Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 23, 2014 Share Posted February 23, 2014 Nicely coded, Lee. Thank you Henrique Quote Link to comment Share on other sites More sharing options...
Ascension Posted February 23, 2014 Author Share Posted February 23, 2014 I think i catch the meaning. Try to implement other ideas with similar approach Quote Link to comment Share on other sites More sharing options...
liuhaixin88 Posted February 24, 2014 Share Posted February 24, 2014 Nicely code,thanks lee I want rotate 3DSolid like this ,not a block, can do? Quote Link to comment Share on other sites More sharing options...
Bhull1985 Posted February 24, 2014 Share Posted February 24, 2014 Welcome to CADTutor Ascension. (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) [/code] as per usual, was hoping to hear your explanation of your process in this while loop if at all possible and time allowing This one is using grread, it appears, short of transformation matricies I haven't seen anything looking quite as abstract. Hoping you could decipher for me.. Quote Link to comment Share on other sites More sharing options...
ymg3 Posted February 24, 2014 Share Posted February 24, 2014 bhull, Actually quite simple. The loop determines if you entered either x , y or z. (asccii "x") -> 120 (ascii "X") ->88 etc. So as soon as you press the "x" key, for example, Variable axs is set to (1.0 0.0 0.0) You then add this value to the base point of the object. Rotation is fixed at 90 degrees. So your 3 arguments to the 'rotate3d method are bpt, the value calculated with mapcar and finally your angle. ymg Quote Link to comment Share on other sites More sharing options...
liuhaixin88 Posted February 25, 2014 Share Posted February 25, 2014 hello!someone can help me? I want rotate 3DSolid like this ,not a block, can do? Quote Link to comment Share on other sites More sharing options...
ymg3 Posted February 25, 2014 Share Posted February 25, 2014 liuhaixin, You can rotate solid. Only problem is getting your base point for rotation. As you know entity list is kind of encrypted. You could get the min of the bounding box and rotate around this point. (defun c:3dsr ( / ** ang axs bpt ent obj ) (while (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect Solid to rotate: "))) (cond ((= 7 (getvar 'errno)) (princ "\nMissed, try again.")) ((/= 'ename (type ent)) nil) ((/= "3DSOLID" (cdr (assoc 0 (entget ent)))) (princ "\nPlease select a Solid.")) ((setq obj (vlax-ename->vla-object ent) ** (vla-getboundingbox obj 'mini 'maxi) bpt (vlax-safearray->list mini) ang (/ pi 2.0) ) (princ "\nRotate about [X/Y/Z] <Exit>: ") ;;;;; Rest of the code is same;;;;;;;;; ymg Quote Link to comment Share on other sites More sharing options...
liuhaixin88 Posted February 25, 2014 Share Posted February 25, 2014 Oh! is cool.Thanks ymg. but I find Y-axis and Z-axis exchange. press"Y" is rotation around the "Z" axis. press"Z" is rotation around the "Y" axis. Quote Link to comment Share on other sites More sharing options...
ymg3 Posted February 25, 2014 Share Posted February 25, 2014 liuhaixin, I believe you are mistaken. Lee's order for the rotation is correct. ymg Quote Link to comment Share on other sites More sharing options...
liuhaixin88 Posted February 25, 2014 Share Posted February 25, 2014 liuhaixin, I believe you are mistaken. Lee's order for the rotation is correct. ymg ymg, I'm sorry!I was wrong! I created a new document, test, It's OK! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 25, 2014 Share Posted February 25, 2014 Thank you for stepping in ymg, good explanation. Quote Link to comment Share on other sites More sharing options...
Least Posted April 1, 2014 Share Posted April 1, 2014 Lee Is it a simple modification for the block rotate routine to work with multiple blocks at a time? How would I go about changing it? Thanks Pads Quote Link to comment Share on other sites More sharing options...
aygn Posted February 28, 2015 Share Posted February 28, 2015 Hi everybody, I need to use ROTATE3D on texts. I have over 2000 texts on TOP view and I want to rotate them so that I can read them on LEFT view. I need a lisp to Rotate3D multiple texts around their own base point, -90 degrees on Y Axis. I would really appreciate any help. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 28, 2015 Share Posted February 28, 2015 I need to use ROTATE3D on texts. I have over 2000 texts on TOP view and I want to rotate them so that I can read them on LEFT view.I need a lisp to Rotate3D multiple texts around their own base point, -90 degrees on Y Axis. Try the following modification of my earlier code: ([color=BLUE]defun[/color] c:3drtxt ( [color=BLUE]/[/color] ang axs idx lst obj sel ) ([color=BLUE]setq[/color] ang ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.0)) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] sel ([color=BLUE]ssget[/color] [color=MAROON]"_:L"[/color] '((0 . [color=MAROON]"TEXT,MTEXT"[/color])))) ([color=BLUE]progn[/color] ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] idx ([color=BLUE]sslength[/color] sel)) ([color=BLUE]setq[/color] lst ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] ([color=BLUE]setq[/color] obj ([color=BLUE]vlax-ename->vla-object[/color] ([color=BLUE]ssname[/color] sel ([color=BLUE]setq[/color] idx ([color=BLUE]1-[/color] idx))))) ([color=BLUE]vlax-get[/color] obj ([color=BLUE]if[/color] ([color=BLUE]or[/color] ([color=BLUE]=[/color] [color=MAROON]"AcDbMText"[/color] ([color=BLUE]vla-get-objectname[/color] obj)) ([color=BLUE]=[/color] [color=BLUE]acalignmentleft[/color] ([color=BLUE]vla-get-alignment[/color] obj)) ) 'insertionpoint 'textalignmentpoint ) ) ) lst ) ) ) ([color=BLUE]princ[/color] [color=MAROON]"\nRotate about [X/Y/Z] <Exit>: "[/color]) ([color=BLUE]while[/color] ([color=BLUE]setq[/color] axs ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] ([color=BLUE]grread[/color] [color=BLUE]nil[/color] 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) ) ) ) ) ([color=BLUE]foreach[/color] itm lst ([color=BLUE]vlax-invoke[/color] ([color=BLUE]car[/color] itm) 'rotate3d ([color=BLUE]cdr[/color] itm) ([color=BLUE]mapcar[/color] '[color=BLUE]+[/color] ([color=BLUE]cdr[/color] itm) axs) ang) ) ) ) ) ([color=BLUE]princ[/color]) ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) Quote Link to comment Share on other sites More sharing options...
mikekmx Posted March 1, 2015 Share Posted March 1, 2015 Lee Mac, Thank you so much for your quick response! It's exactly what i needed, You make my day! +1! Thank you Lee.... i never knew i needed this but it is very nice AutoDesk should hire some people like you. Quote Link to comment Share on other sites More sharing options...
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.