Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to rotate acad_table?

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
danglar
1301 Views, 8 Replies

How to rotate acad_table?

I need to rotate selected acad_table align to current ucs

How I can do it?

I don't find rotation angle in the properties of acad_table

but I find a needful solution here:

https://www.kimprojects.com/rotate-mutiple-objects-around-center-lisp/

A problem is: This is not open code but I need it as lisp solution in order to include it as subroutine in my main program

Can somebody help me?

Any suggestion will be very appreciated

8 REPLIES 8
Message 2 of 9
danglar
in reply to: danglar

I also find this approach to solve the issue, but unfortunately it not working for me

(defun c:align-table  (/ table mtrans)
  (setq table (vlax-ename->vla-object
                (car (entsel "\nSelect Table:"))))
  (setq mtrans
         (vla-GetUCSMatrix
           (vla-get-ActiveUCS
             (vla-get-activedocument (vlax-get-acad-object)))))
  (vla-TransformBy table mtrans))
Message 3 of 9
ВeekeeCZ
in reply to: danglar

Try this one. Thought it rotates tables around their insertion points. Guess if you need mid of bounding box, you can handle the adjustment, right?

 

(defun c:RotateTableToUCS ( / ss i ent dir pnt eng ucs)

  (if (setq ss (ssget '((0 . "ACAD_TABLE"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (setq dir (getpropertyvalue ent "Direction"))
      (setq pnt (cdr (assoc 10 (entget ent))))
      (setq ang (angle '(0 0 0) dir))
      (setq ucs (angle '(0 0 0) (getvar 'UCSXDIR)))
      (command "_.rotate" ent "" "_non" (trans pnt 0 1) "_R" (angtos ang (getvar 'AUNITS) 8) (angtos ucs (getvar 'AUNITS) 8))))
  (princ)
  )

 

Message 4 of 9
Sea-Haven
in reply to: ВeekeeCZ

You have used getproperty so why not seems to work.

 

(setq ang (getvar 'UCSXDIR))
(setpropertyvalue ent "Direction" ang)

 

Message 5 of 9
danglar
in reply to: ВeekeeCZ

Thank you for as usual brilliant solution BeekeeCZ!

First of all your solution published here:

https://lispbox.wordpress.com/2019/05/06/rotates-tables-around-their-insertion-points/

… and the whole routine with your solution as subroutine published here:

https://lispbox.wordpress.com/2019/05/05/count-strings-within-viewport-selected-by-user-with-table-o...

of course with great respect to all subroutines authors include you

Message 6 of 9
ВeekeeCZ
in reply to: danglar

Guess the version rotating table around its center-point might be also useful.

 

(vl-load-com)

(defun c:RotateTableToUCSMid ( / ss i ent dir pnt eng)

  (if (setq ss (ssget '((0 . "ACAD_TABLE"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (vla-getboundingbox (vlax-ename->vla-object ent) 'lf 'ur)
      (setq pnt (mapcar '/ (mapcar '+ (vlax-safearray->list ur) (vlax-safearray->list lf)) '(2 2 2)))
      (setq ang (angle '(0 0 0) (getpropertyvalue ent "Direction")))
      (setq ucs (angle '(0 0 0) (getvar 'UCSXDIR)))
      (command "_.rotate" ent "" "_non" (trans pnt 0 1) "_R" (angtos ang (getvar 'AUNITS) 8) (angtos ucs (getvar 'AUNITS) 8))))
  (princ)
  )
Message 7 of 9
ВeekeeCZ
in reply to: Sea-Haven


@Sea-Haven wrote:

You have used getproperty so why not seems to work.

 

(setq ang (getvar 'UCSXDIR))
(setpropertyvalue ent "Direction" ang)

 

Sure. Did you try it? It doesn't work for me - it rotates just grips, not a geometry itself. Not sure what else has to be updated.

Message 8 of 9
doaiena
in reply to: ВeekeeCZ

(setpropertyvalue ent "BreakEnabled" 1)

Then the "Direction" property can be updated.

Message 9 of 9
ВeekeeCZ
in reply to: doaiena


@doaiena wrote:

(setpropertyvalue ent "BreakEnabled" 1)

Then the "Direction" property can be updated.


 

No, not this "Direction". Sorry. But thanks for trying.

I need a vector of rotation.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost