Mirror and Copy

Mirror and Copy

jorgearone_inssitu
Enthusiast Enthusiast
1,342 Views
11 Replies
Message 1 of 12

Mirror and Copy

jorgearone_inssitu
Enthusiast
Enthusiast

hello everyone
I wanted to know if this type of work is possible using dynamic blocks or some lisp
I have some blocks aligned in a line (a-b)

jorgearone_inssitu_0-1710927247457.png

and what I would like is for it to be reflected in the line (c-d)

selecting the straight line as axis (c-d)

jorgearone_inssitu_1-1710927294082.png

 

What I commonly do is make a mirror, but I have to first select the midpoint between those two lines, then draw my axis so that it comes out aligned, another thing is that the text comes out backwards.

jorgearone_inssitu_2-1710927366215.png

 

0 Likes
Accepted solutions (4)
1,343 Views
11 Replies
Replies (11)
Message 2 of 12

Kent1Cooper
Consultant
Consultant

@jorgearone_inssitu wrote:

.... the text comes out backwards.


For that, read about the MIRRTEXT System Variable, but even that won't do it if they're plain Text in ordinary Blocks.

Kent Cooper, AIA
0 Likes
Message 3 of 12

jorgearone_inssitu
Enthusiast
Enthusiast

I know about MIRRTEXT, 

I would like is for it to be reflected 

selecting the straight line as axis (c-d)

0 Likes
Message 4 of 12

komondormrex
Mentor
Mentor
Accepted solution

hey there,

you can force the text to mirror regardless of mirrtext variable if you fix it inside the block with fix geometric constraint.

komondormrex_0-1710999823261.png

 

komondormrex_1-1710941882243.png

 

0 Likes
Message 5 of 12

dbroad
Mentor
Mentor

 

 

;;;marko_ribar
(DEFUN average	(lst)
  (MAPCAR '(LAMBDA (x) (/ x (LENGTH lst)))
	  (APPLY 'MAPCAR (CONS '+ lst)))
  )

(DEFUN cdrs  (key lst / pr)
  (IF
    (SETQ pr (ASSOC key lst))
     (CONS (CDR pr)
	   (cdrs key (CDR (MEMBER pr lst))))))


(DEFUN c:mirrormid  (/ bl nl p1 p2 ss ss2)

  (IF
    (AND
      (PRINC "\nSelect object to mirror.")
      (SETQ ss (SSGET))
      (PRINC "\nSelect both baselines.")
      (SETQ ss2 (SSGET '((0 . "line"))))
      (>= (SSLENGTH ss2) 2)
      (SETQ bl (ENTGET (SSNAME ss2 0));baseline
	    nl (ENTGET (SSNAME ss2 1));new line
	    p1 (average (cdrs 10 (APPEND bl nl)));mid p1
	    p2 (average (cdrs 11 (APPEND bl nl)));mid p2

	    ))
            (COMMAND "_.mirror" ss "" p1 p2 "_n"));mirror without delete
            )
  (PRINC)
  )

 

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 6 of 12

Kent1Cooper
Consultant
Consultant
Accepted solution

@jorgearone_inssitu wrote:

....

What I commonly do is make a mirror, but I have to first select the midpoint between those two lines, then draw my axis ....


Since c-d is not the axis you want to mirror across, yes, you need an axis halfway between the two Lines.  But there's certainly no need to draw the axis!  And no routine is needed.  In MIRROR, select the stuff, then for the ends of the mirror line, use middle-of-two-points Object Snap [M2P or MTP typed abbreviation, or the "Mid Between 2 Points" item in the shift+right-click list] to get the halfway points between a & c and between b & d.  Either that, or something like @dbroad 's routine, which requires you to select both Lines anyway, because c-d alone isn't enough to tell the story.

Kent Cooper, AIA
0 Likes
Message 7 of 12

Kent1Cooper
Consultant
Consultant

@dbroad wrote:
....
            (COMMAND "_.mirror" ss "" p1 p2 "_n"));mirror without delete
....

[That has an extra right parenthesis at the end.]

 

I would also point out that if a-b and c-d are nicely lined up and parallel as appears in the images, but happen to have been drawn in opposite directions, then p1 and p2 will be the same, causing an error.

Kent Cooper, AIA
0 Likes
Message 8 of 12

dbroad
Mentor
Mentor
Accepted solution

Good points.  Try this out. Might be a simpler way

 

 

 

;;;marko_ribar
(DEFUN average	(lst)
  (MAPCAR '(LAMBDA (x) (/ x (LENGTH lst)))
	  (APPLY 'MAPCAR (CONS '+ lst)))
  )

(DEFUN c:mirrormid  (/ bl bp1 bp2 ip nl np1 np2 p1 p2 ss ss2)
  (IF
    (AND
      (PRINC "\nSelect object to mirror.")
      (SETQ ss (SSGET))
      (PRINC "\nSelect both baselines.")
      (SETQ ss2 (SSGET '((0 . "line"))))
      (>= (SSLENGTH ss2) 2)
      (SETQ bl	(ENTGET (SSNAME ss2 0))			    ;baseline
	    bp1	(CDR (ASSOC 10 bl))
	    bp2	(CDR (ASSOC 11 bl))
	    nl	(ENTGET (SSNAME ss2 1))			    ;new line
	    np1	(CDR (ASSOC 10 nl))
	    np2	(CDR (ASSOC 11 nl)))
      (IF (SETQ ip (INTERS bp1 bp2 np1 np2 nil))
	(PROGN
	  (SETQ	p1 (IF (< (DISTANCE ip bp1) (DISTANCE ip bp2))
		     bp2
		     bp1))
	  (SETQ	p2 (IF (< (DISTANCE ip np1) (DISTANCE ip np2))
		     np2
		     np1))
	  (SETQ p2 (average (LIST p1 p2)))
	  (SETQ p1 ip)
	  )
	(IF (< (DISTANCE bp1 np1) (DISTANCE bp1 np2))
	  (SETQ
	    p1 (average (LIST bp1 np1))			    ;mid p1
	    p2 (average (LIST bp2 np2))			    ;mid p2
	    )
	  (SETQ
	    p1 (average (LIST bp1 np2))
	    p2 (average (LIST bp2 np1))
	    ))
	))

     (COMMAND "_.mirror" ss "" "_non" p1 "_non" p2 "_n")    ;mirror without delete

     )
  (PRINC)
  )

 

 

 

 M 

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 9 of 12

jorgearone_inssitu
Enthusiast
Enthusiast
Thank you very much for the lisp, one last question, what if it were a polyline? It only works with lines.
0 Likes
Message 10 of 12

komondormrex
Mentor
Mentor
Accepted solution

hey there,

check the code below. given the lines a-b and c-d are parallel, select source blocks, source mirror axis, target mirror axis...

 

(defun c:mirror_copy (/ source_list source_mirr_data source_point source_mirr_point target_mirr_ename target_point source_mirror)
	(setq source_list (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "insert")))))))
		  source_mirr_data (entsel "\nPick source mirror axis: ")
		  source_point (vlax-curve-getclosestpointto (setq source_mirr_ename (car source_mirr_data)) (cadr source_mirr_data))
		  source_mirr_point (polar source_point (angle '(0 0) (vlax-curve-getfirstderiv source_mirr_ename (vlax-curve-getparamatpoint source_mirr_ename source_point))) 1)  
		  target_mirr_ename (car (entsel "\nPick target mirror axis: "))
		  target_point (vlax-curve-getclosestpointto target_mirr_ename source_point) 
	)
	(foreach source source_list 
		(setq source_mirror (vla-mirror source (vlax-3d-point source_point) (vlax-3d-point source_mirr_point)))
		(vla-move source_mirror (vlax-3d-point source_point) (vlax-3d-point target_point))
	)
	(princ)
)

 

0 Likes
Message 11 of 12

jorgearone_inssitu
Enthusiast
Enthusiast
Thank you very much, it works perfectly.
0 Likes
Message 12 of 12

jorgearone_inssitu
Enthusiast
Enthusiast

Thank you very much, it works perfectly.

0 Likes