Fit Arc Lisp not working in 2017

Fit Arc Lisp not working in 2017

Anonymous
Not applicable
1,804 Views
15 Replies
Message 1 of 16

Fit Arc Lisp not working in 2017

Anonymous
Not applicable

We use a lisp to create an arc tangent to 3 lines and it is not working in 2017

 

I have gone through the lisp and from what I understand it does the following:

 

(defun c:fa ( / pt1 pt2 pt3 cen ent1 ent2 ent3 pt4)

;define functions

 

(setq oldosmode (getvar "OSMODE"))

;save current osmode

 

 

(setvar "OSMODE" (+ 1024 512))

;set osnap to geometric center and nearest

 

(setq oldhighlight (getvar "HIGHLIGHT"))

;save current highlight mode

 

(setvar "HIGHLIGHT" 0)

;turn off highlight

 

(initget 1)

;prevents the user from responding to the request by entering only Enter

 

(setq pt1 (getpoint "\nPoint to first line: "))

;prompts user to select a point on the first line and defines that point as pt1

 

(initget 1)

;prevents the user from responding to the request by entering only Enter


(setq pt2 (getpoint "\nPoint to second line: "))

;prompts user to select a point on the second line and defines that point as pt2
(initget 1)

;prevents the user from responding to the request by entering only Enter


(setq pt3 (getpoint "\nPoint to third line: "))

;prompts user to select a point on the third line and defines that point as pt3

 

(setvar "OSMODE" (+ 1024 256))

;set osnap to geometric center and tangent

 

(command "circle" "3p" pt1 pt2 pt3)

;draws circle 3 point with tangent osnap to pt1 pt2 and pt3

 

(setvar "OSMODE" 0)

;turns osnaps off

 

(setq cen (trans (cdr (assoc 10 (entget (entlast)))) 0 1))

;sets  cen to the center of the circle just drawn

 

(entdel (entlast))

;deletes the circle

 

(setvar "LASTPOINT" cen)

;sets lastpoint vsystem variable to cen (center of circle drawn and deleted)

 

;Everything seems to work up to here

 

(setq
pt1 (osnap pt1 "qui,per")
pt2 (osnap pt2 "qui,per")
pt3 (osnap pt3 "qui,per")
)

;I think this is supposed to redefine pt1, pt2, and pt3 to points on the lines perpendicular to the center of the circle but i don't think it is working

 

(setq
ent1 (ssget pt1)
ent2 (ssget pt2)
ent3 (ssget pt3)
pt4 (polar pt2 (angle cen pt2) (* 2.0 (distance cen pt2)))
)

;this is supposed to define ent1, ent2, and ent3 by selecting the object that passes through pt1, pt2, and pt3 respectively, and then defines pt4 as a point twice the radius of the circle and polar to the angle from the center of the circle to point 2

 

(command "break" ent1 pt1 pt4)

;breaks ent1 at pt1 to pt4


(command "break" ent3 pt3 pt4)

;breaks ent2 at pt1 to pt4


(command "erase" ent2 "")

;erases ent2


(command "arc" pt1 pt2 pt3)

;draws an arc from pt1 through pt2 to pt3


(setvar "HIGHLIGHT" oldhighlight)

;returns highlight to original setting


(setq oldhighlight nil)

;removes oldhighlight value


(setvar "osmode" oldosmode)

;sets osnaps to previous setting


(setq oldosmode nil)

;removes oldosmode value


(princ)
)

 

The lisp routine is below. Can anyone tell me why this isn't working?

 

 

;given three lines, arcs or combination thereof, fits an arc tangent
;to all 3 and trims off excess.

(defun c:fa ( / pt1 pt2 pt3 cen ent1 ent2 ent3 pt4)
(setq oldosmode (getvar "OSMODE"))
(setvar "OSMODE" (+ 1024 512))
(setq oldhighlight (getvar "HIGHLIGHT"))
(setvar "HIGHLIGHT" 0)
(initget 1)
(setq pt1 (getpoint "\nPoint to first line: "))
(initget 1)
(setq pt2 (getpoint "\nPoint to second line: "))
(initget 1)
(setq pt3 (getpoint "\nPoint to third line: "))
(setvar "OSMODE" (+ 1024 256))
(command "circle" "3p" pt1 pt2 pt3)
(setvar "OSMODE" 0)
(setq cen (trans (cdr (assoc 10 (entget (entlast)))) 0 1))
(entdel (entlast))
(setvar "LASTPOINT" cen)
(setq
pt1 (osnap pt1 "qui,per")
pt2 (osnap pt2 "qui,per")
pt3 (osnap pt3 "qui,per")
)
(setq
ent1 (ssget pt1)
ent2 (ssget pt2)
ent3 (ssget pt3)
pt4 (polar pt2 (angle cen pt2) (* 2.0 (distance cen pt2)))
)
(command "break" ent1 pt1 pt4)
(command "break" ent3 pt3 pt4)
(command "erase" ent2 "")
(command "arc" pt1 pt2 pt3)
(setvar "HIGHLIGHT" oldhighlight)
(setq oldhighlight nil)
(setvar "osmode" oldosmode)
(setq oldosmode nil)
(princ)
)

