AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

Reply
Valued Contributor
72 Posts
1 Kudo
Registered: ‎03-31-2014
Post 1 of 8
Accepted Solution

Flip objects over arc

245 Views, 7 Replies
05-15-2014 07:15 AM

I am attempting to flip a bunch of items over an arc.  I don't want to flip the arc however.  Currently I have an arc and everything is drawn on the top of the arc, mirroring the radius of the arc.  However I need all of this to run along the bottom of the arc now.  I understand there will probably be some spacing issues I need to correct but I was wondering if there is a way I could essentiall mirror these objects or flip them to the other side of the arc?

 

Thanks!

A quickie, mildly tested:

 

;;  MirrorAcrossObject.lsp [command name = MAO]
;;  To Mirror selected object(s) across any appropriate object as a mirror
;;    path or axis.  Mirrors each object across the point on the axis object
;;    closest to the middle of the mirrored object's bounding box.
;;  Kent Cooper, 15 May 2014
(vl-load-com)
(defun C:MAO ; = Mirror Across Object
  (/ mobj ss inc ent mid mobjnea)
  (prompt "\nTo Mirror objects Across another Object,")
  (setq
    ss (ssget ":L")
    mobj (vlax-ename->vla-object (car (entsel "\nSelect object to Flip things across:")))
  ); setq
  (repeat (setq inc (sslength ss))
    (setq ent (ssname ss (setq inc (1- inc))))
    (vla-getboundingbox (vlax-ename->vla-object ent) 'minpt 'maxpt)
    (setq
      mid (mapcar '/ (mapcar '+ (vlax-safearray->list minpt) (vlax-safearray->list maxpt)) '(2 2 2))
      mobjnea (vlax-curve-getClosestPointTo mobj mid)
    ); setq
    (command "_.mirror" ent ""
      mobjnea ; first point of mirror axis
      (polar ; point in tangent direction at nearest point on mobj
        mobjnea
        (angle '(0 0 0) (vlax-curve-getFirstDeriv mobj (vlax-curve-getParamAtPoint mobj mobjnea)))
        1
      ); polar
      "_yes" ; delete source object
    ); command
  ); repeat
  (princ)
); defun -- C:MAO
(prompt "\nType MAO to Mirror object(s) Across another Object.")

 

Since the operation would be the same, it works not only with an Arc but also with a whole mess of other object types as the mirroring axis [Line, Circle, Polyline, Ellipse, Spline, Ray, Xline, etc.].  It can use an error handler, object-type restrictions on selecting the Mirroring axis object, and various other bells and whistles.


ryled wrote:

...I select the line I wish to flip over and get the error,

 

"Points must be distinct

; error: Function cancelled"

...


Another thing it could use, that I forgot to include, is object-snap control.  I suspect you have some running Osnap mode(s) on.  Either build in turning running Osnap off [preferably saving its initial value and restoring it later], or just change these lines:

 

    (command "_.mirror" ent ""
      mobjnea ; first point of mirror axis
      (polar ; point in tangent direction at nearest point on mobj

 

to these, to override Osnap for just those two points:

 

    (command "_.mirror" ent ""
      "_none" mobjnea ; first point of mirror axis
      "_none" (polar ; point in tangent direction at nearest point on mobj

 

It also occurs to me that it ought to have the option to keep the selected Mirrored objects or not, rather than always not keeping them as it now stands [it sounded like that's what you were doing].  I'll work that in, and the other stuff, and post an update some time fairly soon.

*Expert Elite*
6,025 Posts
669 Kudos
Registered: ‎09-13-2004
Post 2 of 8

Re: Flip objects over arc

05-15-2014 07:38 AM in reply to: ryled

ArcMirror.png

 

That would certainly be doable.

Kent Cooper
Valued Contributor
72 Posts
1 Kudo
Registered: ‎03-31-2014
Post 3 of 8

Re: Flip objects over arc

05-15-2014 08:14 AM in reply to: Kent1Cooper

Yes that is what I'm looking for!

*Expert Elite*
6,025 Posts
669 Kudos
Registered: ‎09-13-2004
Post 4 of 8

Re: Flip objects over arc

05-15-2014 12:14 PM in reply to: ryled

A quickie, mildly tested:

 

;;  MirrorAcrossObject.lsp [command name = MAO]
;;  To Mirror selected object(s) across any appropriate object as a mirror
;;    path or axis.  Mirrors each object across the point on the axis object
;;    closest to the middle of the mirrored object's bounding box.
;;  Kent Cooper, 15 May 2014
(vl-load-com)
(defun C:MAO ; = Mirror Across Object
  (/ mobj ss inc ent mid mobjnea)
  (prompt "\nTo Mirror objects Across another Object,")
  (setq
    ss (ssget ":L")
    mobj (vlax-ename->vla-object (car (entsel "\nSelect object to Flip things across:")))
  ); setq
  (repeat (setq inc (sslength ss))
    (setq ent (ssname ss (setq inc (1- inc))))
    (vla-getboundingbox (vlax-ename->vla-object ent) 'minpt 'maxpt)
    (setq
      mid (mapcar '/ (mapcar '+ (vlax-safearray->list minpt) (vlax-safearray->list maxpt)) '(2 2 2))
      mobjnea (vlax-curve-getClosestPointTo mobj mid)
    ); setq
    (command "_.mirror" ent ""
      mobjnea ; first point of mirror axis
      (polar ; point in tangent direction at nearest point on mobj
        mobjnea
        (angle '(0 0 0) (vlax-curve-getFirstDeriv mobj (vlax-curve-getParamAtPoint mobj mobjnea)))
        1
      ); polar
      "_yes" ; delete source object
    ); command
  ); repeat
  (princ)
); defun -- C:MAO
(prompt "\nType MAO to Mirror object(s) Across another Object.")

 

Since the operation would be the same, it works not only with an Arc but also with a whole mess of other object types as the mirroring axis [Line, Circle, Polyline, Ellipse, Spline, Ray, Xline, etc.].  It can use an error handler, object-type restrictions on selecting the Mirroring axis object, and various other bells and whistles.

Kent Cooper
Valued Contributor
72 Posts
1 Kudo
Registered: ‎03-31-2014
Post 5 of 8

Re: Flip objects over arc

05-15-2014 02:01 PM in reply to: Kent1Cooper

I appreciate you taking the time to help me here and sorry it took a bit to get back to you.  I ran the lisp and am having a bit of a problem.  After selecting the objects I select the line I wish to flip over and get the error,

 

"Points must be distinct

; error: Function cancelled"

 

It then sends the objects north of the flip line. 

 

Thanks again!

*Expert Elite*
6,025 Posts
669 Kudos
Registered: ‎09-13-2004
Post 6 of 8

Re: Flip objects over arc

05-15-2014 03:12 PM in reply to: ryled

ryled wrote:

...I select the line I wish to flip over and get the error,

 

"Points must be distinct

; error: Function cancelled"

...


Another thing it could use, that I forgot to include, is object-snap control.  I suspect you have some running Osnap mode(s) on.  Either build in turning running Osnap off [preferably saving its initial value and restoring it later], or just change these lines:

 

    (command "_.mirror" ent ""
      mobjnea ; first point of mirror axis
      (polar ; point in tangent direction at nearest point on mobj

 

to these, to override Osnap for just those two points:

 

    (command "_.mirror" ent ""
      "_none" mobjnea ; first point of mirror axis
      "_none" (polar ; point in tangent direction at nearest point on mobj

 

It also occurs to me that it ought to have the option to keep the selected Mirrored objects or not, rather than always not keeping them as it now stands [it sounded like that's what you were doing].  I'll work that in, and the other stuff, and post an update some time fairly soon.

Kent Cooper
Valued Contributor
72 Posts
1 Kudo
Registered: ‎03-31-2014
Post 7 of 8

Re: Flip objects over arc

05-15-2014 03:17 PM in reply to: Kent1Cooper

Turining off running object snaps did what I needed.  Thanks a lot!

*Expert Elite*
6,025 Posts
669 Kudos
Registered: ‎09-13-2004
Post 8 of 8

Re: Flip objects over arc

05-16-2014 12:09 PM in reply to: Kent1Cooper

Kent1Cooper wrote:

ryled wrote:

...I select the line I wish to flip over and get the error, ....


Another thing it could use, that I forgot to include, is object-snap control.  .... 

It also occurs to me that it ought to have the option to keep the selected Mirrored objects or not, rather than always not keeping them as it now stands [it sounded like that's what you were doing].  I'll work that in, and the other stuff, and post an update some time fairly soon.


Here's a fully-developed version, MirrorAcrossObject.lsp with its MAO command, with all the bells and whistles I could think to incorporate [see comments at the top of the file].


MirrorAcrossObject.png

Kent Cooper
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!