Recent Posts

Pages: [1] 2 3 ... 10
1
.NET / Re: Losing Block Name
« Last post by Jeff H on Today at 11:19:32 AM »
When you insert blocks(BlockReference) they can only vary by position, rotation, and scaling from its definition(BlocktableRecord). So you really can not have a block that has different entities or representations of itself and have the ability to be dynamic.
AutoCAD does this by creating anonymous definitions(BlockTableRecords) naming them *UXXX for each of the dynamic states needed for all the references inserted in a drawing.

2
.NET / Losing Block Name
« Last post by kshitij.jadhav@cctech.co. on Today at 10:56:57 AM »
While developing an AutoCAD plugin in .NET, I encountered an issue where creating two new visibility states and setting this visibility to a block reference causes the block name to change to a format like UXXX (where X represents any digit). Although I can retrieve the original name from the dynamic table record, is there an alternative approach to prevent the block name from changing?
3
AutoLISP (Vanilla / Visual) / Re: Multiple pause
« Last post by w64bit on Today at 10:38:50 AM »
For selection it's OK now, for closing the command, not.
Code: [Select]
(command "SOLIDEDIT" "F" "O" "X" "X")
(while (= 1 (logand 1 (getvar 'cmdactive))) (command "\\"))
4
Use a hash table to quickly delete completely overlapping entities

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

What is a Hash Table?

A hash table (or hash map) is a data structure that provides a mechanism for storing key-value pairs, allowing for fast data retrieval. Each key is processed through a hash function, which computes an index (or hash code) into an array of buckets or slots. The key-value pair is then stored in the corresponding bucket. The fundamental operations of a hash table, such as insertion, deletion, and search, typically have an average time complexity of O(1), making them very efficient.

Why is Using a Hash Table to Delete Identical Entities in ARX Highly Efficient?

1. Fast Lookups:
  • The primary strength of a hash table is its ability to perform quick lookups. When deleting duplicate entities, you can compute a hash for each entity and check if that hash already exists in the table.
  • If the hash already exists, it means the entity is a duplicate and can be marked for deletion.
  • If the hash does not exist, the entity is added to the table.

2. Efficient Handling of Collisions:

  • In a hash table, collisions occur when two different entities produce the same hash code. Advanced hash table implementations efficiently handle collisions using techniques like chaining (where each bucket is a linked list of entries) or open addressing (where a collision triggers a search for the next available slot).
  • Proper handling of collisions ensures that even with duplicate entities, the overall performance remains optimal.

3. Scalability:

  • Hash tables scale well with the number of entities. As more entities are added, a well-implemented hash table can resize itself to maintain performance, ensuring that operations remain O(1) on average.
  • This scalability is crucial when dealing with large datasets or complex drawings in ARX.

ARX and Hash Tables

In the context of ARX (AutoCAD Runtime Extension), using a hash table to manage and delete duplicate entities is beneficial due to the following reasons:

1.Unique Identification:
  • Each entity can be uniquely identified using a hash value that combines various properties (such as geometry, layer, color, etc.).
  • This unique identification ensures that only truly identical entities are considered duplicates.

2.Performance:

  • AutoCAD drawings can contain thousands or even millions of entities. Using a hash table to manage duplicates ensures that the process remains efficient and does not degrade performance.
  • This efficiency is especially important in complex CAD environments where users require quick and responsive operations.

Sample Code for Removing Duplicate Entities Using a Hash Table
Here’s a corrected and complete code sample in ARX for removing duplicate entities using a hash table:

Code - C++: [Select]
  1. /**
  2.  * @brief Removes duplicate entities, keeping only unique ones.
  3.  *
  4.  * @param objectIdArray Array of entity object IDs
  5.  * @param param Bitmask parameter used for selectively calculating the hash value:
  6.  *  - 1: Use the entity's dxfName
  7.  *  - 2: Use the entity's layerName
  8.  *  - 4: Use the entity's colorIndex
  9.  *  - 8: Use the entity's linetypeName
  10.  *  - 16: Use the entity's linetypeScale
  11.  *  - 32: Use the entity's lineWidth
  12.  *  - 64: Use the entity's GRIP Point array (nStretchPts)
  13.  *  - 128: Use the entity's bounding box (box)
  14.  *  - 256: Use the entity's centroid
  15.  *  - 512: Use the entity's description (entity->desc())
  16.  */
  17. void XdDbUtils::RemoveDuplicateEntities(AcDbObjectIdArray& objectIdArray, int param)
  18. {
  19.     std::unordered_map<size_t, AcDbObjectId> entityHashmap;
  20.     AcDbObjectIdArray remainingObjects;
  21.  
  22.     // Iterate through the entity object array
  23.     for (int i = 0; i < objectIdArray.length(); ++i) {
  24.         AcDbObjectId objectId = objectIdArray[i];
  25.         AcDbEntity* pEntity = nullptr;
  26.         if (acdbOpenAcDbEntity(pEntity, objectId, AcDb::kForRead) == Acad::eOk && pEntity) {
  27.             // Calculate the hash value of the entity
  28.             size_t hash = XdDbUtils::CalculateHash(pEntity, param);
  29.  
  30.             // Check if the hash value already exists in the hash table
  31.             if (entityHashmap.find(hash) == entityHashmap.end()) {
  32.                 // The hash value does not exist, add to the hash table and remainingObjects array
  33.                 entityHashmap[hash] = objectId;
  34.                 remainingObjects.append(objectId);
  35.             }
  36.             // Close the entity
  37.             pEntity->close();
  38.         }
  39.     }
  40.  
  41.     // Replace the original objectIdArray with the remainingObjects array
  42.     objectIdArray = remainingObjects;
  43. }
  44.  

Conclusion

Using a hash table to delete duplicate entities in ARX is highly efficient due to the hash table's fast lookup, insertion, and deletion operations. This efficiency is crucial for maintaining performance in complex AutoCAD environments, ensuring that even large datasets are processed quickly and accurately.

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


Code: [Select]
(defun c:xdtb_removeovents (/ ss len ret)
  (xdrx-begin)
  (if (setq ss (xdrx-ssget
(xdrx-string-multilanguage
   "\n选择要处理的对象<退出>:"
   "\nSelect objects to process <Exit>:"
)
       )
      )
    (progn
      (setq len (sslength ss))
      (setq ret (xdrx-entity-removeduplicates ss 129))
      (xdrx-prompt
(xdrx-string-formatex
  (xdrx-string-multilanguage
    "\n共删除了 %d 个重复的实体."
    "\nA total of %d duplicate entities have been removed."
  )
  (- len ret)
)
      )
    )
  )
  (xdrx-end)
  (princ)
)
5
Hey all,

looking for away to set layers on/off/freeze/thaw  bij filter name.
After alot of searching, i have noluck :-(

the next thing is, try to find the layers that are in a layer filter.

At this moment i'm stuck at the point that ik have the filter names, but no layers.
I have tried to look in to de dxf code's, i just can't find it.

The reason i need this is,  to run a lot of drawings.
And i need the layers on/off by filtername.

thx for the help, John

Code: [Select]
(defun :LayerFilterList (/ :SubFilterList)

  (defun :SubFilterList (dict / ent lst)
    (foreach ent (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 350)) dict))
      (setq lst (append lst
                        (cons ent (if (assoc 360 (entget ent))
                                    (:SubFilterList (entget (cdr (assoc 360 (entget (cdr (assoc 360 (entget ent)))))))))))))
    lst)

  (mapcar '(lambda (x) (cdr (assoc 300 (entget x))))
          (:SubFilterList (dictsearch
                            (vlax-vla-object->ename
                              (vla-getextensiondictionary
                                (vla-get-layers
                                  (vla-get-activedocument
                                    (vlax-get-acad-object)))))
                            "ACLYDICTIONARY"))))


(:LayerFilterList)
6
AutoLISP (Vanilla / Visual) / Re: Solid to surface
« Last post by EnM4st3r on Today at 03:25:38 AM »
you mean like CONVTOSURFACE?
7
When I was wrapping BrxCvCivil3d for python, I noticed a converter class, I haven't tried it yet

Code - C++: [Select]
  1. void makePyBrxCvCivil3dConverterWrapper()
  2. {
  3.     PyDocString DS("CvCivil3dConverter");
  4.     class_<PyBrxCvCivil3dConverter>("CvCivil3dConverter")
  5.         .def(init<>())
  6.         .def(init<const PyDbDatabase&, PyDbDatabase&, BrxCvCivil3dConverter::Civil3dLabels>(DS.CTOR(ctor)))
  7.         .def("getCivilEntities", &PyBrxCvCivil3dConverter::getCivilEntities, DS.ARGS())
  8.         .def("convert", &PyBrxCvCivil3dConverter::convert, DS.ARGS({ "entitiesToConvert : list" }))
  9.         .def("attachedLabels", &PyBrxCvCivil3dConverter::attachedLabels, DS.ARGS({ "civilEntity: PyBrxCv.CvCivil3dEntityInfo" }))
  10.         .def("unattachedLabels", &PyBrxCvCivil3dConverter::unattachedLabels, DS.ARGS())
  11.         .def("getInsertedEntities", &PyBrxCvCivil3dConverter::getInsertedEntities, DS.ARGS())
  12.         .def("className", &PyBrxCvCivil3dConverter::className, DS.SARGS()).staticmethod("className")
  13.         ;
  14. }
  15.  
It’s probably available in BRX, .NET too. Not sure about lisp, i'm sure there's a command
8
AutoLISP (Vanilla / Visual) / Re: Multiple pause
« Last post by BIGAL on May 22, 2024, 10:00:36 PM »
Should you be using SSGET filters ? Or are you asking about SSGET "W" "F" "CP" etc. Not sure why you would need pauses, you can do multiple SSGET and use SSADD to make a final selection set. Say select blocks then select plines using filters.

We are guessing. More detail needed.
9
If I remember correctly, the property set can be found but using a particular CIV3D DLL not sure if Bricscad has the same function. I would join the Bricscad forum they are very helpful and actual Bricscad staff respond at times or put in a support request, again they do answer back.
10
AutoLISP (Vanilla / Visual) / Re: Select all layer change to single layer
« Last post by BIGAL on May 22, 2024, 09:52:34 PM »
This is posted else where and the additional request was don't change "Light Furniture" I think it was Forums/autodesk. Also change all nested blocks.

A nuisance when posted at multiple forums.
Pages: [1] 2 3 ... 10