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

function to change texts

  • Thread starter Thread starter ale
  • Start date Start date

ale

Guest
chiedo un piccolo aiuto. :smile:

all' interno di un file .dwg (autocad 2009) ho inserito alcuni testi (riga singola di testo) in ordine sparso :
r, m , v

l' intenzione sarebbe di cambiarli con questa funzione :

public function w(k as string) as string
if k = "r" then w = "roma"
if k = "m" then w = "milano"
if k = "v" then w = "venezia"
end function

inserita in questa routine

public sub y()
dim ss as acadselectionset
dim k as acadtext
dim w as string
set ss = thisdrawing.selectionsets.add("pp")
ss.selectonscreen
k (w)
ss.delete
end sub

il problema che non riesco a risolvere è su k(w) e poi sembra che anche ss.delete non elimini il selectionset.

mi sapreste aiutare ?
 
guarda, io farei una cosa del genere... se non ci devi perdere molto tempo sopra, si può integrarfe un selectcase al posto del ciclo if then... ma se el condizioni sono solo queste 3 va bene anche così

quello che hai scritto sopra... non può assolutamente funzionare...

public sub y()

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

dim sset as acadselectionset
dim element as acadtext

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) = "text"

sset.select acselectionsetall, , , filtertype, filterdata

for each element in sset
if element.textstring = "r" then element.textstring = "roma"
if element.textstring = "m" then element.textstring = "milano"
if element.textstring = "v" then element.textstring = "venezia"
next element

end sub
 
in particolare utilizzando la falsa riga di quel che intendevi fare...

'dichiarazioni pubbliche
dim sset as acadselectionset
dim element as acadtext

public sub y()

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

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) = "text"

sset.select acselectionsetall, , , filtertype, filterdata

for each element in sset
call k(element.textstring)
next element

end sub


public sub k(stringa as string)

select case stringa
case "r"
element.textstring = "roma"
case "m"
element.textstring = "milano"
case "v"
element.textstring = "venezia"
end select

end sub
 

Forum statistics

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

Members online

No members online now.
Back
Top