Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help cleaning intersecting lines

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
143 Views, 4 Replies

Need help cleaning intersecting lines

;; this routine fails-- why?? -- section noted near end
;; it should work with 2 non-parallel lines (2d!)
;; the lines need not intersect, but may
;; the result should be a near-intersection...
;; 2(!) legs should miss by uniform distance from "apparent" intersection

(defun test ()
(setq blk_xscal 24
blk_size 0.1)
(graphscr)
(setq @1 (getpoint "Select line 1 :")
ss (ssget @1)
)
(if ss
(progn
(setq enam (ssname ss 0)
elist (entget enam)
ly (cdr (assoc 8 elist))
)
(setvar "clayer" ly)
) )
(setq @2(getpoint "\t Select line 2 :"))
(command "._fillet" @1 @2)

;; this part needs rework!

(command "._line" @2 "_per" @1 "")
(command "._erase" "last" "")
(setq yy (entlast))
(setq ins@ (getvar"lastpoint"))
(command "._circle" ins@ (* blk_xscal (abs blk_size)))
(setq xx (entlast))
(command "._trim" xx "" ins@ ins@ ins@ "")

;; above trims P1 only! should trim up to 3 objects crossing center of
circle!
(command "._erase" XX "")
)


;;; thanks in advance!
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

One problem I see is that your circle won't be located at the intersection
of the lines unless they're perpendicular to each other, and your pick
points are precisely on the lines. You're trying to do an awful lot with a
selection of points which are, at best, somewhat arbitrary (no checking to
ensure that they even lie on the lines in question). You might have more
success if you avoided using (command) and analyzed the lines for their
endpoints, then use the (inters) function to find the intersection or
extended intersection, and go from there.
___

"Peter Friedrich" wrote in message
news:D8D71B94634295A3BB63B272C203B069@in.WebX.maYIadrTaRb...
> ;; this routine fails-- why??
Message 3 of 5
Anonymous
in reply to: Anonymous

I don't see why ins@ is not understood---
Entity YY(line) is drawn to establish ins@
Then ins@ is used as the center of the circle---
Now, even when Line 1 and Line 2 ARE perpendicular, ins@ is found only
once(!) for trimming purposes! Why??
(for now, I'm not even concerned about non-perpendiculars, but I saw your
point of Non-intersection at ins@)


"Paul Turvill" wrote in message
news:61279721E31C9046A1B2843E478CDDC0@in.WebX.maYIadrTaRb...
> One problem I see is that your circle won't be located at the intersection
> of the lines unless they're perpendicular to each other, and your pick
> points are precisely on the lines. You're trying to do an awful lot with a
> selection of points which are, at best, somewhat arbitrary (no checking to
> ensure that they even lie on the lines in question). You might have more
> success if you avoided using (command) and analyzed the lines for their
> endpoints, then use the (inters) function to find the intersection or
> extended intersection, and go from there.
> ___
>
> "Peter Friedrich" wrote in message
> news:D8D71B94634295A3BB63B272C203B069@in.WebX.maYIadrTaRb...
> > ;; this routine fails-- why??
>
>
Message 4 of 5
Anonymous
in reply to: Anonymous

I think that since your pickpoints *probably* don't lie precisely on the
lines, your circle isn't exactly where you think it is. In any case,
(command ...) can't be depended to always work the way you think it should
in a LISP routine.

Try the attached code.
___

"Peter Friedrich" wrote in message
news:245E2E9D10CD99B2898639F9D2A6B4B3@in.WebX.maYIadrTaRb...
> I don't see why ins@ is not understood---
> Entity YY(line) is drawn to establish ins@
> Then ins@ is used as the center of the circle---
Message 5 of 5
Anonymous
in reply to: Anonymous

Many thanks--
Seems to do what I need, now to plug in & tailor it...
Really, Paul, I was looking for guidance (which you offered) and maybe a
snip of code to introduce what I should look for... this seems to have
solved my problem. Also, your code pointed out a few details I always
wanted to include ... (redraw (car lin1) 3) , but found too esoteric to
investigate (simple, really!)

Yet another reason to use this NG


"Paul Turvill" wrote in message
news:0D8D13FE7D273791BE87DA8CD22CFD64@in.WebX.maYIadrTaRb...
> I think that since your pickpoints *probably* don't lie precisely on the
> lines, your circle isn't exactly where you think it is. In any case,
> (command ...) can't be depended to always work the way you think it should
> in a LISP routine.
>
> Try the attached code.
> ___
>
> "Peter Friedrich" wrote in message
> news:245E2E9D10CD99B2898639F9D2A6B4B3@in.WebX.maYIadrTaRb...
> > I don't see why ins@ is not understood---
> > Entity YY(line) is drawn to establish ins@
> > Then ins@ is used as the center of the circle---
>
>


----------------------------------------------------------------------------
----


(defun C:CLEAN (/ lin1 lin2 pick1 pick2 gap p1 p2 p3 p4 intpt ext1 ext2 ext3
ext4)
(setq lin1 (entsel "\nPick first line: "))
(redraw (car lin1) 3)
(setq pick1 (cadr lin1)
lin2 (entsel "\nPick second line: "))
(redraw (car lin2) 3)
(setq pick2 (cadr lin2)
gap1 (if gap1 gap1 3.0)
gap (getdist (strcat "\Enter gap length <" (rtos gap1) ">: "))
gap (if gap gap gap1)
gap1 gap
)
(setvar "filletrad" 0)
(command "_.fillet" pick1 pick2)
(setq elist1 (entget (car lin1))
elist2 (entget (car lin2))
p1 (cdr (assoc 10 elist1))
p2 (cdr (assoc 11 elist1))
p3 (cdr (assoc 10 elist2))
p4 (cdr (assoc 11 elist2))
intpt (inters p1 p2 p3 p4 nil)
)
(if (< (setq ext1 (distance p1 intpt))(setq ext2 (distance p2 intpt)))
(setq elist1 (subst (cons 10 (polar p1 (angle p2 p1)(- ext1 gap)))(assoc
10 elist1) elist1))
(setq elist1 (subst (cons 11 (polar p2 (angle p1 p2)(- ext2 gap)))(assoc
11 elist1) elist1))
)
(if (< (setq ext3 (distance p3 intpt))(setq ext4 (distance p4 intpt)))
(setq elist2 (subst (cons 10 (polar p3 (angle p4 p3)(- ext3 gap)))(assoc
10 elist2) elist2))
(setq elist2 (subst (cons 11 (polar p4 (angle p3 p4)(- ext4 gap)))(assoc
11 elist2) elist2))
)
(entmod elist1)
(entmod elist2)
(princ)
)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost