Recent Posts

Pages: [1] 2 3 ... 10
1
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


2
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)
3
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
4
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"
5
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.  
6
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

7
Yes, since arx interprets the list, it’s not reliable to hash.
Example  '(220 220 220 220)

'(220 220 220 220)
ARX's resbuf will be parsed into 3D points, but restype=220, not RT3DPOINT,

  So when you calculate the hash value, don’t you include the restype to make it unique?

Code - C++: [Select]
  1. size_t XdDbUtils::CalculateHash(const AcGePoint3d& point) {
  2.         size_t hash = 0;
  3.         hash ^= std::hash<double>{}(point.x) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
  4.         hash ^= std::hash<double>{}(point.y) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
  5.         hash ^= std::hash<double>{}(point.z) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
  6.  
  7.         return hash;
  8. }

Code - C++: [Select]
  1. int XDGetHash()
  2. {
  3.         resbuf* rb = ads_getargs();
  4.         size_t hash = 0;
  5.         while(rb)
  6.         {
  7.                 int restype = XdRbUtils::dxfCodeToDataType(rb->restype);
  8.                 hash ^= XdDbUtils::CalculateHash(rb->restype);
  9.                 switch (restype)
  10.                 {
  11.                 case RTENAME:
  12.                 {
  13.                         AcDbObjectId id;
  14.                         if (acdbGetObjectId(id, rb->resval.rlname) == eOk)
  15.                         {
  16.                                 AcDbEntity* pEnt;
  17.                                 if (acdbOpenObject(pEnt, id, kForRead) == eOk)
  18.                                 {
  19.                                         int param = 511;
  20.                                         if (rb->rbnext && rb->rbnext->restype == RTSHORT)
  21.                                         {
  22.                                                 param = rb->rbnext->resval.rint;
  23.                                         }
  24.                                         hash ^= XdDbUtils::CalculateHash(pEnt, param);
  25.                                         pEnt->close();
  26.                                 }
  27.                         }
  28.                 }
  29.                         break;
  30.                 case RT3DPOINT:
  31.                 {
  32.                         hash ^= XdDbUtils::CalculateHash(asPnt3d(rb->resval.rpoint));
  33.                 }
  34.                         break;
  35.                 case RTSTR:
  36.                 {
  37.                         hash ^= XdDbUtils::CalculateHash(rb->resval.rstring);
  38.                 }
  39.                         break;
  40.                 case  RTREAL:
  41.                 {
  42.                         hash ^= XdDbUtils::CalculateHash(rb->resval.rreal);
  43.                 }
  44.                         break;
  45.                 case  RTSHORT:
  46.                 {
  47.                         hash ^= XdDbUtils::CalculateHash(rb->resval.rint);
  48.                 }
  49.                         break;
  50.                 case RTLONG:
  51.                 {
  52.                         hash ^= XdDbUtils::CalculateHash(rb->resval.rlong);
  53.                 }
  54.                         break;
  55.                 default:
  56.                         break;
  57.                 }              
  58.                 rb = rb->rbnext;
  59.         }
  60.         // &#23558;&#21704;&#24076;&#20540;&#36716;&#25442;&#20026;&#23383;&#31526;&#20018;
  61.         std::string hashString = std::to_string(hash);
  62.         ads_retstr(CMyString::StringToTCHAR(hashString));
  63.         return RSRSLT;
  64. }
8
Yes, since arx interprets the list, it’s not reliable to hash.
Example  '(220 220 220 220)
9
Cool, I always thought it would be really cool to have hashmaps in Autolisp.
I had imagined using hash_combine generating hashes from lists, so lisp users could create generic hash maps

Code - Auto/Visual Lisp: [Select]
  1. (vlia_k_v '(100.0 100.0 10.0) '((-1 . <Entity name: 23873ab8490>) (0 . LWPOLYLINE)...))
  2.  

I toyed with it here, but passing data between autolisp and arx is just not reliable..
so bleh @ autodesk, there's really no good way to extend autolisp.

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

Group code 10, ARX is treated as 3D point,
So for lwpolyline, after lisp is passed to arx for processing, the two-dimensional points will become three-dimensional points.
10
Cool, I always thought it would be really cool to have hashmaps in Autolisp.
I had imagined using hash_combine generating hashes from lists, so lisp users could create generic hash maps

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (vlia_k_v '(100.0 100.0 10.0) '((-1 . <Entity name: 23873ab8490>) (0 . LWPOLYLINE)...))
  3.  

I toyed with it here, but passing data between autolisp and arx is just not reliable..
so bleh @ autodesk, there's really no good way to extend autolisp.

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

thanks,
In addition to the xdrx-entity-removeduplicates provided above, the XDRX API
Functions for calculating the hash value of an entity are also provided:
xdrx-entity-hashstring

Code - Auto/Visual Lisp: [Select]
  1. ;|
  2. @param param Bitmask parameter used for selectively calculating the hash value:
  3.  *  - 1: Use the entity's dxfName
  4.  *  - 2: Use the entity's layerName
  5.  *  - 4: Use the entity's colorIndex
  6.  *  - 8: Use the entity's linetypeName
  7.  *  - 16: Use the entity's linetypeScale
  8.  *  - 32: Use the entity's lineWidth
  9.  *  - 64: Use the entity's GRIP Point array (nStretchPts)
  10.  *  - 128: Use the entity's bounding box (box)
  11.  *  - 256: Use the entity's centroid
  12.  *  - 512: Use the entity's description (entity->desc())
  13. |;
  14. Command: (xdrx-entity-hashstring (entlast) 1)
  15. "1078249248256508798"
  16. Command: (xdrx-entity-hashstring (entlast) 3)
  17. "11643239585821548497"
  18. Command: (xdrx-entity-hashstring (entlast) 129)
  19. "3826409512706688743"
  20.  
Pages: [1] 2 3 ... 10