0 Likes
Accepted solutions (1)
1,805 Views
15 Replies
Replies (15)
Message 2 of 16

rkmcswain
Mentor
Mentor

                                            

                                            

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 16

ВeekeeCZ
Consultant
Consultant
Try to remove qui osnap mode which is no longer supported.
Message 4 of 16

marko_ribar
Advisor
Advisor

Here, I've modified it for you...

 

;given three lines or rectangular polyline, arcs or combination thereof, fits an arc tangent
;to all 3 and trims off excess.

(defun c:fa ( / *error* oldosmode oldhighlight pt1 pt2 pt3 cen ent1 ent2 ent3 )

  (defun *error* ( m )
    (if oldosmode
      (setvar "OSMODE" oldosmode)
    )
    (if oldhighlight
      (setvar "HIGHLIGHT" oldhighlight)
    )
    (command "_.UNDO" "_E")
    (if m
      (prompt m)
    )
    (princ)
  )

  (command "_.UNDO" "_M")
  (setq oldosmode (getvar "OSMODE"))
  (setvar "OSMODE" 512)
  (setq oldhighlight (getvar "HIGHLIGHT"))
  (setvar "HIGHLIGHT" 0)
  (initget 1)
  (setq pt1 (getpoint "\nPoint to first line: "))
  (initget 1)
  (setq pt2 (getpoint "\nPoint to second line: "))
  (initget 1)
  (setq pt3 (getpoint "\nPoint to third line: "))
  (setvar "OSMODE" 256)
  (command "_.CIRCLE" "_3P" pt1 pt2 pt3)
  (setvar "OSMODE" 0)
  (setq cen (trans (cdr (assoc 10 (entget (entlast)))) 0 1))
  (entdel (entlast))
  (setvar "LASTPOINT" cen)
  (setq
     pt1 (osnap pt1 "per")
     pt2 (osnap pt2 "per")
     pt3 (osnap pt3 "per")
  )
  (setq
     ent1 (ssget pt1)
     ent2 (ssget pt2)
     ent3 (ssget pt3)
  )
  (command "_.BREAK" ent1 pt1 pt2)
  (command "_.BREAK" ent3 pt3 pt2)
  (if (and (not (eq (ssname ent1 0) (ssname ent2 0))) (not (eq (ssname ent2 0) (ssname ent3 0))))
    (command "_.ERASE" ent2 "")
  )
  (command "_.ARC" pt1 pt2 pt3)
  (*error* nil)
)

HTH., M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 5 of 16

ВeekeeCZ
Consultant
Consultant

...and replace (command) in the *error* function with (command-s)

0 Likes
Message 6 of 16

marko_ribar
Advisor
Advisor

Yes it's better as it is A2017, but it also works and with just (command) function inside *error* for me...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 7 of 16

ВeekeeCZ
Consultant
Consultant

It does not to me. (2018)

 

In case of no error it will go thru (*error* nil) smoothly.

 

But in case of error... like picked 3 points with no solution...

 

***

Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.

 

Or using (command-s)

 

***

Command: _.UNDO Current settings: Auto = On, Control = All, Combine = Yes, Layer = Yes
Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: _E bad argument type: lselsetp nil

0 Likes
Message 8 of 16

marko_ribar
Advisor
Advisor

Yes, but OP stated that he/she is using A2017... And if you really see something beneficial in (command-s), then I suggest you to test it with some speed test routines... :

 

