Author Topic: [XDrX-PlugIn(99)] Draw a rectangle in the center  (Read 268 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Bull Frog
  • Posts: 479
[XDrX-PlugIn(99)] Draw a rectangle in the center
« on: January 19, 2024, 12:20:59 PM »
 
Code - Auto/Visual Lisp: [Select]
  1. (defun c:xdtb_rectcen (/ box pl)
  2.   (defun myerr (msg)
  3.     (xdrx_sysvar_pop)
  4.     (setq *error* olderr)
  5.     (xdrx-entity-delete pl)
  6.     (xdrx-end)
  7.     (princ)
  8.   )
  9.   (xdrx-begin)
  10.   (setq olderr  *error*
  11.         *error* myerr
  12.   )
  13.   (xd::doc:getdouble (xdrx-string-multilanguage "\n矩形长" "\nRectangle Length")
  14.                      "#xd-var-global-length"
  15.                      10.0
  16.   )
  17.   (xd::doc:getdouble (xdrx-string-multilanguage "\n矩形宽" "\nRectangle Width")
  18.                      "#xd-var-global-width"
  19.                      10.0
  20.   )
  21.   (xdrx-sysvar-push '("osmode" 545))
  22.   (setq box (xdrx_points->offsetbox '(0 0 0)
  23.                                     (list #xd-var-global-length 0.0 0.0)
  24.                                     (/ #xd-var-global-width 2.0)
  25.                                     (/ #xd-var-global-width 2.0)
  26.                                     0.0
  27.                                     0.0
  28.             )
  29.   )
  30.   (setq pl (xdrx-polyline-make box t))
  31.   (xd::drag:freemove pl
  32.                      (xd::geom:get9pt pl 5) ;drag basepoint at center
  33.                      (+ 1 4 128)
  34.                      ;;Activate the base point, rotate 90 degrees, and align
  35.                      547
  36.                      nil
  37.   )
  38.   (xdrx-entity-delete pl)
  39.   (setq *error* olderr)
  40.   (xdrx-end)
  41.   (princ)
  42. )

edit Kerry: [ code=cadlisp-7 ]
« Last Edit: January 19, 2024, 06:38:30 PM by kdub_nz »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net