Divding two points into specifi width and height of rectangle

Divding two points into specifi width and height of rectangle

ganeshgatkul1
Enthusiast Enthusiast
1,766 Views
23 Replies
Message 1 of 24

Divding two points into specifi width and height of rectangle

ganeshgatkul1
Enthusiast
Enthusiast

Please help me for lisp program 

If I select 2 points on screen and it's split int rectangles fo witdh 600 500 450 400 360 350 300 280 275 260 250 225 200 and specific height and widht and hight text into it

0 Likes
Accepted solutions (1)
1,767 Views
23 Replies
Replies (23)
Message 2 of 24

Kent1Cooper
Consultant
Consultant

Welcome to these Forums!

 

An image or small sample drawing would help us understand what you want to do.  Be sure to show where the 2 selected points are in relation to the desired result.

Kent Cooper, AIA
0 Likes
Message 3 of 24

ganeshgatkul1
Enthusiast
Enthusiast

1st i will select 1st point and later 2nd point after that selction specific width and height rectangle has to come Screenshot (5).png

0 Likes
Message 4 of 24

Kent1Cooper
Consultant
Consultant

More criteria are needed.  Why are the two left-end rectangles in the bottom part 200 and 135 units long, rather than 300 and 35, which I would have assumed from both examples starting at the right with as many of the longest length as will fit?  Or why not 280 and 55, or 275 and 60, or 260 and 75, or 250 and 85, or 225 and 110?

 

