Recent Posts

Pages: [1] 2 3 ... 10
1
XDRX-API / [XDrX-PlugIn(154)] Get the total length of overlapping segments
« Last post by xdcad on Today at 09:57:42 PM »

1. xdrx-pointmonitor 

    Through the point monitor callback function _callback, draw dynamic memory MTEXT, POLYLINE screen vector, and dynamic drag



2. xd::geom:getoverlaps

    Get Entitiy List of overlapping segments 

Code: [Select]
;|
Functions: Obtain the memory geometric entities of the overlapping segments of two polylines (determine whether the two polylines will overlap in the future)

parameter:
    1. e1,e2 ---- polyline entity name, or geometric entity name, or point table
    2. mode --- t: returns the geometric entity table, nil: returns t or nil
|;
(defun xd::geom:getoverlaps (e1 e2 mode / g1 g2 gint curveint ret _getparam ranges ranges1)
  (defun _getparam (e1 / g1)
    (cond
      ((= (type e1) 'list)
       (setq g1 (xdge::constructor "kCompositeCrv3d" e1))
      )
      ((and (= (type e1) 'ename)
    (xdrx-object-iskindof e1 "AcDbCurve")
       )
       (setq g1 (xdge::constructor e1))
      )
      ((xdge::type e1)
       t
      )
      (t
       (setq g1 nil)
      )
    )
    g1
  )
  (setq g1 (_getparam e1)
g2 (_getparam e2)
  )
  (if (and g1 g2)
    (progn
      (setq curveint (xdge::constructor "kCurveCurveInt3d"))
      (setq gint (xdge::setpropertyvalue curveint "set" g1 g2))
      (setq ret (> (xdge::getpropertyvalue gint "numOverlaps") 0))
      (if (and mode ret)
(progn
  (setq ranges (xdge::getpropertyvalue gint "overlapranges" t)
ranges1 (mapcar 'car ranges)
  )
  (setq ret
(mapcar '(lambda (x)
    (setq tmp (xdge::copy g1))
    (xdge::setpropertyvalue tmp "setinterval" x)
  )
ranges1
)
  )
)
      )
    )
  )
  (xdge::free g1 g2 curveint gint ranges)
  ret
)

Code: [Select]
(defun c:tt ()
  (defun *error* (msg)
    (xdrx-entity-delete ents)
    (xdrx-pointmonitor)
    (xdrx-end)
    (redraw)
  )
  (defun _callback (dynpt)
    (redraw)
    (xd::pnts:mark verts 2 0.025)
    (xdrx-setpropertyvalue
      ents
      "constantwidth"
      (* (getvar "viewsize") 0.015)
      "color" 6
    )
    (xdrx-grdraw 6 ents)
    (xd::grdraw:drawtext
  txt
  totallen
  (polar dynpt (/ pi 4.0) (/ (xd::doc:getpickboxheight) 2.0))
  1
  (* (getvar "viewsize") 0.03)
  6
  (getvar "ucsxdir")
  nil
  8
)
   
  )
  (xdrx-begin)
  (if (and (setq e1 (car (xdrx-entsel
   (xdrx-string-multilanguage
     "\n拾取第一条多段线<退出>:"
     "\nPick the first polyline<Exit>:"
   )
   '((0 . "*polyline"))
)
    )
   )
   (setq e2 (car (xdrx-entsel
   (xdrx-string-multilanguage
     "\n拾取第一条多段线<退出>:"
     "\nPick the first polyline<Exit>:"
   )
   '((0 . "*polyline"))
)
    )
   )
      )
    (progn
      (if (setq data (xd::geom:getoverlaps e1 e2 t))
(progn
  (setq txt (xdrx-mtext-make)
nums (length data)
tlen (apply '+ (xdrx-getpropertyvalue data "length"))
totallen (xdrx-string-formatex
   (xdrx-string-multilanguage
     "重叠段 %d,总长度 %.1f\r\n"
     "Overlapping segment %d.\r\nTotal length=%.1f"
   )
   nums
   tlen
)
verts (xdrx-getpropertyvalue data "vertices")
ents (xdrx-entity-make data)
verts (xd::list:flat-point verts)
  )
  (xdrx-pointmonitor "_callback")
  (if (getpoint)
    (progn
      (xdrx-entity-make txt)
    )
  )
  ;(xdrx-entity-delete ents)
  (xdrx-pointmonitor)
)
      )
    )
  )
  (redraw)
  (xdrx-end)
  (princ)
)

=======================

The above LISP code uses the XDRX-API, which can be downloaded from https://github.com/xdcad/XDrx-API

The XDRX API encapsulates AcDb, AcEd, AcGe, AcBr... C++ library, using C++ methods to develop LISP programs.Thousands of Lisp functions are available.
2
AutoLISP (Vanilla / Visual) / Re: Align Multiple Text Objects to Curve
« Last post by xdcad on Today at 09:52:51 PM »

Quote

Dear Sir,
i downloaded the file and save to lsp file but has an error. tnx
ReyAs

Have you downloaded the API compressed package at https://github.com/xdcad/XDrx-API, decompressed it, and installed the files inside?
During installation, check all of them. After installation, start ACAD and check with F2. There will be a prompt whether the API is loaded.

=======

┌───────────────────────────────────┐
│  ≡ XDRX_API For AutoCAD Build 2024.04.28 ≡  │
│  http://www.xdcad.net  Mail:7598165@qq.com  │
└───────────────────────────────────┘

========


If normal,

It is possible to run the forum LISP
3
PERFECT!!! I thank you very much, 'Prince'! :smitten:

Clint
4
AutoLISP (Vanilla / Visual) / Re: Align Multiple Text Objects to Curve
« Last post by reyas1123 on Today at 07:36:21 AM »

You can specify the distance after alignment





https://www.theswamp.org/index.php?topic=59245.0

Dear Sir,
i downloaded the file and save to lsp file but has an error. tnx
ReyAs
5
AutoLISP (Vanilla / Visual) / Re: Ssget filter for mirrored multileader
« Last post by ribarm on April 20, 2024, 04:09:33 PM »
Correct...
It selects in AutoCAD 2022 on my Laptop...
6
AutoLISP (Vanilla / Visual) / Re: Ssget filter for mirrored multileader
« Last post by ronjonp on April 20, 2024, 03:41:02 PM »
This works for me on your sample drawing.
Code - Auto/Visual Lisp: [Select]
  1. (sssetfirst nil (ssget "_X" '((0 . "MULTILEADER") (13 -1.0 0.0 0.0))))
7
This part :

Code - Auto/Visual Lisp: [Select]
  1.     (setq test1 (car (_vl-times)))
  2.     (repeat 100 (_getNumPoints ent) )
  3.     (setq test2 (car (_vl-times)))
  4.     (repeat 100 (_getPoints ent) )
  5.     (setq test (car (_vl-times)))
  6.     (princ "\n_getNumPoints: ")
  7.     (princ (- test test1))
  8.     (princ "\n_getPoints:    ")
  9.     (princ (- test test2))
  10.  

Should be :

Code - Auto/Visual Lisp: [Select]
  1.     (setq test1 (car (_vl-times)))
  2.     (repeat 100 (_getNumPoints ent) )
  3.     (setq test2 (car (_vl-times)))
  4.     (repeat 100 (_getPoints ent) )
  5.     (setq test3 (car (_vl-times)))
  6.     (princ "\n_getNumPoints: ")
  7.     (princ (- test2 test1))
  8.     (princ "\n_getPoints:    ")
  9.     (princ (- test3 test2))
  10.  
8
Any ideas why it shows different result when object selected prior running the test function, vs object selected during running the function?
probably caused by some internal and thus mysterious reasons :)
add (getstring) after line #22
9
/facepalm

Thank you!

Any ideas why it shows different result when object selected prior running the test function, vs object selected during running the function?
10
(- test test1) includes time spent for both benchmarks
should be (- test2 test1))
Pages: [1] 2 3 ... 10