Make unique blocks for every block reference

Make unique blocks for every block reference

alashG39HJ
Explorer Explorer
252 Views
3 Replies
Message 1 of 4

Make unique blocks for every block reference

alashG39HJ
Explorer
Explorer

Hi everyone,

 

I need a routine, to make every block reference as unique block in entire drawing, for use in other sofrtware. I  have found a leemac script Copy or Rename Block reference, it does exactly what i need but just for one selected element. I have tried to edit it, and with some success but i have got strange error also. When i run this script first time in drawing with block i work perfectly, but when i try to run it again in the same drawing i got error with selection set. I can't figure it out why it is happening. 

There are my edited script and also some simple drawing with two blocks inside. After loading a lisp to file use cb command, you will find, that routine created new definition of block with numbered definition and also deleted block reference for base block. But if u try to use cb command again it will fail right after creation of new selection set. I can't manage to run this script second time in the same drawing. If i copy this new blocks to fresh drawing and then in new drawing again run cb command it works again, but again only once. What is going on here?

0 Likes
Accepted solutions (2)
253 Views
3 Replies
Replies (3)
Message 2 of 4

Moshe-A
Mentor
Mentor
Accepted solution

@alashG39HJ ,

 

can i guess? some where along the 'road' you did something like this:

(setq sslength .....)

 

This is forbidden, redefinition of built in AutoLISP function?  😩

 

moshe

 

 

 

0 Likes
Message 3 of 4

cadffm
Consultant
Consultant
Accepted solution

Moshe-A and others are waiting for your answer..

 

Mistake1 - Moshe pointed to

1.1 You should no redefine native AutoCAD Lispfunctions

1.2 In this case, it doesn't make sense, also not with another symbole name,

      because you used this variable just one time in the code. For just one time,

      you don't need to bind a value to a symbole (aka variable).

cadffm_1-1742400454709.png

 

 

Mistake2

I am not sure whyt you tried here. WHY this? I ;;;comment this part

cadffm_0-1742400274543.png

 

Sebastian

0 Likes
Message 4 of 4

alashG39HJ
Explorer
Explorer

Oh my god, can't believe it was such a trival error.  Unfortunately i will not have acces to AC till tomorrow, so testing will have to wait. Thanks a lot for catching that!
About mistake2, in my mind it should delete the base element from drawing, so thanks to that  i will not end with two overlapping identicals block references across whole drawing. It worked, but maybe not because of this lines of code😅 I will test it further tomorrow, i made a lot of mess trying to find first error, maybe i should start from scratch. 

0 Likes