Message 1 of 28
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
Hard to describe in words what I'm trying to do. So here is an image.
Solved! Go to Solution.
Hi all,
Hard to describe in words what I'm trying to do. So here is an image.
Solved! Go to Solution.
[The image didn't attach....]
Here is the image.
I have tried blocks, but it becomes tedious.
If the lisp would 1. ask user to select the intersection, 2. then draw and trim as shown in image parametrically..
It would save us a lot of time and effort.
I'm hoping somebody has done something similar I can use or at least get me going in the right direction programming-wise.
You say "parametrically". So what is the parameter? You should probably upload a drawing and be a bit more detailed in your request.
The dimensions would always be 1/4" long from intersection x 1/8" wide ( 1/16" from line). These numbers would by multiplied by the current dimscale....
See image to clarify
How about this approach:
-select lines
-find intersections
-draw a rectangle for each line (representing the fitting outline)
-region the rectangles
-break the lines at the point of intersection and at the point where the fitting ends
That should leave you with a region. If you want it to be a polyline, you can explode the region and join the remaining lines.
Seems like selecting lines, then intersection is more clicks than desired.
If I could get the lines and intersection in one click? Not sure how I would do this..
Also, drawing the rectangles from the two midpoints? Not sure how to do this either?
All this is way out of my league.
I think using LINEWORKSHRINKWRAP and selecting the rectangles instead of region and explode with work.
Ok,
I have the angled rectangle by two clicks (midpoints) figured out.
I have LINEWORKSHRINKWRAP to draw boundary around the rectangles after drawing.
Then erase the rectangles.
I now need to figure out the intersection point and each line direction from picking the intersection?
Hi,
Here is my Drainage Program that might be of interests.
Thank you but we have a long time client that there way of doing things. It's a lot of tedious work, but we would like to keep the client happy.
Just download the program and test it yourself and definitely you would find out how powerful, fast and accurate this program is as soon as you get familiar to it.
If you are offering software solutions to clients, you should at least try and improve your lisp skills. The function you want to create is almost trivial /basic 2D geometric functions/. Here is a starting point for you /barely tested/.
(defun c:test ( / DrawRect line1 line2 len width fuzz line1Start line1End line2Start line2End intersPt line1Ang line2Ang p1 p2 p3 p4) (defun DrawRect (lst) (entmake (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 1)) (mapcar (function (lambda (p) (cons 10 p))) lst))) );defun (while (not line1) (setq line1 (entsel "\nPick first line: "))) (while (not line2) (setq line2 (entsel "\nPick second line: "))) (setq len 80) (setq width 20) (setq fuzz 0.01) (setq line1Start (cdr (assoc 10 (entget (car line1))))) (setq line1End (cdr (assoc 11 (entget (car line1))))) (setq line2Start (cdr (assoc 10 (entget (car line2))))) (setq line2End (cdr (assoc 11 (entget (car line2))))) ;If the 2 lines intersect (if (setq intersPt (inters line1Start line1End line2Start line2End)) (progn (setq line1Ang (angle line1Start line1End)) (setq line2Ang (angle line2Start line2End)) (mapcar '(lambda (line / lineStart lineEnd lineAng) (setq lineStart (car line) lineEnd (cadr line) lineAng (caddr line)) (cond ;Intersection point is on the start point of the line ((equal intersPt lineStart fuzz) (setq p1 (polar intersPt (- lineAng (/ pi 2)) (/ width 2))) (setq p2 (polar (polar intersPt lineAng len) (- lineAng (/ pi 2)) (/ width 2))) (setq p3 (polar (polar intersPt lineAng len) (+ lineAng (/ pi 2)) (/ width 2))) (setq p4 (polar intersPt (+ lineAng (/ pi 2)) (/ width 2))) (DrawRect (list p1 p2 p3 p4)) ) ;Intersection point is on the end point of the line ((equal intersPt lineEnd fuzz) (setq p1 (polar intersPt (- lineAng (/ pi 2)) (/ width 2))) (setq p2 (polar (polar intersPt (+ lineAng pi) len) (- lineAng (/ pi 2)) (/ width 2))) (setq p3 (polar (polar intersPt (+ lineAng pi) len) (+ lineAng (/ pi 2)) (/ width 2))) (setq p4 (polar intersPt (+ lineAng (/ pi 2)) (/ width 2))) (DrawRect (list p1 p2 p3 p4)) ) ;Intersection point is in the middle of the line (T (setq p1 (polar (polar intersPt lineAng len) (- lineAng (/ pi 2)) (/ width 2))) (setq p2 (polar (polar intersPt (+ lineAng pi) len) (- lineAng (/ pi 2)) (/ width 2))) (setq p3 (polar (polar intersPt (+ lineAng pi) len) (+ lineAng (/ pi 2)) (/ width 2))) (setq p4 (polar (polar intersPt lineAng len) (+ lineAng (/ pi 2)) (/ width 2))) (DrawRect (list p1 p2 p3 p4)) ) );cond ) (list (list line1Start line1End line1Ang) (list line2Start line2End line2Ang)) );mapcar )) (princ) );defun
If you spend some time, im sure this can be written in a far more elegant way, in probably less than half the code.
To clarify, I never offered any software to any client. I do a lot of work for them which is tedious. The software is for me to assist me in doing the work. The client knows nothing of my means and methods, only how they want drawings to look when complete.
I'm sorry. I misunderstood your previous post. But still, learning a bit of lisp goes a long way.
Your code works but I ran into a couple things.
What if I have more than two lines? Corners are problematic as well.