And is the height always 100 as labeled [though it's clearly not the same in the upper and lower parts of your image]?

Kent Cooper, AIA
0 Likes
Message 5 of 24

ganeshgatkul1
Enthusiast
Enthusiast

in 2nd image heigth of rectangle is 150

i need only specific width rectangle as mention above, width lick 600 500 450 400 360 350 300 280 275 260 250 240 225 200 195 190 185 180 175 170 165 160 155 150 145 140 135 130 125 120 115 110 105 100 only

0 Likes
Message 6 of 24

ganeshgatkul1
Enthusiast
Enthusiast

can you draw above method from left point to right point

 

0 Likes
Message 7 of 24

Kent1Cooper
Consultant
Consultant

@ganeshgatkul1 wrote:

....

i need only specific width rectangle ... width lick 600 500 450 400 360 350 300 280 275 260 250 240 225 200 195 190 185 180 175 170 165 160 155 150 145 140 135 130 125 120 115 110 105 100 only


So now there are many more widths....

 

In your examples, it appears that you fill up the overall width with as many 600-wide rectangles as will fit, before going to those of lower widths.  That suggests to me that you would then want to put in the widest available width that will fit in what remains.  But that's not what you did in the lower one in the image.  Some reason is needed for choosing which size to use when another 600-wide rectangle will not fit.

 

And what should happen if the distance between the selected points cannot be divided into any combination of those specific widths?  For example, 1567 drawing units?

 

And what determines the height of the rectangles?

Kent Cooper, AIA
0 Likes
Message 8 of 24

ganeshgatkul1
Enthusiast
Enthusiast

if 600 width is not fitted then it pick from any width which is early mention

if distance is 1567 then it conver into 1565 and height of rectangle is mention by user

0 Likes
Message 9 of 24

Kent1Cooper
Consultant
Consultant

@ganeshgatkul1 wrote:

if 600 width is not fitted then it pick from any width which is early mention

....


I'm afraid that criterion is too loose.  It would be possible with a random number generator to pick "any width" that will fit, but the choice could be any of them, including the narrowest.  It may be possible to restrict it to choose at random from only those that come sooner in the list, but how many of them should be allowed?

 

And I assume you want the result to include only those widths in a way that adds up to the overall width exactly, if possible.  If what is left after some 600-wide rectangles is 335 units as in your lower example, I assume you would not want it to put in a 300-unit width and have only 35 units remaining.  Rather you would want to use 200+135 as shown there, or some other combination that adds up exactly.  There are a lot of them -- 225+110, 195+140, 190+145, 185+150, 180+155, 175+160, 170+165, 135+100+100, 125+110+100, 120+115+100, 115+115+105 -- but which combination should it use?

 

How it would find a combination with the correct total is also a challenge.  That would be much easier if the intervals between numbers in the list were regular in some way, but they vary all over the map, and not in any regular way -- 100, 50, 50, 40, 10, 50, 20, 5, 15, 10, 10, 15, 25, 5 [and the rest are all 5].

 

It would be much easier if you can give some criteria that are specific.

Kent Cooper, AIA
0 Likes
Message 10 of 24

ganeshgatkul1
Enthusiast
Enthusiast

It choose first 200 and then 135 this type of combination I need

0 Likes
Message 11 of 24

ganeshgatkul1
Enthusiast
Enthusiast

If any odd length occur then pick any odd size in between 195-100 of interval of 5

0 Likes
Message 12 of 24

Kent1Cooper
Consultant
Consultant

@ganeshgatkul1 wrote:

It choose first 200 and then 135 this type of combination I need


Fine, but why 200+135, instead of 225+110, or 195+140, or any of those other combinations?  The leftover distance is not always going to be 335, so some reason will be needed for choosing which next number to use.

Kent Cooper, AIA
Message 13 of 24

Sea-Haven
Mentor
Mentor

I think a better understanding of what it is your drafting would help, what do the rectangles represent, floor tiles, ducts, dog kennels, a real dwg would help. Just way to many variations. Is it a nesting type of solution.

0 Likes
Message 14 of 24

ganeshgatkul1
Enthusiast
Enthusiast

If I choose 225+110 combination it make both odd size rectangles instead I use 200+135 combination so it's make only one rectangles of odd size

0 Likes
Message 15 of 24

ganeshgatkul1
Enthusiast
Enthusiast

Can we use while loop in which rectangles width come as or in order 600 500 450 400 350 300 280 275 260 250 240 230 225 220 210 200 (195-100 in the interval of 5)

0 Likes
Message 16 of 24

Kent1Cooper
Consultant
Consultant

@ganeshgatkul1 wrote:

If I choose 225+110 combination it make both odd size rectangles instead I use 200+135 combination so it's make only one rectangles of odd size


Then you need to define what an "odd" size is.  It's not an odd number -- 110 is even.

Kent Cooper, AIA
0 Likes
Message 17 of 24

ganeshgatkul1
Enthusiast
Enthusiast

For me not in multiple of 50 is considerd as odd size

0 Likes
Message 18 of 24

ganeshgatkul1
Enthusiast
Enthusiast

@Kent1Cooper  please help me 

0 Likes
Message 19 of 24

ronjonp
Advisor
Advisor
Accepted solution

@ganeshgatkul1 wrote:

For me not in multiple of 50 is considerd as odd size


Here'a a start .. you'll need to figure out the logic on what's an odd size even when it's even 😋.

 

 

(defun c:foo (/ a d d2 h l p1 p2 r)
  ;; RJP » 2021-08-17
  ;; Divides a distance with a preset list of allowable lengths
  (cond
    ((and (progn (initget 6) (setq h (getreal "\nEnter height: ")))
	  (setq p1 (getpoint "\nPick first point"))
	  (setq p2 (getpoint p1 "\nPick second point"))
     )
     (if (< (car p1) (car p2))
       (setq a	p1
	     p1	p2
	     p2	a
       )
     )
     (setq l  '(600   500   450	  400	360   350   300	  280	275   260   250	  240	225   200
		195   190   185	  180	175   170   165	  160	155   150   145	  140	135   130
		125   120   115	  110	105   100
	       )
	   d  (abs (- (car p1) (car p2)))
	   d2 0
	   r  0
     )
     (while r
       (cond ((setq r (vl-some '(lambda	(x)
				  (if (<= x (- d d2))
				    x
				  )
				)
			       l
		      )
	      )
	      (princ (strcat "\nInterim Length: " (vl-princ-to-string r)))
	      (setq d2 (+ d2 r))
	      (entmake (list '(0 . "TEXT")
			     '(100 . "AcDbEntity")
			     '(67 . 0)
			     (cons 8 (vl-princ-to-string r))
			     '(100 . "AcDbText")
			     (cons 10 (mapcar '- p1 (list (/ r 2) (/ h 2) 0)))
			     (cons 40 (/ h 2))
			     (cons 1 (strcat (vl-princ-to-string r) " X " (vl-princ-to-string h)))
			     '(50 . 0.)
			     '(41 . 1.)
			     '(51 . 0.)
			     '(71 . 0)
			     '(72 . 1)
			     (cons 11 (mapcar '- p1 (list (/ r 2) (/ h 2) 0)))
			     '(100 . "AcDbText")
			     '(73 . 2)
		       )
	      )
	      (entmake (list '(0 . "LWPOLYLINE")
			     '(100 . "AcDbEntity")
			     '(67 . 0)
			     (cons 8 (vl-princ-to-string r))
			     '(100 . "AcDbPolyline")
			     '(90 . 4)
			     '(70 . 1)
			     (cons 10 p1)
			     (cons 10 (setq p1 (mapcar '- p1 (list r 0 0))))
			     (cons 10 (setq a (mapcar '- p1 (list 0 h 0))))
			     (cons 10 (mapcar '+ a (list r 0 0)))
		       )
	      )
	     )
       )
     )
     (princ (strcat "\nOddball end length: " (vl-princ-to-string (- d d2))))
    )
  )
  (princ)
)

2021-08-17_13-10-15.gif

 

 

 

0 Likes
Message 20 of 24

ganeshgatkul1
Enthusiast
Enthusiast

how to reduce text height to 100 or 90 rotate 90 degree

0 Likes