Recent Posts

Pages: [1] 2 3 ... 10
1
Efficiency test, 510 entities, including 505 duplicate entities

Hash table efficiency far exceeds overkill

 

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

Command: tt
Select objects: Specify opposite corner: 510 found

Select objects:

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

Command: (tt1)

CPU:(1x)Intel(R) Xeon(R) E3-1575M v5 @ 3.00GHz 4Cores  / Memory:64G / OS: WIN10 professional workstation version
Benchmarking ......
Current settings: Tolerance=0.000001, Ignore=None, Optimize polylines=Yes, Combine partial overlap=Yes, Combine end-to-end=Yes
505 duplicate(s) deleted
0 overlapping object(s) or segment(s) deleted. done for 16 iterations. Sorted from fastest.
Statement                    Increment  Time(ms)  Normalize  Relative
-------------------------------------------------------------------------------
(xdrx-entity-removeduplic...)       16      1078         1078     28.07 <fastest>
(COMMAND ._-overkill SS  )          1       1891      30256       1.00 <slowest>
-------------------------------------------------------------------------------

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2.   (if (setq ss (ssget))
  3.     (progn
  4.      (setq ss1 (xdrx-entity-copy ss))
  5.     )
  6.   )
  7.   (princ)
  8. )
  9. (defun tt1 ()
  10.   (xd::quickbench
  11.     '((command "._-overkill" ss "" "")
  12.       (xdrx-entity-removeduplicates ss1 129)
  13.      )
  14.   )
  15.   (princ)
  16. )
2
AutoLISP (Vanilla / Visual) / Re: Solid to surface
« Last post by ScottMC on May 24, 2024, 05:33:54 PM »
Is it a region? Another option Amarulu would be solidedit/face/copy and pick on the edge of the inner segment...
3
>>>>>
Here’s another example of a valiant attempt to extend lisp
https://www.theswamp.org/index.php?topic=45841.msg618986#msg618986

It’s very unfortunate




Yes, unfortunate is an understatement.  I'm baffled why AutoDesk can't provide a valid round-trip mechanism for values.

Really, really frustrating not being able to maintain the integrity of data.
4
AutoLISP (Vanilla / Visual) / Re: Turn all layout viewports ON-OFF in a drawing
« Last post by Ndruu on May 24, 2024, 12:04:26 PM »
Thank you all for the great suggestions and sorry for the late reply!
Unfortunately none of it worked for me hundred percent, but after some digging and fiddling I found a way to do it.
Thanks to Andrzej Kalinowski who wrote a description of his app https://autolisps.blogspot.com/p/viewporttools.html

To get the correct Viewport ID, you have to cycle through all layouts, that is unavoidable.
But the process takes more time as the number of layers grow in the drawing.
So the key is to freeze all the layers and then go through each layout. After that you can thaw back the layers with LAYERP.

Final simple code (no error trapping):

