Author Topic: [XDrX-PlugIn(97)] TopoL(2) -- Polygon acute angle check  (Read 341 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Bull Frog
  • Posts: 492
[XDrX-PlugIn(97)] TopoL(2) -- Polygon acute angle check
« on: January 18, 2024, 10:32:22 PM »
 
Code - Auto/Visual Lisp: [Select]
  1. (defun c:xdtb_topochksharpangle
  2.        (/ dis e i inx lst np nums pt result ss var verts x)
  3.   (defun _callback (dynpt)
  4.     (redraw)
  5.     (mapcar '(lambda (x) (xdrx_grdraw 2 0 x 4 4)) result)
  6.   )
  7.   (xdrx_begin)
  8.   (if (not xd_var_global_angletol)
  9.     (setq xd_var_global_angletol 5)
  10.   )
  11.   (if (setq var (getreal (xdrx_prompt
  12.                            (xdrx-string-formatex
  13.                              (xdrx-string-multilanguage
  14.                                "\n&#36755;&#20837;&#38160;&#35282;(&#24230;)<%.1f>"
  15.                                "\nEnter acute angle (degree)<%.1f>"
  16.                              )
  17.                              xd_var_global_angletol
  18.                            )
  19.                            t
  20.                          )
  21.                 )
  22.       )
  23.     (setq xd_var_global_angletol var)
  24.   )
  25.   (setq #ang (* pi (/ xd_var_global_angletol 180.0)))
  26.   (if (setq ss (xdrx_ssget
  27.                  (xdrx-string-multilanguage
  28.                    "\n&#36873;&#25321;&#35201;&#26816;&#26597;&#30340;&#22810;&#27573;&#32447;<&#36864;&#20986;>:"
  29.                    "\nSelect polylines to inspect <Exit>:"
  30.                  )
  31.                  '((0 . "*polyline"))
  32.                )
  33.       )
  34.     (progn
  35.       (setq result nil)
  36.       (mapcar '(lambda (x)
  37.                  (setq nums (xdrx_getpropertyvalue x "numverts"))
  38.                  (setq i 0)
  39.                  (repeat nums
  40.                    (setq np (xdrx_getpropertyvalue x "angle" i))
  41.                    (if (< np #ang)
  42.                      (setq
  43.                        result (cons (xdrx_getpropertyvalue x "pointat" i)
  44.                                     result
  45.                               )
  46.                      )
  47.                    )
  48.                    (setq i (1+ i))
  49.                  )
  50.                )
  51.               (xdrx_pickset->ents ss)
  52.       )
  53.       (if result
  54.         (progn
  55.           (xdrx_prompt
  56.             (xdrx-string-formatex
  57.               (xdrx-string-multilanguage
  58.                 "\n>>&#38160;&#35282;&#26816;&#26597;&#23436;&#27605;.\n  &#20849;&#21457;&#29616; %d &#20010;&#22810;&#36793;&#24418;&#39030;&#28857;&#22841;&#35282;&#23567;&#20110; %.1f &#24230;."
  59.                 "\n>>Acute angle check completed.\n A total of %d polygon vertices with angles less than %.1f degrees were found."
  60.               )
  61.               (length result)
  62.               xd_var_global_angletol
  63.             )
  64.           )
  65.           (xdrx_pointmonitor "_callback")
  66.           (xdrx_initget "F")
  67.           (if (setq pt
  68.                      (getpoint
  69.                        (xdrx-string-multilanguage
  70.                          "\n&#32553;&#25918;&#23631;&#24149;&#26597;&#30475;[&#29983;&#25104;&#22278;(F)]:"
  71.                          "\nZoom the screen to view [Generate Circle(F)]:"
  72.                        )
  73.                      )
  74.               )
  75.             (progn
  76.               (cond ((= pt "F")
  77.                      (setq dis (xd::doc:getpickboxheight))
  78.                      (if (setq var
  79.                                 (getreal
  80.                                   (xdrx_prompt
  81.                                     (xdrx-string-formatex
  82.                                       (xdrx-string-multilanguage
  83.                                         "\n&#22278;&#21322;&#24452;<%.1f>"
  84.                                         "\nCircle radius<%.1f>:"
  85.                                       )
  86.                                       dis
  87.                                     )
  88.                                     t
  89.                                   )
  90.                                 )
  91.                          )
  92.                        (setq dis var)
  93.                      )
  94.                      (redraw)
  95.                      (xdrx_entity_setproperty
  96.                        (xdrx_circle_make (cons dis result))
  97.                        "color"
  98.                        2
  99.                        "layer"
  100.                        (xdrx-string-multilanguage
  101.                          "&#25299;&#25169;&#26680;&#26597;"
  102.                          "Topology Verification"
  103.                        )
  104.                      )
  105.                     )
  106.               )
  107.             )
  108.           )
  109.           (xdrx_pointmonitor)
  110.         )
  111.         (xdrx_prompt
  112.           (xdrx-string-formatex
  113.             (xdrx-string-multilanguage
  114.               "\n&#38160;&#35282;&#26816;&#26597;&#23436;&#27605;&#65292;&#27809;&#21457;&#29616;&#35282;&#24230;&#23567;&#20110; %.1f &#30340;&#38160;&#35282;."
  115.               "\nAcute angle check completed, no acute angle smaller than %.1f was found."
  116.             )
  117.             xd_var_global_angletol
  118.           )
  119.         )
  120.       )
  121.     )
  122.   )
  123.   (xdrx_end)
  124.   (princ)
  125. )

 edit Kerry : [ code=cadlisp-7 ]
« Last Edit: January 19, 2024, 06:39:47 PM by kdub_nz »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

xdcad

  • Bull Frog
  • Posts: 492
Re: [XDrX-PlugIn(97)] TopoL(2) -- Polygon acute angle check
« Reply #1 on: March 28, 2024, 02:00:38 PM »
hi,kerry
Thanks for editing the post
Now the code editor of this forum does not support UNICODE, causing Chinese characters to be garbled.
The codes I provide now are all bilingual. Using LISP tags will cause garbled Chinese characters.
So what I always use is [ code ]

@kdub_nz
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net