block names

block names

Anonymous
Not applicable
263 Views
8 Replies
Message 1 of 9

block names

Anonymous
Not applicable
Using autocad14 how do I go through every block in a drawing and if the
block name is over 31 characters I want to rename it to "block1", "block2",
etc..... Any help is appreciated.
Thanks,
Rob
0 Likes
264 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
This code should do the task. It does NOT however check to see if there
already is a block named "BlockX" before it renames one of the blocks:

Option Explicit

Sub RenameBlocks()

Dim oBlock As AcadBlock
Dim oBlocks As AcadBlocks
Dim intCounter As Integer

Set oBlocks = ThisDrawing.Blocks
intCounter = 1

For Each oBlock In oBlocks
If Not oBlock.IsXRef And Not oBlock.IsLayout Then
If Len(oBlock.Name) > 31 Then
oBlock.Name = "Block" & CStr(intCounter)
intCounter = intCounter + 1
End If
End If
Next

End Sub

Trond Hasse Lie
Thrane Information Systems
Norway

"Hairball" wrote in message
news:ef344b5.-1@WebX.SaUCah8kaAW...
> Using autocad14 how do I go through every block in a drawing and if the
> block name is over 31 characters I want to rename it to "block1",
"block2",
> etc..... Any help is appreciated.
> Thanks,
> Rob
>
0 Likes
Message 3 of 9

Anonymous
Not applicable
This will not do you much good since you cannot have a block name of more
than 31 characters in AutoCAD R14. Not sure what you are trying to acheive.

Joe

"Trond Hasse Lie" wrote in message
news:ef344b5.0@WebX.SaUCah8kaAW...
> This code should do the task. It does NOT however check to see if there
> already is a block named "BlockX" before it renames one of the blocks:
>
> Option Explicit
>
> Sub RenameBlocks()
>
> Dim oBlock As AcadBlock
> Dim oBlocks As AcadBlocks
> Dim intCounter As Integer
>
> Set oBlocks = ThisDrawing.Blocks
> intCounter = 1
>
> For Each oBlock In oBlocks
> If Not oBlock.IsXRef And Not oBlock.IsLayout Then
> If Len(oBlock.Name) > 31 Then
> oBlock.Name = "Block" & CStr(intCounter)
> intCounter = intCounter + 1
> End If
> End If
> Next
>
> End Sub
>
> Trond Hasse Lie
> Thrane Information Systems
> Norway
>
> "Hairball" wrote in message
> news:ef344b5.-1@WebX.SaUCah8kaAW...
> > Using autocad14 how do I go through every block in a drawing and if the
> > block name is over 31 characters I want to rename it to "block1",
> "block2",
> > etc..... Any help is appreciated.
> > Thanks,
> > Rob
> >
>
0 Likes
Message 4 of 9

Anonymous
Not applicable
🙂 I didn't the AutoCAD 14 bit..... but it MIGHT be a typo?

Trond Hasse Lie
Norway

"Joe Sutphin" wrote in message
news:ef344b5.1@WebX.SaUCah8kaAW...
> This will not do you much good since you cannot have a block name of more
> than 31 characters in AutoCAD R14. Not sure what you are trying to
acheive.
>
> Joe
>
> "Trond Hasse Lie" wrote in message
> news:ef344b5.0@WebX.SaUCah8kaAW...
> > This code should do the task. It does NOT however check to see if there
> > already is a block named "BlockX" before it renames one of the blocks:
> >
> > Option Explicit
> >
> > Sub RenameBlocks()
> >
> > Dim oBlock As AcadBlock
> > Dim oBlocks As AcadBlocks
> > Dim intCounter As Integer
> >
> > Set oBlocks = ThisDrawing.Blocks
> > intCounter = 1
> >
> > For Each oBlock In oBlocks
> > If Not oBlock.IsXRef And Not oBlock.IsLayout Then
> > If Len(oBlock.Name) > 31 Then
> > oBlock.Name = "Block" & CStr(intCounter)
> > intCounter = intCounter + 1
> > End If
> > End If
> > Next
> >
> > End Sub
> >
> > Trond Hasse Lie
> > Thrane Information Systems
> > Norway
> >
> > "Hairball" wrote in message
> > news:ef344b5.-1@WebX.SaUCah8kaAW...
> > > Using autocad14 how do I go through every block in a drawing and if
the
> > > block name is over 31 characters I want to rename it to "block1",
> > "block2",
> > > etc..... Any help is appreciated.
> > > Thanks,
> > > Rob
> > >
> >
>
0 Likes
Message 5 of 9

Anonymous
Not applicable
no, it's not a typo. if you convert a 2000 drawing to 14 it will keep the
block names too long so at work i can't xref things in. that's why i'm
making this program.
Rob
0 Likes
Message 6 of 9

Anonymous
Not applicable
this doesn't work. is it different for autocad r14?
Rob

