Author Topic: [XDrX-PlugIn(80)] Restore exploded dimension  (Read 249 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Bull Frog
  • Posts: 479
[XDrX-PlugIn(80)] Restore exploded dimension
« on: January 04, 2024, 02:27:11 PM »
Code: [Select]
(defun c:xdtb_dimres (/       #endpoint       #startpoint     ang
      box     dimexo  dimlinepnt      e       e1
      e2      e3      e4      e5      i       int1
      int2    pnt     scl     ss      ss1     styl
      style   txt     v       x       xdir    xline1pnt
      xline2pnt       ydir
     )
  (defun xd::dim:isexplodegroup (txt / box xdir ydir ss)
    (defun _isparallel (e v)
      (xdrx-getpropertyvalue e "startpoint")
      (xdrx-vector-isparallel
(xdrx-getpropertyvalue e "getfirstderiv" #startpoint)
v
      )
    )
    (defun _isperp (e v)
      (xdrx-getpropertyvalue e "startpoint")
      (xdrx-vector-isperpendicular
(xdrx-getpropertyvalue e "getfirstderiv" #startpoint)
v
      )
    )
    (defun _xlinepnt (e pnt)
      (xdrx-getpropertyvalue e "startpoint" "endpoint")
      (if (< (distance #startpoint pnt) (distance #endpoint pnt))
#endpoint
#startpoint
      )
    )
    (if (and (setq box (xdrx-text-box txt)
   xdir (xdrx-vector-normalize
  (mapcar '- (nth 1 box) (nth 0 box))
)
   ydir (xdrx-vector-normalize
  (mapcar '- (nth 2 box) (nth 1 box))
)
     )
     (setq ss (xdrx_entity_prevEntities txt 5))
     (= (length ss) 5)
     (xdrx-object-iskindof (setq e1 (nth 0 ss)) "acdbblock*")
     (xdrx-object-iskindof (setq e2 (nth 1 ss)) "acdbblock*")
     (xdrx-object-iskindof (setq e3 (nth 2 ss)) "acdbline")
     (xdrx-object-iskindof (setq e4 (nth 3 ss)) "acdbline")
     (xdrx-object-iskindof (setq e5 (nth 4 ss)) "acdbline")
     (_isparallel e3 xdir)
     (_isparallel e4 ydir)
     (_isparallel e5 ydir)
)
      (progn (setq styl       (getvar "dimstyle")
   style      (xdrx-object-get "dimstyle" styl)
   dimexo     (xdrx-getpropertyvalue style "dimexo")
   scl       (xdrx-getpropertyvalue style "dimscale")
   int1       (xdrx-get-inters e3 e4 1)
   int2       (xdrx-get-inters e3 e5 1)
   dimlinepnt (car int1)
   xline1pnt  (_xlinepnt e5 (car int2))
   xline2pnt  (_xlinepnt e4 (car int1))
   ydir       (xdrx-vector-normalize (mapcar '- xline2pnt dimlinepnt))
   xline1pnt  (mapcar '+
      xline1pnt
      (xdrx-vector-product ydir (* dimexo scl))
      )
   xline2pnt  (mapcar '+
      xline2pnt
      (xdrx-vector-product ydir (* dimexo scl))
      )
   ang       (angle (car int2) dimlinepnt)
     )
     (list (list dimlinepnt xline1pnt xline2pnt ang) ss)
      )
    )
  )
  (xdrx-begin)
  (xdrx-prompt
    (xdrx-string-multilanguage
      "\n**请设置好当前的标注样式,按当前标注样式恢复炸开的标注对象**"
      "\n**Restore the exploded dimension object according to the current dimension style**"
    )
  )
  (if (setq
ss1 (xdrx-ssget
      (xdrx-string-multilanguage
"\n请选择炸开后的文字<退出>:"
"\nPlease select the exploded text <Exit>:"
      )
      '((0 . "*text"))
    )
      )
    (progn
      (setq i 0)
      (mapcar '(lambda (x)
(if (setq ss (xd::dim:isexplodegroup x))
   (progn (setq i (1+ i))
  (xdrx-entity-delete ss)
  (xdrx_dimension_MakeRotate
    (cadr (car ss))
    (caddr (car ss))
    (car (car ss))
    (last (car ss))
  )
  (xdrx-entity-matchprop x (entlast))
  (xdrx-setpropertyvalue (entlast) "color" 256)
  (xdrx-entity-delete (cons x (last ss)))
   )
)
       )
      (xdrx-pickset->ents ss1)
      )
      (xdrx-prompt
(xdrx-string-formatex
  (xdrx-string-multilanguage
    "\n共选择了 %d 个文字,其中发现炸开组 %d 个,恢复了 %d 个标注对象."
    "\nA total of %d texts were selected, among which %d exploded groups were found and %d annotation objects were restored."
  )
  (sslength ss1)
  i
  i
)
      )
    )
  )
  (xdrx-end)
  (princ)
)
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