Jump to content

Recommended Posts

Posted
+1!

 

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

 

Thank you Mike!

 

AutoDesk should hire some people like you.:shock:

 

I wish! - That would be fantastic :)

Posted

Thank you very much Lee.

But I get the following error after selecting the objects (texts)

 

; error: no function definition: VLAX-ENAME->VLA-OBJECT

 

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
Thank you very much Lee.

But I get the following error after selecting the objects (texts)

 

; error: no function definition: VLAX-ENAME->VLA-OBJECT

 

Such errors are usually caused by the ActiveX (COM) component of Visual LISP not being loaded, however, this shouldn't be an issue as the posted code already contains a (vl-load-com) expression which is evaluated on loading the code.

 

Try typing (vl-load-com) manually at the command-line before running the program and see if this resolves the issue.

 

What OS are you running? Windows or Mac?

 

Lee

Posted

Hi, I use Autocad 2014 on windows.

 

I tried typing (vl-load-com) but it did not change anything.

Posted
Hi, I use Autocad 2014 on windows.

 

I tried typing (vl-load-com) but it did not change anything.

 

I believe you may need to reinstall your AutoCAD 2014 software, as the ActiveX support for Visual LISP does not appear to have been successfully installed.

Posted (edited)

Thank you very much for your help. I'll try that!

 

Edit: One last question.

I am new to this lisp world. Does the problem with the ActiveX support affect only this lisp? Because I can use another lisp I found online. The following works fine.

Sorry for taking your time..

 

(defun c:rotmult ()
 (prompt "Select Entities to Rotate, <ENTER> for SSX.")
 (setq ss (ssget))
 (if (not ss) (setq ss (ssx)))
 (setq num (sslength ss))
 (setq x 0)
 (if ss 
 	(if (setq ang (getreal "Enter Rotation Angle: "))
  	(repeat num
	  	(setq ename (ssname ss x))
	    (setq elist (entget ename))
		(setq pnt (cdr(assoc 10 elist)))
		(command "Rotate" ename "" pnt ang)
		    (setq x (1+ x))
    	)
  	)
   )
 )

Edited by aygn
code
Posted
Does the problem with the ActiveX support affect only this lisp? Because I can use another lisp I found online. The following works fine.

 

The lack of ActiveX support will affect any LISP program which uses functions starting with vlax/vla/vlr.

Posted

Thank you very much. I'll try to reinstall Autocad and try the lisp in different versions and computers.

 

The lack of ActiveX support will affect any LISP program which uses functions starting with vlax/vla/vlr.
Posted
You're welcome aygn, and good luck!

 

Lee, you were right. There must be a problem with my computer. The lisp worked in Autocad 2008 on another computer.

 

Is it possible to use such a code or edit this one to rotate3d "points" on their own base points as well? I hope I am not asking too much.

Posted

This is exactly what I was looking for. Thank you very much eldon.

 

If you look at this thread, you might be able to see what you want
  • 2 months later...
Posted

Dear Lee

 

Nice code . at #12 ,rotate 3d solid , only can choose one solid ,how choose multi 3d solid objects ?

Posted

Dear @Lee Mac

I mean can use "window selection" and "crossing selection" to choose solid objects . can do ?

Posted
Nice code . at #12 ,rotate 3d solid , only can choose one solid ,how choose multi 3d solid objects ?

 

The following should work with a selection of any objects:

(defun c:3dr ( / ang axs 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)

  • Like 1
Posted
The following should work with a selection of any objects:

 

Lee, Perfect! You're great . :thumbsup: I'm truly grateful for your help.

  • 8 years later...
Posted

Lee's codes are awesome! Now, is it possible to preset this to always rotate in the x axis (or y or z)?

 

Instead of selecting [X/Y/Z], I would like to have

      1. a command to rotate in x

      2. a command to rotate in y

      3. a command to rotate in z

 

Thank you

Posted (edited)

Yes can be split, need though to split the code into separate defuns 3DR no C : then c:3drx c:3dry c:3drz and set axis to correct direction eg (1.0 0.0 0.0) then run the foreach. 

 

Have a go always a good time to learn lisp.

 

A hint is C:3drx,  y & z calls 3dr. 

 

Edited by BIGAL

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