Mirror: Rotation and X Scale

Mirror: Rotation and X Scale

renanemeyer
Advocate Advocate
3,573 Views
23 Replies
Message 1 of 24

Mirror: Rotation and X Scale

renanemeyer
Advocate
Advocate

Hello everybody.
I come to clarify a doubt, if anyone has any better ideas I also accept suggestions.

I often use the mirror in autocad, but in the mirror upwards it assigns a rotation 180 or when the mirror is on the side it assigns -1 in Scale X.
See the example photo

 

renanemeyer_0-1629984404335.png

 

I thought about creating a lisp that would take everything from this layer and adjust these mirrors to rotation 0 and X Scale = 1, but I come to ask if anyone already has something I can base myself on or could help me stop this repetitive work .

 

Thanks in advance


 

 
 
 
 
 
0 Likes
Accepted solutions (1)
3,574 Views
23 Replies
Replies (23)
Message 2 of 24

ВeekeeCZ
Consultant
Consultant

Not sure where is the issue.

Would you post just 2 situations, the initial state and wanted outcome?

0 Likes
Message 3 of 24

renanemeyer
Advocate
Advocate

Hello @ВeekeeCZ 
thanks for answering. Yes, the situation I would leave at the end would be like the picture

 

renanemeyer_0-1629985732765.png

 

for this result I keep applying mirror one or more times, according to each case

 

0 Likes
Message 4 of 24

Kent1Cooper
Consultant
Consultant

Only parts of what's Mirrored are Blocks in your sample drawing -- do you want the Line parts Mirrored normally, but just the Block parts revised for X scale factor and rotation?

 

It's easy to just grab a whole area of things, and in the Properties palette, reduce the selection to only the Blocks, and change all their X scale factors and rotations collectively.  But when I do that, I get this [the labels are still your originals -- all Blocks are now X=1 and Rotation=0]:

Kent1Cooper_0-1629986337149.png

Is that what you want?

EDIT:  I now see your latest post, in which the left-to-right series of Blocks are the same in all 4 locations, not just the scale/rotation of each individual block corrected.  That's a lot more complicated....  If you Mirror the Block parts as a group, horizontally, what is the Mirror axis location -- the midpoint of the long horizontal Line?  Would there always be some discernible location like that?

Kent Cooper, AIA
0 Likes
Message 5 of 24

ВeekeeCZ
Consultant
Consultant

Like this?

 

(defun c:Mirrfor ( / s p)

  (if (and (setq s (ssget "_:L"))
	   (setq p (getpoint "\nSpecify point: "))
	   )
    (command "_.copy" s "" "_non" p "_non" "@"
	     "_.mirror" s "" "_non" p "_non" "@0,1" "_n"
	     "_.mirror" s "" "_non" p "_non" "@1,0" "_n"
	     "_.mirror" s "" "_non" p "_non" "@1,0" "_y"
	     "_.mirror" "_p" "" "_non" p "_non" "@0,1" "_y"
	     ))
  (princ)
  )

Edit: Fixed multiple LL corner.

Message 6 of 24

renanemeyer
Advocate
Advocate

 That's right @Kent1Cooper , it's a little more complicated!
I haven't been able to solve it for days and I believe there will be no way.
But in this case, I don't mirror in the center of the horizontal line, because where I mirror it's in a drawing that contains several of these blocks

0 Likes
Message 7 of 24

renanemeyer
Advocate
Advocate

Thanks @ВeekeeCZ 

In fact, that way he creates the situation he didn't want. The image I put as a first example is my situation that comes out when I apply the mirror.

 

renanemeyer_0-1629988680567.png

 

What I was trying to get was for her to fix this mirror (even if it was just up or to the side) so that they all look the same as the original like that

 

renanemeyer_1-1629988914724.png

 

0 Likes
Message 8 of 24

ВeekeeCZ
Consultant
Consultant

@renanemeyer wrote:

 

renanemeyer_1-1629988914724.png

 


 

Are you actually wanting to mirror just a line that makes a "leader?" And all blocks should be just a copy?

0 Likes
Message 9 of 24

Kent1Cooper
Consultant
Consultant

