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

vba select all not working

  • Thread starter Thread starter yag
  • Start date Start date

yag

Guest
I don't understand why I can make this code work.
....


filtertype(0) = 0: filterdata(0) = "insert"
set sset = thisdrawing.selectionsets.add("element")
sset.select acselectionsetall, filtertype, filterdata

dim array1 as variant
dim slinetowrite as string
Slinetowrite = "

for each element in sset
array1 = element.getattributes
....

I should travail attributes because there are but I want to select everything not v
works only if I put

sset.selectonscreen filtertype, filterdata

Then you will
 
I don't understand why I can make this code work.
....


filtertype(0) = 0: filterdata(0) = "insert"
set sset = thisdrawing.selectionsets.add("element")
sset.select acselectionsetall, filtertype, filterdata

dim array1 as variant
dim slinetowrite as string
Slinetowrite = "

for each element in sset
array1 = element.getattributes
....

I should travail attributes because there are but I want to select everything not v
works only if I put

sset.selectonscreen filtertype, filterdata

Then you will
Meanwhile welcome and maybe a message in the presentation section would not be bad.. .

cmq for your problem not seeing all the code is difficult to understand whether the problem is only there or not....

cmq the correct syntax is sset.select acselectionsetall, , filtertype, filterdata
in your code missing a comma

then doing the filter only on the block and not knowing if there are blocks that do not have attributes I would recommend you to use

for each element in ssetif element.hasattributes thenarray1 = element.getattributes


Then I recommend you

on error resume next
if not isnull(thisdrawing.selectionsets.item("element") then
set sset = thisdrawing.selectionsets.item("element")
sset.delete
end if

to eliminate any errors if the set does not empty at the end of the macro.

I mean... with what you wrote there is understandable above all I do not understand then how you go to read the attributes.... .

that cmq should be such a thing
for x = lbound(array1) to ubound(array1)
vartag=array1(x).tagstring
varval=array1(x).textstring
next x
 
Meanwhile welcome and maybe a message in the presentation section would not be bad.. .

cmq for your problem not seeing all the code is difficult to understand whether the problem is only there or not....

cmq the correct syntax is sset.select acselectionsetall, , filtertype, filterdata
in your code missing a comma

then doing the filter only on the block and not knowing if there are blocks that do not have attributes I would recommend you to use

for each element in ssetif element.hasattributes thenarray1 = element.getattributes


Then I recommend you

on error resume next
if not isnull(thisdrawing.selectionsets.item("element") then
set sset = thisdrawing.selectionsets.item("element")
sset.delete
end if

to eliminate any errors if the set does not empty at the end of the macro.

I mean... with what you wrote there is understandable above all I do not understand then how you go to read the attributes.... .

that cmq should be such a thing
for x = lbound(array1) to ubound(array1)
vartag=array1(x).tagstring
varval=array1(x).textstring
next x
I'm sorry for rudeness.
I'll tell you...

I can program premise only I have to understand how autocad works.. .

Basically what I should do is this:

create a mask to select files (dwg with blocks)
upload them to a listbox cycloclase each file and:

I need a hand, say,

- open it.
- read all the blocks
- extract all attributes
- export them into a csv file
- repeat for the next file until the end.. .

Thank you.
in advance now

r.
 
apertura documento

file=userform1.listbox1.item(y)
thisdrawing.application.documents.open (file)

slezione
on error resume next
if not isnull(thisdrawing.selectionsets.item("element")) then
set sset = thisdrawing.selectionsets.item("element")
sset.delete
end if

filtertype(0) = 0: filterdata(0) = "insert"
set sset = thisdrawing.selectionsets.add("element")

sset.select acselectionsetall, , , filtertype, filterdata

riempimento array

for each element in sset
if element.hasattributes then array1 = element.getattributes
next element

lettura array
for x = lbound(array1) to ubound(array1)
vartag=array1(x).tagstring (etichetta attributo)
varval=array1(x).textstring (valore attributo)
next x



l'export credo tu sappia farlo in autonomia, quello non dipende da autocad..
 
aggiornamento mancava questo comando:
set sset = thisdrawing.selectionsets.add("element")

ora funziona
 
aggiornamento mancava questo comando:
set sset = thisdrawing.selectionsets.add("element")

ora funziona

cmq secondo me la routine corretta è lòa seguente

public sub select_all()

dim filtertype(0) as integer
dim filterdata(0) as variant

dim sset as acadselectionset
dim element as acadblockreference

on error resume next
' delete the selection set if it exists
if not isnull(thisdrawing.selectionsets.item("element")) then
set sset = thisdrawing.selectionsets.item("element")
sset.delete
end if

set sset = thisdrawing.selectionsets.add("element")

filtertype(0) = 0
filterdata(0) = "insert"

sset.select acselectionsetall, , , filtertype, filterdata

msgbox ("elementi selezionati:" & sset.count)

end sub

questa ci metto la mano sul fuoco... però ci deve essere on error resume next prima del if not isnull(thisdrawing.selectionsets.item("element")) then
 
Hi.
or if you want to filter the whole design one or more blocks... .

set ssblock = thisdrawing.selectionsets.add("element")
filtertype(0) = -4
filterdata(0) = "<and"
filtertype(1) = 0
filterdata(1) = "insert"
filtertype(2)
filterdata(2) = "newcart" (block name)
filtertype(3) = 2
filterdata(3) = "newcart" (block name)
filtertype(4) = 4
filterdata(4) = "and>"

ssblock.select acselectionsetall, , filtertype, filterdata
 
Hi.
or if you want to filter the whole design one or more blocks... .

set ssblock = thisdrawing.selectionsets.add("element")
filtertype(0) = -4
filterdata(0) = "<and"
filtertype(1) = 0
filterdata(1) = "insert"
filtertype(2)
filterdata(2) = "newcart" (block name)
filtertype(3) = 2
filterdata(3) = "newcart" (block name)
filtertype(4) = 4
filterdata(4) = "and>"

ssblock.select acselectionsetall, , filtertype, filterdata
ios to try to emulate the find command of autocad (in the modified menu) but I can only search for an element not all those in the scene ...
 
Hi.
sincerely I never tried to emulate find... and cmq if I do not find any program find a voice at a time.
the above filter is another thing, it is suitable only for a selection of objects, in that case blocks
 

Forum statistics

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

Members online

No members online now.
Back
Top