script that writes length and width of all rectangles in a drawing

script that writes length and width of all rectangles in a drawing

Anonymous
Not applicable
679 Views
5 Replies
Message 1 of 6

script that writes length and width of all rectangles in a drawing

Anonymous
Not applicable

I am beginner in lisp and I would like to know if it is possible to make a script that writes length and width of all rectangles in the entire drawing. I have tried to make the following and it does not work. Could anyone help? 

0 Likes
Accepted solutions (1)
680 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

Without trying it or evaluating details like parentheses matching, etc., I have a couple of comments:

 

Post the definition of the (css_enl) function.  [And maybe (Mid_P), though I can imagine what that does.]

 

This could be a problem:
  (cons 10 TIP) (cons 11 TIP)

The 10-code and 11-code entries can't be the same for MC-justified Text.  11 is the insertion point in the middle, and 10 is the left end of the base-line, which is only a resultant from the combination of 11 and the height and font and content and width factor of the Text.  Omit the 10 entry.

 

If you want to label only rectangles, not parallelograms, you can add a check for whether the diagonals are equal:

  (equal (distance P1 P3) (distance P2 P4) 1E-3)

Kent Cooper, AIA
0 Likes
Message 3 of 6

Anonymous
Not applicable

(Defun css_EnL (ss / L i ) (setq i 0 @u "SS~EnL" )
(repeat (if ss (ssLength ss) 0 ) ; errors on non ss
(setq L (cons (ssname ss i ) L )
i (1+ i) ) ) L ) ; ed

this is the definition of the css_enl function. thanks for the 10-code explanation. I removed that part  but I think the script is still wrong

0 Likes
Message 4 of 6

Anonymous
Not applicable
(defun mid_P ( / pt1 pt2)
(setq pt1 (getpoint "\nSelect first point: "))
(setq pt2 (getpoint "\nSelect second point: "))
(polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2.0))
)
and this is mid_p i forgot to mention
0 Likes
Message 5 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:
(defun mid_P ( / pt1 pt2)
  (setq pt1 (getpoint "\nSelect first point: "))
  (setq pt2 (getpoint "\nSelect second point: "))
  (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2.0))
)
....

That's written to ask the User to pick points to find the midpoint between.  As used in the larger routine, you need a version that's written to take arguments of existing known points instead:

 

(defun mid_P (pt1 pt2)
  (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2.0))
)

 

EDIT:

Make that version under a different name, and use that name in the larger routine, if you use your original version of it in other contexts and still need the ask-the-User-for-points approach.  [In new-enough versions of AutoCAD, you don't need such a thing -- use the M2P / MTP Object Snap mode.]

 

If you do that, does the larger routine work?  I looked more closely, and though there are things about it that I would do more simply, I don't see any other reason that it shouldn't work with a new midpoint-calculating function.

Kent Cooper, AIA
0 Likes
Message 6 of 6

Anonymous
Not applicable

it now works. thanks a lot

0 Likes