Code - Auto/Visual Lisp: [Select]
  1. (defun c:avpoff (/ old-ctab ss count ent llc i)
  2.   (setq old-ctab (getvar "ctab"))
  3.   (setq llc (length (layoutlist)))
  4.   (setq llc0 llc)
  5.   (command "-Layer" "freeze" "*" "")
  6.   (acet-ui-progress-init
  7.     (strcat "In progress ( Nr. of layouts " (rtos llc 2 0) " )")
  8.     llc
  9.   )
  10.   (setq i 0)
  11.   (foreach layout (layoutlist)
  12.     (if
  13.       (and (not (= (strcat layout) "MODEL"))
  14.            (setq ss (ssget "x" (list '(0 . "VIEWPORT") (cons 410 layout))))
  15.            (setvar 'ctab layout)
  16.       )
  17.        (progn
  18.          (setq count -1)
  19.          (setq i (1+ i))
  20.          (while (< (setq count (1+ count)) (1- (sslength ss)))
  21.            (setq ent (vlax-ename->vla-object (ssname ss count)))
  22.            (vla-display ent :vlax-false)
  23.            (vla-put-viewporton ent :vlax-false)
  24.            (acet-ui-progress-safe i)
  25.          )                              ;while
  26.        )
  27.     )                                   ;if
  28.   )                                     ;foreach
  29.   (acet-ui-progress-done)
  30.   (setvar 'ctab old-ctab)
  31.   (command "layerp")
  32.   (princ)
  33.   (setvar 'modemacro "")
  34.   (princ "\nDone!")
  35.   (alert "\nAll viewports are ON")
  36.   (princ)
  37. )
  38.  
  39. (defun c:avpon  (/ old-ctab ss count ent llc i)
  40.   (setq old-ctab (getvar "ctab"))
  41.   (setq llc (length (layoutlist)))
  42.   (setq old-layer (getvar 'clayer))
  43.   (command "-Layer" "freeze" "*" "")
  44.   (acet-ui-progress-init
  45.     (strcat "In progress ( Nr. of layouts: "
  46.             (rtos llc 2 0)
  47.             " )"
  48.     )
  49.     llc
  50.   )
  51.   (setq i 0)
  52.   (foreach layout (layoutlist)
  53.     (if
  54.       (and (not (= (strcat layout) "MODEL"))
  55.            (setq ss (ssget "x" (list '(0 . "VIEWPORT") (cons 410 layout))))
  56.            (setvar 'ctab layout)
  57.       )
  58.        (progn
  59.          (setq count -1)
  60.          (setq i (1+ i))
  61.          (while (< (setq count (1+ count)) (1- (sslength ss)))
  62.            (setq ent (vlax-ename->vla-object (ssname ss count)))
  63.            (vla-display ent :vlax-false)
  64.            (vla-put-viewporton ent :vlax-true)
  65.            (acet-ui-progress-safe i)
  66.          )                              ;while
  67.        )
  68.     )                                   ;if
  69.   )                                     ;foreach
  70.   (acet-ui-progress-done)
  71.   (setvar 'ctab old-ctab)
  72.   (command "layerp")
  73.   (princ)
  74.   (setvar 'modemacro "")
  75.   (princ "\nDone!")
  76.   (alert "\nAll viewports are ON")
  77.   (princ)
  78. )
5
Misunderstanding? Let’s say I have a key that’s a string, and a value that starts with a DXF code
(‘(“A”), ‘(11 11))
  Key       Value

Now I want to retrieve the value of ‘(“A”), I will get back (11.0 11.0 0.0). The value is wrong
I wanted two integers back, but I get back 3 doubles

Here’s another example of a valiant attempt to extend lisp
https://www.theswamp.org/index.php?topic=45841.msg618986#msg618986

It’s very unfortunate


6
My point is, you can’t use certain lists in the ‘value’ part of the map either, because what you put in, is not the same as what you get out

MapInsert ('(KEY) ‘(10 10)) may return ‘(10 10 0)
MapInsert ('(KEY) ‘(220 220 220 220))  LsAdsInvoke Internal Error

‘(220 220 220 220) This kind, because it is a BUG, cannot be passed from LISP to ARX at all, let’s not discuss it first.
'(10 10), when passed to ARX, will become a 3D point of '(10.0 10.0 0.0),
Insert into MAP, so '(10 10) under LISP can also query the index position INDEX through '(10.0 10.0 0.0), and then return the index to LISP for processing'(10 10)
7
My point is, you can’t use certain lists in the ‘value’ part of the map either, because what you put in, is not the same as what you get out

MapInsert ('(KEY) ‘(10 10)) may return ‘(10 10 0)
MapInsert ('(KEY) ‘(220 220 220 220))  LsAdsInvoke Internal Error
8
No, I don’t think I hashed the restype, just the value, but the value you get back can also be modified

vlia_k_v (‘(10 10 10) ‘(10 10))
or
vlia_k_v ‘(10 10 10) ‘'(220 220 220 220)

so it’s not really possible to build a generic unordered_map for lisp,  because there is some probability of a ;LsAdsInvoke Internal Error, or worse, corrupt data

'(220.0 220.0 220.0) and  '(210 220.0 220.0 220.0)

What I said about adding restype to hash calculation is to address the above points.
Within ARX, they are all considered to be 3D points. If calculated directly, their hash values will be the same.

======

Command: (xdrx_entity_hashstring '(220.0 220.0 220.0))
"17095823065452309527"
Command: (xdrx_entity_hashstring '(210 220.0 220.0 220.0))
"6635585597989606581"
9
Yes, since arx interprets the list, it’s not reliable to hash.
Example  '(220 220 220 220)

Just tested it
'(220 220 220 220) This kind of data is illegal data. If it cannot be converted into resbuf, an error will be reported. This should be a BUG of AUTOCAD, and there are 221, 222, etc.

Command: (xdrx_entity_hashstring '(220 220 220 220))
error: LsAdsInvoke Internal Error

Command: (xdrx_entity_hashstring '(221 220 220 220))
error: LsAdsInvoke Internal Error

Command: (xdrx_entity_hashstring '(219 220 220 220))
"4355413184637992076"

Command: (xdrx_entity_hashstring '(218 220 220 220))
"6650467817808998717"

Command: (xdrx_entity_hashstring '(223 220 220 220))
error: LsAdsInvoke Internal Error

Command: (xdrx_entity_hashstring '(239 220 220 220))
error: LsAdsInvoke Internal Error

Command: (xdrx_entity_hashstring '(230 220 220 220))
error: LsAdsInvoke Internal Error

Command: (xdrx_entity_hashstring '(10 220 220 220))
"6350337662529562573"

Command: (xdrx_entity_hashstring '(215 220 220 220))
"13560894329457377856"

Code - C++: [Select]
  1. else if ((resType >= 210) && (resType <=239))
  2. {
  3.         return(RT3DPOINT);
  4. }
  5.  

Should be changed to:

Code - C++: [Select]
  1. else if ((resType >= 210) && (resType <=219))
  2. {
  3.         return(RT3DPOINT);
  4. }
  5.  
10
No, I don’t think I hashed the restype, just the value, but the value you get back can also be modified

vlia_k_v (‘(10 10 10) ‘(10 10))
or
vlia_k_v ‘(10 10 10) ‘'(220 220 220 220)

so it’s not really possible to build a generic unordered_map for lisp,  because there is some probability of a ;LsAdsInvoke Internal Error, or worse, corrupt data

Pages: [1] 2 3 ... 10