(defun c:test_command-s_vs_vl-cmdf ( / ti )
  (setq ti (car (_vl-times)))
  (repeat 10000
    (vl-cmdf "_.LINE" "_non" '(0.0 0.0 0.0) "_non" '(0.0 0.0 1.0) "")
  )
  (prompt "\nElapsed time for (vl-cmdf) is : ") (princ (rtos (/ (- (car (_vl-times)) ti) 1000.0) 2 50)) (prompt " seconds...")
  (setq ti (car (_vl-times)))
  (repeat 10000
    (command-s "_.LINE" "_non" '(0.0 0.0 0.0) "_non" '(0.0 0.0 1.0) "")
  )
  (prompt "\nElapsed time for (command-s) is : ") (princ (rtos (/ (- (car (_vl-times)) ti) 1000.0) 2 50)) (prompt " seconds...")
  (princ)
)
(defun c:test_vl-cmdf_vs_command ( / ti )
  (setq ti (car (_vl-times)))
  (repeat 10000
    (command "_.LINE" "_non" '(0.0 0.0 0.0) "_non" '(0.0 0.0 1.0) "")
  )
  (prompt "\nElapsed time for (command) is : ") (princ (rtos (/ (- (car (_vl-times)) ti) 1000.0) 2 50)) (prompt " seconds...")
  (setq ti (car (_vl-times)))
  (repeat 10000
    (vl-cmdf "_.LINE" "_non" '(0.0 0.0 0.0) "_non" '(0.0 0.0 1.0) "")
  )
  (prompt "\nElapsed time for (vl-cmdf) is : ") (princ (rtos (/ (- (car (_vl-times)) ti) 1000.0) 2 50)) (prompt " seconds...")
  (princ)
)
(defun c:test_command-s_vs_command ( / ti )
  (setq ti (car (_vl-times)))
  (repeat 10000
    (command "_.LINE" "_non" '(0.0 0.0 0.0) "_non" '(0.0 0.0 1.0) "")
  )
  (prompt "\nElapsed time for (command) is : ") (princ (rtos (/ (- (car (_vl-times)) ti) 1000.0) 2 50)) (prompt " seconds...")
  (setq ti (car (_vl-times)))
  (repeat 10000
    (command-s "_.LINE" "_non" '(0.0 0.0 0.0) "_non" '(0.0 0.0 1.0) "")
  )
  (prompt "\nElapsed time for (command-s) is : ") (princ (rtos (/ (- (car (_vl-times)) ti) 1000.0) 2 50)) (prompt " seconds...")
  (princ)
)

My tests showed to me that the best choice is (vl-cmdf)... I don't have A2018 to test it for (*error* nil), but if it passes that, then IMHO (vl-cmdf) is the best... Beside all this, (command-s) is not supported in earlier versions of AutoCAD... So I didn't made any mistake by putting (command) inside error handler... And I thought speed is here not and issue as OP already used (command) function inside his/her main (c:fa) command function...

 

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 9 of 16

ВeekeeCZ
Consultant
Consultant

@marko_ribar wrote:

Yes, but OP stated that he/she is using A2017... And if you really see something beneficial in (command-s), then I suggest you to test it with some speed test routines... :

 

 


