Recent Posts

Pages: 1 ... 5 6 [7] 8 9 10
61
PERFECT!!! I thank you very much, 'Prince'! :smitten:

Clint
62
AutoLISP (Vanilla / Visual) / Re: Align Multiple Text Objects to Curve
« Last post by reyas1123 on April 21, 2024, 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
63
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...
64
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))))
65
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.  
66
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
67
/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?
68
(- test test1) includes time spent for both benchmarks
should be (- test2 test1))
69
https://www.cadtutor.net/forum/topic/74275-assigning-random-colors-to-each-linepolyline-within-a-selection-set/

Code: [Select]
(defun c:xdtb_entrandclr (/ ss clr)
  (xdrx-begin)
  (if (setq ss (xdrx-ssget
(xdrx-string-multilanguage
   "\n选择实体<退出>:"
   "\nSelect Entity<Exit>:"
)
       )
      )
    (progn
      (mapcar '(lambda (x)
(setq clr (xdrx-math-rand 1 255))
(xdrx-setpropertyvalue x "color" clr)
       )
      (xdrx-ss->ents ss)
      )
    )
  )
  (xdrx-end)
  (princ)
)
70
Hello.

I have a function that returns list of fit points of a spline:
Code - Auto/Visual Lisp: [Select]
  1. (DEFUN _getPoints (ent / coord result)
  2.    (WHILE (SETQ coord (ASSOC 11 ent))
  3.       (SETQ result (CONS (CDR coord) result)
  4.             ent    (CDR (MEMBER coord ent))
  5.       )
  6.    )
  7.    (REVERSE result)
  8. )
I use it also to count fit points, which seemed like waste of resources, since I could just count the point within the function instead:
Code - Auto/Visual Lisp: [Select]
  1. (DEFUN _getNumPoints (ent / coord num)
  2.    (setq num 0)
  3.    (WHILE (SETQ coord (ASSOC 11 ent))
  4.       (SETQ ent (CDR (MEMBER coord ent))
  5.             num (1+ num)
  6.       )
  7.    )
  8. )
However, my benchmark shows that _getNumPoints is actually slower, almost twice on spline with 200+ points!
How is this possible? Or my benchmark is incorrect?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ ent _getPoints _isNumPoints test test1 test2)
  2.     (DEFUN _getPoints (ent / coord result)
  3.         (WHILE (SETQ coord (ASSOC 11 ent))
  4.             (SETQ result (CONS (CDR coord) result)
  5.                   ent    (CDR (MEMBER coord ent))
  6.             )
  7.         )
  8.         (REVERSE result)
  9.     )
  10.  
  11.  
  12.     (DEFUN _getNumPoints (ent / coord num)
  13.         (setq num 0)
  14.         (WHILE (SETQ coord (ASSOC 11 ent))
  15.             (SETQ ent (CDR (MEMBER coord ent))
  16.                   num (1+ num)
  17.             )
  18.         )
  19.     )
  20.  
  21.     ; only FIT spline, not CV
  22.     (setq ent (entget (SSNAME (ssget ":S" '((0 . "SPLINE") (-4 . "!=") (74 . 0))) 0)))
  23.     ; start bench
  24.     (setq test1 (car (_vl-times)))
  25.     (repeat 100 (_getNumPoints ent) )
  26.     ;
  27.     (setq test2 (car (_vl-times)))
  28.     (repeat 100 (_getPoints ent) )
  29.     ; result
  30.     (setq test (car (_vl-times)))
  31.     (princ "\n_getNumPoints: ")
  32.     (princ (- test test1))
  33.     (princ "\n_getPoints:    ")
  34.     (princ (- test test2))
  35.     (princ)
  36. )

P.S.
While preparing this question, I've noticed that if I preselect spline before running the test it takes 10 times longer than when spline selected when prompted by the test...huh?
Code: [Select]
Command: TEST <--- pre selected spline
_getNumPoints: 1030
_getPoints:    542
Command:
Command: TEST <-- nothing pre selected
Select objects:
_getNumPoints: 68
_getPoints:    37
Pages: 1 ... 5 6 [7] 8 9 10