• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

program to rename blocks

  • Thread starter Thread starter tiziano69
  • Start date Start date

tiziano69

Guest
Good morning

I attach a small utility to rename autocad blocks, draw a list.

does not provide for controls on the existence of blocks with the same name.... It should be improved, however, and functional, especially when there are a number of blocks encoded with committed codes that must be changed.

it would be interesting to insert also a window to have the preview of the block that you go to rename.... who is able....
 

Attachments

I didn't understand well if you created from 0 this macro (but I think not) I think you integrated only the part of the rename.... I tell you this because most of the list is solved with 5 lines of code to read and insert in a list box the collection of blocks of a dwg
Code:
dim i as integer
dim s1 as string
for i = 0 to thisdrawing.blocks.count - 1
    s1 = thisdrawing.blocks.item(i).name
    userform1.listbox1.additem s1
next i
by them just do what you did to rename with name1 and name2

the macro mail takes a lot of time to fill the list this code 2 seconds. The only difference is that the order is not made but it can be integrated with a list support box.

I am for simple and lightweight things, unnecessarily weight the code and decrease machine performance unnecessarily do not like it much.

so if it is all flour of your sack (compliments really nice code and written well) do not copy pieces of code here and without being really sure of what they do and why.
 
I'll break again. the bottleneck is definitely here
Code:
 [COLOR="Red"]for each acadobject in thisdrawing.modelspace[/COLOR]
        if acadobject.objectname = "acdbblockreference" then
            on error resume next    ' simple way to avoid duplcates in collection
           blocklist.add acadobject.name, acadobject.name
        end if
    next
as you see here you analyze all the objects of the drawing, then you filter the only blocks, thinks you have a dwg with 10,000 objects and only 20 of these are blocks, you light 9.980 objects in vain.
 
I used part of existing code. . However if it is better well come, it would also be interesting to add a preview of the block but I did not find controls in degrees to be able to do it.
Besides, can you make a query to filter the block list?
 
can you make a query to filter the block list?
you want to see only those who start with a string e.g. 123evidence?

if it is what you meant yes, you can also search for a string contained example "try123test" however this means doing a job that requires more car back because you have to pass all the names along with a string equal to the filter... But you can do it.
 
filter the listbox data through a combobox and the search key should not have a mandatory position.

Is it feasible?
 
Okay, it just remains the problem of the preview of the block, I thought it was more simple since there is already in the insertion of the block, but so it is not....

I'm kind of documenting. . .

for now the code to this point

to use it you must do as follows:

load the macro from autocad

tools-> macro-> project loading

tools->macro->editor of visual basic (alt+f11)

from the editor go on tools->references and you should find a carcad 20... type library missing, select your version

I use a 64-bit 2012 and it's almost certainly not compatible with yours, you should be fine.

p.s. the filter read uppercase and lowercase, if you want me to ignore the difference

change the line
Code:
if mid(s1, x, len(textbox3.text)) = textbox3.text then userform1.listbox1.additem s1

in 

if [COLOR="Red"]ucase([/COLOR]mid(s1, x, len(textbox3.text)) [COLOR="Red"])[/COLOR]= [COLOR="Red"]ucase([/COLOR]textbox3.text[COLOR="Red"])[/COLOR] then userform1.listbox1.additem s1
 

Attachments

ok good the application of the filter, but now the names of the blocks appear according to a random order, I believe is that of the database of autocad and also in case there are xrifs, also appear the names of xrif.

How do you think that's helpful?
 
How do you think that's helpful?
Well, I don't know, it depends on what you have to do.
for me it is not useful I have applications of this kind to do, I think I have renamed a few blocks since I use autocad... but for you maybe it is very much!!!

cmq I found two roads for the preview of the block:

1: Create a temporary wmf image of the block and then upload it
2:extract the block in a temporary file and view it as dwg files extenuate in the mask... pèare that there is no way to preview the block.

Tell me what you want
 
I believe the first solution is better because it does not create external dwg that then stay around the computer. can you make sure that by scrolling the block list, a wmf is generated for each single block? I'm curious.

however thanks to the availability and interest. then I wouldn't have another interesting thing to rekindle the autocads
 
then for cleaning issue it is better the extenuating dwg in the sense that creates it displays it and deletes it to make an image I have to put it in the drawing, export it and upload it ocme image, if you have to do many times the operation could become heavy, with the wblock instead it is lighter in my opinion.

the difference is in the viewer one uses an image control, the other autocad dwgthumbnail.

Tell me
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top