You could at least simplify your corrections if you put the six Blocks into a temporary Block before MIRRORing.  In this case it looks like the midpoint of the horizontal Line would be an appropriate insertion point.  Then you can easily change the X scale factor and rotation of the temporary Block, or many of them all at once, and finally Explode it/them to get the independent Blocks back, so you can edit Attributes in them, etc.

Kent Cooper, AIA
0 Likes
Message 10 of 24

renanemeyer
Advocate
Advocate

Understood @Kent1Cooper is I would like to have less work to do all this (usually there are 300 to 1000 blocks of these in each drawing), but I think it is a little complex even to do with lisp.
I tried to do it just change the rotation, but even so, it's not the same to apply a new mirror
But I thank everyone who gave me ideas, if I solve it, I'll put the code here

0 Likes
Message 11 of 24

ВeekeeCZ
Consultant
Consultant

Perhaps this.... only those with one horizontal line...

 

(vl-load-com)

(defun c:Mirrfor ( / s p b e m)
  
  (if (and (setq s (ssget "_:L"))
	   (setq p (getpoint "\nSpecify point: "))
	   (setq b (ssadd))
	   )
    (progn
      (repeat (setq i (sslength s))
	(and (setq e (ssname s (setq i (1- i))))
	     (= "INSERT" (cdr (assoc 0 (entget e))))
	     (ssadd e b)
	     (ssdel e s))
	(and (= "LINE" (cdr (assoc 0 (entget e))))
	     (= (nth 2 (assoc 10 (entget e))) (nth 2 (assoc 11 (entget e))))
	     (setq m (trans (mapcar '/ (mapcar '+ (cdr (assoc 10 (entget e))) (cdr (assoc 11 (entget e)))) '(2 2)) 0 1))))
      
      (if (> (sslength s) 0)
	(command "_.copy" s "" "_non" p "_non" "@"
		 "_.mirror" s "" "_non" p "_non" "@0,1" "_n"
		 "_.mirror" s "" "_non" p "_non" "@1,0" "_n"
		 "_.mirror" s "" "_non" p "_non" "@1,0" "_y"
		 "_.mirror" "_p" "" "_non" p "_non" "@0,1" "_y"))
      (if (and (> (sslength b) 0)
	       (or m
		   (and (setq m (LM:ssboundingbox b))
			(setq m (trans (mapcar '/ (mapcar '+ (car m) (cadr m)) '(2 2)) 0 1)))))
	(command "_copy" b "" "_d" "_non" (list (* 2 (- (car p) (car m))) 0.)
		 "_copy" b "" "_d" "_non" (list 0. (* 2 (- (cadr p) (cadr m))))
		 "_copy" b "" "_d" "_non" (list (* 2 (- (car p) (car m))) (* 2 (- (cadr p) (cadr m))))))))
  (princ)
  )

;; Selection Set Bounding Box  -  Lee Mac
;; Returns a list of the lower-left and upper-right WCS coordinates of a
;; rectangular frame bounding all objects in a supplied selection set.
;; sel - [sel] Selection set for which to return bounding box

(defun LM:ssboundingbox ( sel / idx llp ls1 ls2 obj urp )
  (repeat (setq idx (sslength sel))
    (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))))
    (if (and (vlax-method-applicable-p obj 'getboundingbox)
	     (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'llp 'urp))))
	     )
      (setq ls1 (cons (vlax-safearray->list llp) ls1)
	    ls2 (cons (vlax-safearray->list urp) ls2))))
  (if (and ls1 ls2)
    (mapcar '(lambda ( a b ) (apply 'mapcar (cons a b))) '(min max) (list ls1 ls2))))

 

 
Message 12 of 24

renanemeyer
Advocate
Advocate

@ВeekeeCZ 

 

Thanks for the feedback and for the helpfulness
I read the code and it seems to be very useful to solve the problem.
I haven't tested it yet because I'm traveling, arriving at a computer I will test it and bring feedback

0 Likes
Message 13 of 24

Kent1Cooper
Consultant
Consultant

Clarify something for me....  Are your images just illustrating the possible MIRRORing results to show how they can differ from what you want, but you're looking for something to fix the result of an individual MIRROR command?  Or are you actually looking for a routine that will always make all those MIRRORings for a resulting 4 copies of whatever you started with, as appears to be what some posted code does?

Kent Cooper, AIA
Message 14 of 24

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

Clarify something for me....  Are your images just illustrating the possible MIRRORing results ..., but you're looking for something to fix the result of an individual MIRROR command?  ....


If so, attached is a start -- MirrorNoBlockReverse.lsp with its MNBR command.  Since I wouldn't assume the insertion points of all Blocks in a selection would necessarily line up with each other as in your example, I had it find the middle of the collective bounding box of all Blocks, and use that as the reference for Moving or Copying the Blocks [depending on whether you want to Erase the originals] instead of Mirroring them, to preserve their arrangement and scales/rotations.  It Mirrors everything else.  Because your Blocks are not vertically centered on their insertion points, it gets the result across the horizontal axis off in the vertical positioning of the Block parts in relation to the Lines, but it does well with the result across the vertical axis.

Kent1Cooper_0-1630013110993.png

If the circumstances in which you would use such a thing always have the insertion points lined up in a direction parallel or perpendicular to the Mirror axis, it could use a coordinate from an insertion point.  But it would need to also consider the Block rotation angle, and assume those are all the same as well as the lining up of the insertion points.  And for "predictable" results, it might need to be limited to orthogonal Mirror axes.

Kent Cooper, AIA
Message 15 of 24

renanemeyer
Advocate
Advocate

@ВeekeeCZ 
Excellent line that you thought using the bounding box. I really liked this idea, I'll see if I adjust it for my case (it would only be a mirror, vertical or horizontal, it won't always be 4 copies.

 

 


I plan to see the bounding box adjustment after that too, for the case when you have more than one set of blocks.

renanemeyer_0-1630066771716.png

 

renanemeyer_1-1630066782567.png


I appreciate the idea you gave me to try to settle this case (it's an old fight I have)

0 Likes
Message 16 of 24

renanemeyer
Advocate
Advocate

@Kent1Cooper  your lisp "MirrorNoBlockReverse.lsp with its MNBR command" was really good, and the idea of ​​making the mirror preserving the axis was great.
I go to incorporate this idea to my case (which would be the case with more than one set of blocks - On this occasion I'll still have to make some adjustments based on your idea to see if I can fix it)

renanemeyer_0-1630067257261.png

 


Thank you so much 

0 Likes
Message 17 of 24

ВeekeeCZ
Consultant
Consultant

Well, to be fair, I kinda abandoned this bounding box idea because of the issue that Kent explains in his msg no 14.

My code primarily focuses on the horizontal line (the bounding box is used just in case that no horizontal line is found). Do all your block sets include a horizontal line? If yes, I would build the code around this.

 

It's this part:

(and (= "LINE" (cdr (assoc 0 (entget e))))
	     (= (nth 2 (assoc 10 (entget e))) (nth 2 (assoc 11 (entget e))))
	     (setq m (trans (mapcar '/ (mapcar '+ (cdr (assoc 10 (entget e))) (cdr (assoc 11 (entget e)))) '(2 2)) 0 1))))

 

 

Message 18 of 24

Kent1Cooper
Consultant
Consultant

@renanemeyer wrote:

.... my case (which would be the case with more than one set of blocks - .... 


With the approach that my code takes, it would be necessary to do each of those sets of Blocks separately, because the distances to Move or Copy each set would need to be different.  It may be possible, but I think very complicated, to get a routine to figure out the groupings from a single selection, and process each set separately, but the sets would need to have some reliable and definable relationship to check for, such as Insertion points aligned.

Kent Cooper, AIA
Message 19 of 24

renanemeyer
Advocate
Advocate

I understood @ВeekeeCZ 
So, there are two lines of codes (both much better than the initial one I started), but each one covers a case.
The horizontal line will always be present, a practical example would be a square with several of these blocks (and lines) like the image:

renanemeyer_0-1630083863254.png

 


I still thought about the boudingbox, including everything, I was trying to develop something of the two codes, but without success
 

0 Likes
Message 20 of 24

renanemeyer
Advocate
Advocate

I understand @Kent1Cooper 
I saw the line that your code and the @ВeekeeCZ  followed and it was much better than the initial one I had, but in this case it would have to be one per block. I am very grateful, especially for the proposal and idea that you developed
 

0 Likes