Message 1 of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need rotate multiple objects to a unique central point, no matter the way, like photos:
Solved! Go to Solution.
I need rotate multiple objects to a unique central point, no matter the way, like photos:
Solved! Go to Solution.
I am not one of the robots you're looking for
For quick start, let me know in case of any modification :
(defun c:test ( / e i ip s p) (if (and (setq s (ssget '((0 . "insert")))) (setq p (getpoint "\nSpecify unique central point : ")) ) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i)))) (setq ip (cdr (assoc 10 (entget e)))) (command-s "_.rotate" e "" ip "_r" ip (polar ip (* pi 0.5) 1.0) p) ) ) (princ) )
A 'heavily' modified version of the code @Satish_Rajdev to take into account the direction of the block you want to have pointed to your central point. Yeah...I know....but I really just like the VL* commands
In the example below the block has been defined as seen on screen, so the blocks are inserted with a rotation angle of 0. But the result should be that the north of the block is rotated to your central point, so there needs to be an offset angle to work with; in this case 90 or (0.5 * pi). In the code of @Satish_Rajdev this is a hard-coded value.
But as this may be different for different blocks, an additional input is required to provide the offset angle to work with. Effective the block offset angle specifies which side of the block should be directed to your central point and this code also takes into account the current rotation angle of the blocks.
(defun c:Test (/ T_Selection T_Point T_OffsetAngle T_Object T_Angle) (if (and (setq T_Selection (ssget '((0 . "INSERT")))) (setq T_Point (getpoint "\nSpecify unique central point : ")) (not (initget 1)) (setq T_OffsetAngle (* pi (/ (getreal "\nOffset block angle : ") 180))) ) (progn (vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) (foreach T_Object (vl-remove-if '(lambda (T_Item) (listp (cadr T_Item))) (ssnamex T_Selection)) (setq T_Object (vlax-ename->vla-object (cadr T_Object))) (setq T_Angle (angle (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint T_Object))) T_Point)) (vla-put-Rotation T_Object (- T_Angle T_OffsetAngle)) ) (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) ) ) (princ) )
@DannyNL wrote:...
In the example below the block has been defined as seen on screen, so the blocks are inserted with a rotation angle of 0. But the result should be that the north of the block is rotated to your central point, so there needs to be an offset angle to work with; in this case 90 or (0.5 * pi). In the code of @Satish_Rajdev this is a hard-coded value.
Let's say that using the (getreal) is +1. But using the (getangle) would be +2!
Haha....my bad....you are absolutely right!
Let's just say it's almost weekend and I'm already losing my edge a bit on Thursday's afternoon
The code as it should have been the first time
(defun c:Test (/ T_Selection T_Point T_OffsetAngle T_Object T_Angle) (if (and (setq T_Selection (ssget '((0 . "INSERT")))) (setq T_Point (getpoint "\nSpecify unique central point : ")) (not (initget 1)) (setq T_OffsetAngle (getangle "\nOffset block angle : ")) ) (progn (vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) (foreach T_Object (vl-remove-if '(lambda (T_Item) (listp (cadr T_Item))) (ssnamex T_Selection)) (setq T_Object (vlax-ename->vla-object (cadr T_Object))) (setq T_Angle (angle (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint T_Object))) T_Point)) (vla-put-Rotation T_Object (- T_Angle T_OffsetAngle)) ) (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) ) ) (princ) )
i want to rotate more objects with mtext. see my attachment. i want rotate multiple circles +mtexts of circle's own center. not metext center. can you help me
@Anonymous wrote:
i want to rotate more objects with mtext. see my attachment. i want rotate multiple circles +mtexts of circle's own center. not metext center. can you help me
I assume from your description that these are not Blocks with Attributes [that would make it much easier]. Are those text parts each one Mtext object with the number as subscript, or is the "D" a separate object from the "2"?
[And if the center of the Circle is the rotation base point, Rotating the Circle itself serves no purpose....]
@Kent1Cooper wrote:
@Anonymous wrote:i want to rotate more objects with mtext. see my attachment. i want rotate multiple circles +mtexts of circle's own center. not metext center. can you help me
I assume from your description that these are not Blocks with Attributes [that would make it much easier]. Are those text parts each one Mtext object with the number as subscript, or is the "D" a separate object from the "2"?
[And if the center of the Circle is the rotation base point, Rotating the Circle itself serves no purpose....]
can be added text, mtext, rtext, block with attributes and more objects to this lisp?
that would be great