Corner points(p1 p2 p3 p4)

Corner points(p1 p2 p3 p4)

Anonymous
Not applicable
1,138 Views
9 Replies
Message 1 of 10

Corner points(p1 p2 p3 p4)

Anonymous
Not applicable

Sir,

i need a lisp for.................

I have a closed box(lines only), with in i want to create a region and get corner four points (p1 p2 p3 p4) list.

please help me.

Thank you

0 Likes
1,139 Views
9 Replies
Replies (9)
Message 2 of 10

ВeekeeCZ
Consultant
Consultant

(defun c:LinesToRegion (/ s i e p l)

  (princ "Lines required, ")
  (if (setq s (ssget '((0 . "LINE"))))
    (repeat (setq i (sslength s))
      (setq e (entget (ssname s (setq i (1- i)))))
      (foreach k '(10 11)
	(setq p (cdr (assoc k e)))
	(if (not (member p l))
	  (setq l (cons p l))))))
  (if s
    (progn
      (command "_.region" s "")
      (print l)))
  (princ)
  )
0 Likes
Message 3 of 10

Anonymous
Not applicable

Sir,

I have already a rectangle/square with lines, i want to create a region and get X min Y min & X max Y max of corners using autolisp.

0 Likes
Message 4 of 10

john.uhden
Mentor
Mentor

Let's picture a parallelogram with the sides vertical and the right side lower than the left...

xmin and xmax are simple, but

Is ymin the bottom right, and ymax the top left?

Or are you looking at it differently?

     

John F. Uhden

0 Likes
Message 5 of 10

Anonymous
Not applicable

Yes ......sir exactly

0 Likes
Message 6 of 10

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Sir,

I have already a rectangle/square with lines, i want to create a region and get X min Y min & X max Y max of corners using autolisp.


If you're talking about an orthogonally-oriented  rectangle/square, this could get you started -- DrawBoundingBoxMult.lsp, with its DBBM command, available >here<.

 

Load it, call the DBBM command, pick your Lines, and it will draw a Polyline [not a Region, but the conversion can be added easily enough if you need that specifically].  If you remove LL and UR from the localized variables list at the top, they will remain after the routine is done, and LL will give you the min-X and min-Y, and UR will give you the max-X and max-Y.

Kent Cooper, AIA
0 Likes
Message 7 of 10

john.uhden
Mentor
Mentor
You might try joining the lines into a closed polyline and using the
vla-getboundingbox function. We can help you if you need.

John F. Uhden

0 Likes
Message 8 of 10

Sea-Haven
Mentor
Mentor

A quick way is bpoly pick inside then get co-ordinates if you only want cnr pts.

 

 

(setq pt (getpoint "\npick point inside"))
(command "bpoly" pt "" )
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
(command "erase" "l" "")

 

0 Likes
Message 9 of 10

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:
You might try joining the lines into a closed polyline and using the
vla-getboundingbox function. ....

… again, for only an orthogonally-oriented  rectangle.

Kent Cooper, AIA
0 Likes
Message 10 of 10

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....

I have a closed box(lines only), with in i want to create a region and get corner four points (p1 p2 p3 p4) list.

….


Just because many replies are assuming or hoping that you're talking about an orthogonally-oriented rectangle or square, but you apparently haven't replied about that question, please clarify.  And if it might sometimes be at some other angle, do you want the four corners of the box, or the minimum and maximum X and Y coordinates [not the same thing]?  @john.uhden asked "is it A or B" and you replied "Yes," which doesn't answer the question.

Kent Cooper, AIA
0 Likes