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
Solved! Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
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))
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) )
You have used getproperty so why not seems to work.
(setq ang (getvar 'UCSXDIR)) (setpropertyvalue ent "Direction" ang)
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:
of course with great respect to all subroutines authors include you
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) )
@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.