I don't prefer command-s at all. I've just pointed out the well-known issue (very likely to you as well 🙂 that since version A2015 we should not use the plain (command) in the *error* trap function and use the (command-s) instead.

 

See HERE for more.

0 Likes
Message 10 of 16

marko_ribar
Advisor
Advisor

It is not new info for me - I've read it already several times, and I just can't figure out what is improvement in releases A2014+... If there is a difference in logic like it's stated then this can only be something unusual... I mean how can something that necessarily requires single line tokens be better than something that is more flexible in that aspect...

 

How can this be better :

(command-s "_.PLINE" "_non" p1 "_non" p2 ... "_non" pn "")

 

Than this :

(setq ptlst (list p1 p2 ... pn))

(vl-cmdf "_.PLINE")

(foreach p ptlst

  (vl-cmdf "_non" p)

)

(vl-cmdf "")

 

Or this :

(setq ptlst (list p1 p2 ... pn))

(command "_.PLINE")

(mapcar (function (lambda ( x ) (command "_non" x))) ptlst)

(command "")

 

Given the fact that in LISP (List Processing API) we more than often rather use lists (lists of points) than separate variables (point lists) to apply adequate command tokens to...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 11 of 16

dbroad
Mentor
Mentor

The improvement, in theory, is that command-s would reject attempts to use the command function interactively within the *errror* function.  Vl-cmdf might work.  It's also possible just to use other methods, like below.

(defun c:fa (/	      CEN      DOC	ES1	 ES2	  ES3
	     OLDHIGHLIGHT      OLDOSMODE	 PT1	  PT2
	     PT3      PT4
	    )
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (defun *error* (msg)
    (if	msg
      (print msg)
    )
    (mapcar 'setvar
	    '("HIGHLIGHT" "OSMODE")
	    (list oldhighlight oldosmode)
    )
    (vla-EndUndoMark doc)
    (princ)
  )
  (vla-EndUndoMark doc)
  (vla-StartUndoMark doc)
  (setq oldosmode (getvar "OSMODE"))	;save current osmode
  (setvar "OSMODE" (+ 1024 512))	;set osnap to geometric center and nearest
  (setq oldhighlight (getvar "HIGHLIGHT")) ;save current highlight mode
  (setvar "HIGHLIGHT" 0)		;turn off highlight
  (if (and ;;if three objects are selected (no object type filtering)..
	   (setq es1 (entsel "\nPoint to first line: "))
					;prompts user to select a point on the first line and defines that point as pt1
	   (setq es2 (entsel "\nPoint to second line: "))
					;prompts user to select a point on the second line and defines that point as pt2
	   (setq es3 (entsel "\nPoint to third line: "))
					;prompts user to select a point on the third line and defines that point as pt3
      )
    (progn
      (setvar "OSMODE" (+ 1024 256))	;set osnap to geometric center and tangent
      (command "._circle" "_3p" (cadr es1) (cadr es2) (cadr es3))
					;draws circle 3 point with tangent osnap to pt1 pt2 and pt3
      (setvar "OSMODE" 0)		;turns osnaps off
      (setq cen (trans (cdr (assoc 10 (entget (entlast)))) (entlast) 1))
					;sets  cen to the center of the circle just drawn
      (entdel (entlast))		;deletes the circle
      (setvar "LASTPOINT" cen)		;sets lastpoint vsystem variable to cen (center of circle drawn and deleted)
					;Everything seems to work up to here
      (setq
	pt1 (osnap (cadr es1) "_per")	;removed qui, used original pick point
	pt2 (osnap (cadr es2) "_per")	;""
	pt3 (osnap (cadr es3) "_per")	;""
      )
					;changed ssget to (car(entselp...
      (setq
	pt4 (polar pt2 (angle cen pt2) (* 2.0 (distance cen pt2)))
      )
					
      (command "._break" (car es1) pt1 pt4) ;breaks ent1 at pt1 to pt4
      (command "._break" (car es3) pt3 pt4) ;breaks ent3 at pt1 to pt4
      (command "._erase" (car es2) "")	;erases ent2
      (command "._arc" pt1 pt2 pt3)	;draws an arc from pt1 through pt2 to pt3
    )
  )
  (*error* nil)				;Restore variable settings.
)

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

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:
Try to remove qui osnap mode which is no longer supported.

I'm not sure it would solve the problem, but QUIck mode is indeed no longer around [see this thread for some discussion], and it used to be represented by 1024, before there was a geometric-center mode at all.  So I would at least suggest removing both the QUI part of those (osnap) functions and  the 1024 from the OSMODE setting.

 

But it looks to me, in any case, like the resulting Circle wouldn't  always be tangent to the Lines, but would be affected by where you picked  on them, and therefore its center wouldn't be in quite the right place for locations perpendicular from there to the Lines to be the tangent points of the desired Circle.  But I haven't loaded and tested it.  Instead of picking the Lines as objects, and going through the shenanigans of drawing a Circle that's sort-of close, finding locations relative to its center and drawing another, you can do the Circle this way:

 

(command "_.circle" "_3p" "_tan" pause "_tan" pause "_tan" pause)

 

which not only uses a lot less code but will actually be precisely the Circle you want.  I'll leave you to work out the Trimming or Breaking parts, which may be a relatively minor adjustment to the code you already have for that.

Kent Cooper, AIA
0 Likes
Message 13 of 16

marko_ribar
Advisor
Advisor

Yes, Kent is in right, there were lacks in the code I posted... I've changed it according to what Kent suggested and according to discussed things with (command) functions... It seems that for me now it works well - I've put "_tan" tokens inside that circle call and removed highlight thingy - it's not needed anywhere - also my breaking was bad so I reverted to OP's solution with pt4 variable... To my tests till now I had no problems what ever I've drawn... It also should support polylines...

Again, correct me if you see something wrong...

 

;given three lines or rectangular polyline, arcs or combination thereof, fits an arc tangent
;to all 3 and trims off excess.

(defun c:fa ( / *error* adoc oldosmode pt1 pt2 pt3 cen ent1 ent2 ent3 pt4 )

  (vl-load-com)

  (defun *error* ( m )
    (if oldosmode
      (setvar "OSMODE" oldosmode)
    )
    (if adoc
      (vla-endundomark adoc)
    )
    (if m
      (prompt m)
    )
    (princ)
  )

  (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
  (setq oldosmode (getvar "OSMODE"))
  (setvar "OSMODE" 512)
  (initget 1)
  (setq pt1 (getpoint "\nPoint to first line: "))
  (initget 1)
  (setq pt2 (getpoint "\nPoint to second line: "))
  (initget 1)
  (setq pt3 (getpoint "\nPoint to third line: "))
  (vl-cmdf "_.CIRCLE" "_3P" "_tan" pt1 "_tan" pt2 "_tan" pt3)
  (setvar "OSMODE" 0)
  (setq cen (trans (cdr (assoc 10 (entget (entlast)))) (entlast) 1))
  (entdel (entlast))
  (setvar "LASTPOINT" cen)
  (setq
     pt1 (osnap pt1 "_per")
     pt2 (osnap pt2 "_per")
     pt3 (osnap pt3 "_per")
     pt4 (polar cen (angle cen pt2) (* 10 (distance cen pt2)))
  )
  (setq
     ent1 (ssget pt1)
     ent2 (ssget pt2)
     ent3 (ssget pt3)
  )
  (vl-cmdf "_.BREAK" ent1 pt1 pt4)
  (vl-cmdf "_.BREAK" ent3 pt3 pt4)
  (if (and (not (eq (ssname ent1 0) (ssname ent2 0))) (not (eq (ssname ent2 0) (ssname ent3 0))))
    (vl-cmdf "_.ERASE" ent2 "")
  )
  (vl-cmdf "_.ARC" pt1 pt2 pt3)
  (*error* nil)
)

M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 14 of 16

marko_ribar
Advisor
Advisor

Found some more issues at the end of routine... One more revision :

 

;given three lines or polyline, arcs or combination thereof, fits an arc tangent
;to all 3 and trims off excess.

(defun c:fa ( / *error* adoc oldosmode pt1 pt2 pt3 cen ent1 ent2 ent3 )

  (vl-load-com)

  (defun *error* ( m )
    (if oldosmode
      (setvar "OSMODE" oldosmode)
    )
    (if adoc
      (vla-endundomark adoc)
    )
    (if m
      (prompt m)
    )
    (princ)
  )

  (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
  (setq oldosmode (getvar "OSMODE"))
  (setvar "OSMODE" 512)
  (initget 1)
  (setq pt1 (getpoint "\nPoint to first line: "))
  (initget 1)
  (setq pt2 (getpoint "\nPoint to second line: "))
  (initget 1)
  (setq pt3 (getpoint "\nPoint to third line: "))
  (vl-cmdf "_.CIRCLE" "_3P" "_tan" pt1 "_tan" pt2 "_tan" pt3)
  (setvar "OSMODE" 0)
  (setq cen (trans (cdr (assoc 10 (entget (entlast)))) (entlast) 1))
  (entdel (entlast))
  (setvar "LASTPOINT" cen)
  (setq
     pt1 (osnap pt1 "_per")
     pt2 (osnap pt2 "_per")
     pt3 (osnap pt3 "_per")
  )
  (setq
     ent1 (ssget pt1)
     ent2 (ssget pt2)
     ent3 (ssget pt3)
  )
  (cond
    ( (= (cdr (assoc 0 (entget (ssname ent2 0)))) "LINE")
      (vl-cmdf "_.BREAK" ent1 pt1 (car (vl-sort (list (trans (cdr (assoc 10 (entget (ssname ent1 0)))) 0 1) (trans (cdr (assoc 11 (entget (ssname ent1 0)))) 0 1)) (function (lambda ( a b ) (< (distance pt2 a) (distance pt2 b)))))))
      (vl-cmdf "_.BREAK" ent3 pt3 (car (vl-sort (list (trans (cdr (assoc 10 (entget (ssname ent3 0)))) 0 1) (trans (cdr (assoc 11 (entget (ssname ent3 0)))) 0 1)) (function (lambda ( a b ) (< (distance pt2 a) (distance pt2 b)))))))
      (vl-cmdf "_.ERASE" ent2 "")
    )
    ( t
      (vl-cmdf "_.BREAK" ent1 pt1 pt2)
      (setq ent3 (ssget pt3))
      (vl-cmdf "_.BREAK" ent3 pt2 pt3)
    )
  )
  (vl-cmdf "_.ARC" pt1 pt2 pt3)
  (*error* nil)
)

HTH., M.R.

 

I think now that that's it... Sorry for my blunders...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 15 of 16

marko_ribar
Advisor
Advisor
Accepted solution

One more revision... Only now I saw that you are also combining arcs with straight segments... This mod should work I expect with any combination of those 3 (lines, polylines, arcs)...

 

;given three lines or polyline or arcs or any combination thereof, fits an arc tangent
;to all 3 and trims off excess.

(defun c:fa ( / *error* adoc oldosmode pt1 pt2 pt3 cen ent1 ent2 ent3 )

  (vl-load-com)

  (defun *error* ( m )
    (if oldosmode
      (setvar "OSMODE" oldosmode)
    )
    (if adoc
      (vla-endundomark adoc)
    )
    (if m
      (prompt m)
    )
    (princ)
  )

  (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
  (setq oldosmode (getvar "OSMODE"))
  (setvar "OSMODE" 512)
  (initget 1)
  (setq pt1 (getpoint "\nPoint to first line: "))
  (initget 1)
  (setq pt2 (getpoint "\nPoint to second line: "))
  (initget 1)
  (setq pt3 (getpoint "\nPoint to third line: "))
  (vl-cmdf "_.CIRCLE" "_3P" "_tan" pt1 "_tan" pt2 "_tan" pt3)
  (setvar "OSMODE" 0)
  (setq cen (trans (cdr (assoc 10 (entget (entlast)))) (entlast) 1))
  (entdel (entlast))
  (setvar "LASTPOINT" cen)
  (setq
     pt1 (osnap pt1 "_per")
     pt2 (osnap pt2 "_per")
     pt3 (osnap pt3 "_per")
  )
  (setq
     ent1 (ssget pt1)
     ent2 (ssget pt2)
     ent3 (ssget pt3)
  )
  (cond
    ( (and (not (eq (ssname ent1 0) (ssname ent2 0))) (not (eq (ssname ent2 0) (ssname ent3 0))))
      (vl-cmdf "_.BREAK" ent1 pt1 (car (vl-sort (list (trans (vlax-curve-getstartpoint (ssname ent1 0)) 0 1) (trans (vlax-curve-getendpoint (ssname ent1 0)) 0 1)) (function (lambda ( a b ) (< (distance pt2 a) (distance pt2 b)))))))
      (vl-cmdf "_.BREAK" ent3 pt3 (car (vl-sort (list (trans (vlax-curve-getstartpoint (ssname ent3 0)) 0 1) (trans (vlax-curve-getendpoint (ssname ent3 0)) 0 1)) (function (lambda ( a b ) (< (distance pt2 a) (distance pt2 b)))))))
      (vl-cmdf "_.ERASE" ent2 "")
    )
    ( (or (not (eq (ssname ent1 0) (ssname ent2 0))) (not (eq (ssname ent2 0) (ssname ent3 0))))
      (vl-cmdf "_.BREAK" ent1 pt1 (car (vl-sort (list (trans (vlax-curve-getstartpoint (ssname ent1 0)) 0 1) (trans (vlax-curve-getendpoint (ssname ent1 0)) 0 1)) (function (lambda ( a b ) (< (distance pt2 a) (distance pt2 b)))))))
      (setq ent3 (ssget pt3))
      (vl-cmdf "_.BREAK" ent3 pt3 (car (vl-sort (list (trans (vlax-curve-getstartpoint (ssname ent3 0)) 0 1) (trans (vlax-curve-getendpoint (ssname ent3 0)) 0 1)) (function (lambda ( a b ) (< (distance pt2 a) (distance pt2 b)))))))
      (vl-cmdf "_.ERASE" (ssget pt2) "")
    )
    ( t
      (vl-cmdf "_.BREAK" ent1 pt1 pt2)
      (setq ent3 (ssget pt3))
      (vl-cmdf "_.BREAK" ent3 pt2 pt3)
    )
  )
  (vl-cmdf "_.ARC" pt1 pt2 pt3)
  (*error* nil)
)

Once again, sorry I am late, but better ever than never...

M.R.

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

Anonymous
Not applicable

Thanks everybody for the help. I thought it was something to do with the qui osnap.

0 Likes