reverse selected arcs

reverse selected arcs

Anonymous
Not applicable
1,638 Views
5 Replies
Message 1 of 6

reverse selected arcs

Anonymous
Not applicable

Hi there again. I am novice to Lisp. I need small easy lisp: with one click -to reverse selected 2D arcs. It is easy, but not for me -LOOK at the picture.

If there is a solution or someone can make it...Thank You...

0 Likes
Accepted solutions (1)
1,639 Views
5 Replies
Replies (5)
Message 2 of 6

marko_ribar
Advisor
Advisor
Accepted solution

Here...

 

(defun c:revarcs ( / *error* *adoc* ss i arc p1 p2 )
  (vl-load-com)
  (defun *error* ( m )
    (vla-endundomark *adoc*)
    (if m
      (prompt m)
    )
    (princ)
  )
  (vla-startundomark (setq *adoc* (vla-get-activedocument (vlax-get-acad-object))))
  (setq ss (ssget "_:L" '((0 . "ARC"))))
  (repeat (setq i (sslength ss))
    (setq arc (ssname ss (setq i (1- i))))
    (setq p1 (vlax-curve-getstartpoint arc))
    (setq p2 (vlax-curve-getendpoint arc))
    (vla-mirror (vlax-ename->vla-object arc) (vlax-3d-point p1) (vlax-3d-point p2))
    (entdel arc)
  )
  (*error* nil)
)

HTH, M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 3 of 6

john.uhden
Mentor
Mentor
If the figure is a polyline, all you have to do is reverse the sign of each bulge.

John F. Uhden

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant

Assuming they're Arc entities, and not parts of a Polyline [since not all are reversed, as presumably they would be with a routine that reverses the sign on all bulge factors of a Polyline], here's a slightly-less-code [in the "core" functioning, apart from error handling and undo wrapping that can be added, etc.] version:

(defun C:RVA (/ ss n arc); = ReVerseArc(s)
  (prompt "\nTo ReVerse Arc(s),")
  (if (setq ss (ssget "_:L" '((0 . "ARC"))))
    (repeat (setq n (sslength ss))
      (command "_.mirror" (setq arc (ssname ss (setq n (1- n)))) ""
        "_none" (vlax-curve-getStartPoint arc) "_none" (vlax-curve-getEndPoint arc)
        "_yes"
      ); command
    ); repeat
  ); if
  (princ)
); defun
(vl-load-com); if needed [outside command definition so it runs only at loading]

If they are parts of a Polyline, and you need to reverse only some of them, that could probably be done, but would be more complicated.

Kent Cooper, AIA
0 Likes
Message 5 of 6

john.uhden
Mentor
Mentor
I like it! But what's the problem with calling (vl-load-com) multiple times? It can't be a performance issue because repeating it 100,000 times takes only about 1 second. Hmmm... presuming each run takes 4 seconds including object selection, then 100,000 runs would take you 111 hours which means you'd be missing your train ride home by over 4 days. So one second isn't very meaningful.

John F. Uhden

0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:
I like it! But what's the problem with calling (vl-load-com) multiple times? ....

Not a "problem" or a performance issue -- it just seems like a waste to have that run redundantly every time you call the command.

 

BY THE WAY, @Anonymous, if those lines are Line entities, and you'd like to Fillet them with that reversed Arc direction in the first place, rather than use regular Fillet and then reverse them, check out FilletLinesReverse.lsp with its FLR command, available here.  But it does require Lines specifically, and won't work on other things such as Polylines.

Kent Cooper, AIA
0 Likes