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

line change inside the blocks

  • Thread starter Thread starter tiziano69
  • Start date Start date

tiziano69

Guest
Good morning, I have the following problem.. .
I want to change the line "pippo" (present inside the blocks) with the line "alpha".
This is because... because many times dwg drawings have been exported by micro and I find myself a number of typeliness that I would replace and it is unthinkable to enter into every single block search and change if that particular typeline is there.
I add, I don't want to rename the line you want it to be changed so at the end of processing it is not + used and I can "eliminate" permanently.

I tried to change this piece of code that needed to change scale factor to objects but I just can't figure out how to get into the blocks and analyze all the subentitas present within the block so that I can change properties


function change_typeline()

dim asa as an object

set oautocad = getobject(, "autocad.application")

set omodelspace = oautocad.activedocument.modelspace

set asa = oautocad.activedocument.blocks

number_entta = asa.count
for i = 1 to number
if asa.item(s)

end function
 
then, I wrote this part of code but I have a problem of " Indices" in scanning the entities present inside the block..... solved this, you can then change typeline from vba code

function write_text()

dim asa as an object
dim typeline as string

set oautocad = getobject(, "autocad.application")

set omodelspace = oautocad.activedocument.modelspace
set asa = oautocad.activedocument.blocks
dim nr_ent as integer


for inti = 1 to asa.count

if asa.item(inti).name <> "model_space" or asa.item(inti).name <> "paper_space" then
msgbox ("is a block")

for x = 1 to asa.item(inti).count
typelinea = asa.item(inti).item(x).linetype
msgbox (typeline)
next x

end if

next inti
end function
 
So here it is, I think it works, now it is to be improved replaces the two "inputbox" with the "tiline" panel of autocad to select the names of the line.

function change_typeline_blocchi()
dim asa as an object
dim typeline as string

set oautocad = getobject(, "autocad.application")
set omodelspace = oautocad.activedocument.modelspace
set asa = oautocad.activedocument.blocks

dim nr_ent as integer

name_typelinea_prec = inputbox("typeline name to be replaced")
new_typelinea = inputbox("new typeline name")

for inti = 0 to asa.count - 1

if asa.item(inti).name <> "model_space" or asa.item(inti).name <> "paper_space" then
'msgbox ("is a block")

for x = 0 to asa.item(inti).count - 1
typelinea = asa.item(inti).item(x).linetype

if asa.item(inti).item(x).linetype=typelinea_prec then
asa.item(inti).item(x).linetype = new_typelinea
asa.item(inti).item(x).highlight (true)
end if

'msgbox (typeline)
next x

end if

next inti

Thisdrawing. application.update
thisdrawing.regen acactiveviewport


end function
 
I rewrite it. with the holidays the concentration to tell you where wrong I do not have it;-) .

This code is more linear and simple than your (I believe) :-)
HTML:
function change_typeline_blocchi()

'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dim blocks as acadblocks
dim i as integer
set blocks = thisdrawing.blocks

dim name_typelinea_prec as string
dim new_typelinea as string
dim typeline as string

'user input
name_typelinea_prec = ucase(inputbox("typename to be replaced"))
new_typelinea = ucase(inputbox("new typeline name"))

' cycle that analyzes all the blocks of design
for i = 0 to blocks.count - 1

if block(s).name like "*model_space" or blocks(s).name like "*paper_space" then

♪
' cycle that analyzes all entities' of the block
for x = 0 to blocks(s).count - 1
typeline = blocks(s).item(x).linetype

if ucase(typeline) = name_typelinea_prec then
blocks(i).item(x).linetype = new_typelinea
end if
next x
end if

next i

thisdrawing.regen acactiveviewport

end function
 
allora ho ridotto il codice a questo, semplificando di molto e interagisce soltanto sui blocchi
funziona anche con la proprieta dalayer (attenzione ai caratteri)

private sub commandbutton2_click()
dim blk as acadblock
dim xrent as acadentity
dim b as string

a = inputbox("old")
b = inputbox("new")

for each blk in thisdrawing.blocks
if not blk.islayout then

for x = 0 to blk.count - 1

if blk.item(x).linetype = a then
blk.item(x).linetype = b
end if
next x

end if
next blk

thisdrawing.regen acactiveviewport
end sub
 

Forum statistics

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

Members online

No members online now.
Back
Top