Jump to content

Recommended Posts

Posted

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

Posted (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 by Lee Mac
Posted

Lee Mac, Thank you so much for your quick response!

It's exactly what i needed, You make my day! 8)

Posted

This seemed interesting - try the following:

Nicely coded, Lee.

 

 

Henrique

Posted

I think i catch the meaning. Try to implement other ideas with similar approach :)

Posted

Nicely code,thanks lee

 

I want rotate 3DSolid like this ,not a block, can do?

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

Posted

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

Posted

hello!someone can help me?

 

I want rotate 3DSolid like this ,not a block, can do?

Posted

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

Posted

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.

Posted

liuhaixin,

 

I believe you are mistaken.

 

Lee's order for the rotation is correct.

 

ymg

Posted
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!

  • 1 month later...
Posted

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

  • 10 months later...
Posted

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.

Posted
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])

Posted
Lee Mac, Thank you so much for your quick response!

It's exactly what i needed, You make my day! 8)

 

+1!

 

Thank you Lee.... i never knew i needed this but it is very nice :beer:

 

AutoDesk should hire some people like you.:shock:

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