Author Topic: [XDrX-PlugIn(104)] Partially bold curve  (Read 274 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Bull Frog
  • Posts: 469
[XDrX-PlugIn(104)] Partially bold curve
« on: January 25, 2024, 12:15:53 AM »
Code: [Select]
(defun c:xdtb_curvesubjc (/ pmid pts p1 e p2 dbpl spa epa mpa pnt clr p2 berase e1)
  (defun _callback (dynpt)
    (if (or (and p1 (not (equal p1 dynpt)))
    (and pmid (not (equal pmid dynpt)))
)
      (progn  (setq spa (xdrx-curve-getparamatpoint e p1)
   pnt (xdrx-curve-getclosestpoint e dynpt)
   epa (xdrx-curve-getparamatpoint e pnt)
   mpa (if pmid
(xdrx-curve-getparamatpoint e pmid)
(/ (+ spa epa) 2.0)
       )
     )
     (setq pl (xdrx-curve-setinterval e spa epa mpa))
     (if (not (xdrx-object-iskindof pl "kcompositecrv3d"))
       (progn
(setq a (xdge::constructor "kcompositecrv3d" pl))
      (xdge::free pl)
      (setq pl a)
       )
     )
     (setq data (xdrx-getpropertyvalue pl "get"))
     (xdrx-setpropertyvalue dbpl "set" data)
     (xdrx-setpropertyvalue dbpl "constantwidth" #xd_var_global_width "color" clr)
     (xdrx-grdraw clr dbpl)
     (xdge::free)
      )
    )
  )
  (xdrx_begin)
  (xdrx_sysvar_push '("osmode" 547))
  (setq pts nil)
  (if (not #xd_var_global_width)
    (setq #xd_var_global_width 1.0)
  )
  (if (setq var (getreal
  (xdrx_prompt (xdrx-string-formatex (xdrx-string-multilanguage "\n输入加粗宽度<%.2f>:"
"\nEnter bold width<%.2f>:"
     )
     #xd_var_global_width
       )
       t
  )
)
      )
    (setq #xd_var_global_width var)
  )
  (if (and (setq e (car
     (xdrx_entsel (xdrx-string-multilanguage "\n选择曲线实体<退出>:"
     "\nSelect Curve Entity<Exit>:"
  )
  '((0 . "*line,arc,circle,ellipse"))
     )
   )
   )
   (if (xdrx-object-iskindof e "AcDbSpline")
     (progn (setq e1 e
  e (xdrx-polyline-make (xdrx-getsamplept e (/ (xd::doc:getpickboxheight) 10.0))
     (xdrx-curve-isclosed e)
)
  berase t
    )
    (xdrx-entity-matchprop e1 e)
     )
     t
   )
   (setq dbpl (xdrx-polyline-make))
   (setq p1 (getpoint (xdrx-string-multilanguage "\n起始点<退出>:"
"\nStart Point<Exit>:"
      )
    )
   )
   (xdrx_pointmonitor "_callback")
   (if (xdrx_curve_isclosed e)
     (progn (setq pmid (getpoint p1
(xdrx-string-multilanguage "\n中间点<退出>:"
    "\nMiddle Point<Exit>:"
)
       )
    )
    (setq pts (append (list p1) (list pmid)))
     )
     t
   )
   (or (setq p2 (getpoint (if pmid
    pmid
    p1
  )
  (xdrx-string-multilanguage "\n终止点<结束>:"
     "\nEnd Point<End>:"
  )
)
       )
       t
   )
   (setq p1 (xdrx_curve_getclosestpoint e (trans p1 1 0)))
   (setq p2 (xdrx_curve_getclosestpoint e (trans p2 1 0)))
      )
    (progn
   (xdrx-entity-make dbpl)
   (xdrx_entity_matchprop e (entlast))
           (setq clr (getvar "cecolor")
clr (cond ((= clr "BYLAYER") 256)
   ((= clr "BYBLOCK") 0)
   (T (atoi clr))
     )
   )
   (xdrx_setpropertyvalue (entlast)
  "constantwidth"
  #xd_var_global_width
  "color" clr
 
   )
           (xdrx-object-release dbpl)
   (xdrx_prompt
     (xdrx-string-multilanguage "\n局部曲线加粗成功."
"\nLocal curve bolding successful."
     )
   )
      (if berase
(xdrx-entity-delete e))
    )
  )
  (xdrx_pointmonitor)
  (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