Hello @john.uhden 👋
Sorry for the delay in responding, I was trying to adapt the lisp routine to your modification.
Thank you very much for fixing the routine code for me! 👏🙏😲
Your modification works perfect!😁👏🙏
Now I have a problem and it is my fault for not having said it before. The runtina lisp that I publish is not complete, I only published a part, do not imagine that they were going to modify it completely as you did. I'm so sorry!
I am using Autodesk AutoCAD Map 2021.
All the lisp code that I am going to put below this paragraph is only for one block and this block has an ID equal to "190" assigned and it is found within a group of blocks with the name "SPRSYMBOL".
(setq GroupEntity (ssget "x" (list (cons 0 "SPRSYMBOL") (cons 70 190))))
(while (ssname GroupEntity #EntityCount)
(setq Entity (ssname GroupEntity #EntityCount)
#EntityCount (+ #EntityCount 1)
)
(SETQ TNSEC (ntos NSec))
(setq valor (strcat HUB "_" TNSEC))
(IF (getlinksipre Entity 98)
()
(progn
(addlinksipre Entity 98 Valor)
(chsprcolor Entity 1)
(setq NSec (+ NSec 1))
)
)
)
That's why that name "SPRSYMBOL" seems strange to you.
Now, with the modification that you made, it only works for ID 190 and I need it to work for the other IDs of blocks, which I did not publish before, because that part of the code that I published above is repeated for each block and the only thing that changes are the IDs of the blocks that are these numbers 65, 190, 200, 207 and 451.
If we go to the code before fixing it, the lisp routine would look like this:
(defun c:NCAEM (/ ntos #EntityCount GroupEntity Entity NSec TNSEC HUB valor)
(defun ntos (n) ;; by @dbroad 2/10/17 and compacted by @john.uhden https://forums.autodesk.com/
(if (< (setq n (1- n)) 26)
(chr (+ 65 n))
(strcat (ntos (/ n 26))(chr (+ 65 (rem n 26))))
)
)
(setq #EntityCount 0)
(setq NSec 0)
(setq HUB "PPP")
(initget 6)
(or
(setq NSec (getint "\nEnter starting number <1>: "))
(setq NSec 1)
)
(setq GroupEntity (ssget "x" (list (cons 0 "SPRSYMBOL") (cons 70 65))))
(while (ssname GroupEntity #EntityCount)
(setq Entity (ssname GroupEntity #EntityCount)
#EntityCount (+ #EntityCount 1)
)
(SETQ TNSEC (ntos NSec))
(setq valor (strcat HUB "-" TNSEC))
(IF (getlinksipre Entity 98)
()
(progn
(addlinksipre Entity 98 Valor)
(chsprcolor Entity 1)
(setq NSec (+ NSec 1))
)
)
)
(setq #EntityCount 0)
(setq GroupEntity (ssget "x" (list (cons 0 "SPRSYMBOL") (cons 70 190))))
(while (ssname GroupEntity #EntityCount)
(setq Entity (ssname GroupEntity #EntityCount)
#EntityCount (+ #EntityCount 1)
)
(SETQ TNSEC (ntos NSec))
(setq valor (strcat HUB "-" TNSEC))
(IF (getlinksipre Entity 98)
()
(progn
(addlinksipre Entity 98 Valor)
(chsprcolor Entity 1)
(setq NSec (+ NSec 1))
)
)
)
(setq #EntityCount 0)
(setq GroupEntity (ssget "x" (list (cons 0 "SPRSYMBOL") (cons 70 200))))
(while (ssname GroupEntity #EntityCount)
(setq Entity (ssname GroupEntity #EntityCount)
#EntityCount (+ #EntityCount 1)
)
(SETQ TNSEC (ntos NSec))
(setq valor (strcat HUB "-" TNSEC))
(IF (getlinksipre Entity 98)
()
(progn
(addlinksipre Entity 98 Valor)
(chsprcolor Entity 1)
(setq NSec (+ NSec 1))
)
)
)
(setq #EntityCount 0)
(setq GroupEntity (ssget "x" (list (cons 0 "SPRSYMBOL") (cons 70 207))))
(while (ssname GroupEntity #EntityCount)
(setq Entity (ssname GroupEntity #EntityCount)
#EntityCount (+ #EntityCount 1)
)
(SETQ TNSEC (ntos NSec))
(setq valor (strcat HUB "-" TNSEC))
(IF (getlinksipre Entity 98)
()
(progn
(addlinksipre Entity 98 Valor)
(chsprcolor Entity 1)
(setq NSec (+ NSec 1))
)
)
)
(setq #EntityCount 0)
(setq GroupEntity (ssget "x" (list (cons 0 "SPRSYMBOL") (cons 70 451))))
(while (ssname GroupEntity #EntityCount)
(setq Entity (ssname GroupEntity #EntityCount)
#EntityCount (+ #EntityCount 1)
)
(SETQ TNSEC (ntos NSec))
(setq valor (strcat HUB "-" TNSEC))
(IF (getlinksipre Entity 98)
()
(progn
(addlinksipre Entity 98 Valor)
(chsprcolor Entity 1)
(setq NSec (+ NSec 1))
)
)
)
(ALERT "Process completed satisfactorily!")
)
As you can see, the previous code fragment is repeated again and only the ID numbers of the blocks change.
So with your code fix, I can't put the IDs of the blocks, I modified my routine but I don't know where to put the IDs of the blocks.
Sorry for my mistake for not posting all the code for the lisp routine first.
Have a nice day and a good weekend if you can't answer me before.
Again I apologize for my mistake and for making it work double.
Thank you very much for reading my message.
Greetings.