Trond Hasse Lie wrote in message
news:ef344b5.0@WebX.SaUCah8kaAW...
> This code should do the task. It does NOT however check to see if there
> already is a block named "BlockX" before it renames one of the blocks:
>
> Option Explicit
>
> Sub RenameBlocks()
>
> Dim oBlock As AcadBlock
> Dim oBlocks As AcadBlocks
> Dim intCounter As Integer
>
> Set oBlocks = ThisDrawing.Blocks
> intCounter = 1
>
> For Each oBlock In oBlocks
> If Not oBlock.IsXRef And Not oBlock.IsLayout Then
> If Len(oBlock.Name) > 31 Then
> oBlock.Name = "Block" & CStr(intCounter)
> intCounter = intCounter + 1
> End If
> End If
> Next
>
> End Sub
>
> Trond Hasse Lie
> Thrane Information Systems
> Norway
>
> "Hairball" wrote in message
> news:ef344b5.-1@WebX.SaUCah8kaAW...
> > Using autocad14 how do I go through every block in a drawing and if the
> > block name is over 31 characters I want to rename it to "block1",
> "block2",
> > etc..... Any help is appreciated.
> > Thanks,
> > Rob
> >
>
0 Likes
Message 7 of 9

Anonymous
Not applicable
The code doesn't work in 14. As far as I can see, the BlockRenaming must be
done in 2000 before saving to 14 format.

And... When I tested, I made a block in 2000 with a 32 character name. When
opening the drawing in 14, the blocks name consisted of only the 26 first
charaters. Don't know why.....

Trond Hasse Lie
Norway

"Rob" wrote in message
news:ef344b5.4@WebX.SaUCah8kaAW...
> this doesn't work. is it different for autocad r14?
> Rob
>
> Trond Hasse Lie wrote in message
> news:ef344b5.0@WebX.SaUCah8kaAW...
> > This code should do the task. It does NOT however check to see if there
> > already is a block named "BlockX" before it renames one of the blocks:
> >
> > Option Explicit
> >
> > Sub RenameBlocks()
> >
> > Dim oBlock As AcadBlock
> > Dim oBlocks As AcadBlocks
> > Dim intCounter As Integer
> >
> > Set oBlocks = ThisDrawing.Blocks
> > intCounter = 1
> >
> > For Each oBlock In oBlocks
> > If Not oBlock.IsXRef And Not oBlock.IsLayout Then
> > If Len(oBlock.Name) > 31 Then
> > oBlock.Name = "Block" & CStr(intCounter)
> > intCounter = intCounter + 1
> > End If
> > End If
> > Next
> >
> > End Sub
> >
> > Trond Hasse Lie
> > Thrane Information Systems
> > Norway
> >
> > "Hairball" wrote in message
> > news:ef344b5.-1@WebX.SaUCah8kaAW...
> > > Using autocad14 how do I go through every block in a drawing and if
the
> > > block name is over 31 characters I want to rename it to "block1",
> > "block2",
> > > etc..... Any help is appreciated.
> > > Thanks,
> > > Rob
> > >
> >
>
0 Likes
Message 8 of 9

Anonymous
Not applicable
and if you try to xref that drawing into another drawing it says the block
name is too long. so what's going on?
Rob

Trond Hasse Lie wrote in message
news:4B8B4A7113723585ED51AF5BE6010C5A@in.WebX.SaUCah8kaAW...
> The code doesn't work in 14. As far as I can see, the BlockRenaming must
be
> done in 2000 before saving to 14 format.
>
> And... When I tested, I made a block in 2000 with a 32 character name.
When
> opening the drawing in 14, the blocks name consisted of only the 26 first
> charaters. Don't know why.....
>
> Trond Hasse Lie
> Norway
>
> "Rob" wrote in message
> news:ef344b5.4@WebX.SaUCah8kaAW...
> > this doesn't work. is it different for autocad r14?
> > Rob
> >
> > Trond Hasse Lie wrote in message
> > news:ef344b5.0@WebX.SaUCah8kaAW...
> > > This code should do the task. It does NOT however check to see if
there
> > > already is a block named "BlockX" before it renames one of the blocks:
> > >
> > > Option Explicit
> > >
> > > Sub RenameBlocks()
> > >
> > > Dim oBlock As AcadBlock
> > > Dim oBlocks As AcadBlocks
> > > Dim intCounter As Integer
> > >
> > > Set oBlocks = ThisDrawing.Blocks
> > > intCounter = 1
> > >
> > > For Each oBlock In oBlocks
> > > If Not oBlock.IsXRef And Not oBlock.IsLayout Then
> > > If Len(oBlock.Name) > 31 Then
> > > oBlock.Name = "Block" & CStr(intCounter)
> > > intCounter = intCounter + 1
> > > End If
> > > End If
> > > Next
> > >
> > > End Sub
> > >
> > > Trond Hasse Lie
> > > Thrane Information Systems
> > > Norway
> > >
> > > "Hairball" wrote in message
> > > news:ef344b5.-1@WebX.SaUCah8kaAW...
> > > > Using autocad14 how do I go through every block in a drawing and if
> the
> > > > block name is over 31 characters I want to rename it to "block1",
> > > "block2",
> > > > etc..... Any help is appreciated.
> > > > Thanks,
> > > > Rob
> > > >
> > >
> >
>
0 Likes
Message 9 of 9

Anonymous
Not applicable
Autodesk released a patch to R14, called BindTPtch.arx, which neatly
addressed this problem.

see (watch for word wrap):
http://www3.autodesk.com/adsk/support/techdoc/0,,116068--273818-0_21837,00.h
tml

--
R. Robert Bell, MCSE
Xtending the Power
www.acadx.com

"Rob" wrote in message
news:ef344b5.3@WebX.SaUCah8kaAW...
| no, it's not a typo. if you convert a 2000 drawing to 14 it will keep the
| block names too long so at work i can't xref things in. that's why i'm
| making this program.
| Rob
|
0 Likes