Auto-Enrty of Drawing Numbers

Auto-Enrty of Drawing Numbers

Anonymous
Not applicable
508 Views
7 Replies
Message 1 of 8

Auto-Enrty of Drawing Numbers

Anonymous
Not applicable
I dont know if this possible, but this is what I would like to do:

When a drawing is opened (any drawing), through my computer, Mechanical
Desktop will search for either a text string or attribute and replace it
with the drawing's file name (less the .dwg).

I basically want to make a tool that will automatically fill in the drawing
number when the file is saved as its drawing number (eliminate the drawing
file name and the title block drawing number not matching)

--
Chris
0 Likes
509 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Use the BeginSave event to create a filtered selection set containing only your
title block(s). From there, iterate the set, retreive the attributes, iterate
the attributes until you find the tag you're interested in and change the
TextString property.

--
http://www.acadx.com
Win a free autographed copy of
"AutoCAD 2000 VBA Programmer's Reference"

"MaJicMrLn" wrote in message
news:[email protected]...
> I dont know if this possible, but this is what I would like to do:
>
> When a drawing is opened (any drawing), through my computer, Mechanical
> Desktop will search for either a text string or attribute and replace it
> with the drawing's file name (less the .dwg).
>
> I basically want to make a tool that will automatically fill in the drawing
> number when the file is saved as its drawing number (eliminate the drawing
> file name and the title block drawing number not matching)
>
> --
> Chris
>
0 Likes
Message 3 of 8

Anonymous
Not applicable
Thanx for the Help (as always)

Chris

"Frank Oquendo" wrote in message
news:[email protected]...
> Use the BeginSave event to create a filtered selection set containing only
your
> title block(s). From there, iterate the set, retreive the attributes,
iterate
> the attributes until you find the tag you're interested in and change the
> TextString property.
>
> --
> http://www.acadx.com
> Win a free autographed copy of
> "AutoCAD 2000 VBA Programmer's Reference"
>
> "MaJicMrLn" wrote in message
> news:[email protected]...
> > I dont know if this possible, but this is what I would like to do:
> >
> > When a drawing is opened (any drawing), through my computer, Mechanical
> > Desktop will search for either a text string or attribute and replace it
> > with the drawing's file name (less the .dwg).
> >
> > I basically want to make a tool that will automatically fill in the
drawing
> > number when the file is saved as its drawing number (eliminate the
drawing
> > file name and the title block drawing number not matching)
> >
> > --
> > Chris
> >
>
0 Likes
Message 4 of 8

Anonymous
Not applicable
Here's a code clip from one of the numerous tblock subs I've written. I usually
use the select case statement these days, it's less typing, but none the less, a
picture says a thousand words 🙂

If BlkRef.HasAttributes Then
AttArray = BlkRef.GetAttributes
For I = LBound(AttArray) To UBound(AttArray)
If AttArray(I).TagString = "TT2" Then
AttArray(I).TextString = DateTime.Date
ElseIf AttArray(I).TagString = "LDR_BY" Then
AttArray(I).TextString = "JDW"
ElseIf AttArray(I).TagString = "LCHKD_BY" Then
AttArray(I).TextString = "RMS"
ElseIf AttArray(I).TagString = "LDRAWN_DATE" Then
AttArray(I).TextString = DateTime.Date
ElseIf AttArray(I).TagString = "LCHKD_DATE" Then
AttArray(I).TextString = "AUG 99"
ElseIf AttArray(I).TagString = "TT17" Then
AttArray(I).TextString = "53020799/53020800"
ElseIf AttArray(I).TagString = "TT29" Then
AttArray(I).TextString = ThisDrawing.Application.Name
ElseIf AttArray(I).TagString = "TT1" Then
AttArray(I).TextString = "---------"
ElseIf AttArray(I).TagString = "TT26" Then
AttArray(I).TextString = "1999"
ElseIf AttArray(I).TagString = "TT3" Then
AttArray(I).TextString = "FULL"
ElseIf AttArray(I).TagString = "TT34" Then
AttArray(I).TextString = "--------"
ElseIf AttArray(I).TagString = "TT9" Then
AttArray(I).TextString = "130"
ElseIf AttArray(I).TagString = "TT10" Then
AttArray(I).TextString = "TBD"
ElseIf AttArray(I).TagString = "TT7" Then
AttArray(I).TextString = "RMS"
ElseIf AttArray(I).TagString = "TT6" Then
AttArray(I).TextString = "JDW"
ElseIf AttArray(I).TagString = "TT12" Then
AttArray(I).TextString =
ThisDrawing.Application.ActiveDocument.FullName
ElseIf AttArray(I).TagString = "TT4" Then
AttArray(I).TextString =
Mid$(ThisDrawing.Application.ActiveDocument.Name, 5, 2)

MaJicMrLn wrote:

> Thanx for the Help (as always)
>
> Chris
>
> "Frank Oquendo" wrote in message
> news:[email protected]...
> > Use the BeginSave event to create a filtered selection set containing only
> your
> > title block(s). From there, iterate the set, retreive the attributes,
> iterate
> > the attributes until you find the tag you're interested in and change the
> > TextString property.
> >
> > --
> > http://www.acadx.com
> > Win a free autographed copy of
> > "AutoCAD 2000 VBA Programmer's Reference"
> >
> > "MaJicMrLn" wrote in message
> > news:[email protected]...
> > > I dont know if this possible, but this is what I would like to do:
> > >
> > > When a drawing is opened (any drawing), through my computer, Mechanical
> > > Desktop will search for either a text string or attribute and replace it
> > > with the drawing's file name (less the .dwg).
> > >
> > > I basically want to make a tool that will automatically fill in the
> drawing
> > > number when the file is saved as its drawing number (eliminate the
> drawing
> > > file name and the title block drawing number not matching)
> > >
> > > --
> > > Chris
> > >
> >
0 Likes
Message 5 of 8

Anonymous
Not applicable
How do you identify that the BlkRef refers to the Title Block???

Chris

"Minkwitz Design" wrote in message
news:[email protected]...
> Here's a code clip from one of the numerous tblock subs I've written. I
usually
> use the select case statement these days, it's less typing, but none the
less, a
> picture says a thousand words 🙂
>
> If BlkRef.HasAttributes Then
> AttArray = BlkRef.GetAttributes
> For I = LBound(AttArray) To UBound(AttArray)
> If AttArray(I).TagString = "TT2" Then
> AttArray(I).TextString = DateTime.Date
> ElseIf AttArray(I).TagString = "LDR_BY" Then
> AttArray(I).TextString = "JDW"
> ElseIf AttArray(I).TagString = "LCHKD_BY" Then
> AttArray(I).TextString = "RMS"
> ElseIf AttArray(I).TagString = "LDRAWN_DATE" Then
> AttArray(I).TextString = DateTime.Date
> ElseIf AttArray(I).TagString = "LCHKD_DATE" Then
> AttArray(I).TextString = "AUG 99"
> ElseIf AttArray(I).TagString = "TT17" Then
> AttArray(I).TextString = "53020799/53020800"
> ElseIf AttArray(I).TagString = "TT29" Then
> AttArray(I).TextString =
ThisDrawing.Application.Name
> ElseIf AttArray(I).TagString = "TT1" Then
> AttArray(I).TextString = "---------"
> ElseIf AttArray(I).TagString = "TT26" Then
> AttArray(I).TextString = "1999"
> ElseIf AttArray(I).TagString = "TT3" Then
> AttArray(I).TextString = "FULL"
> ElseIf AttArray(I).TagString = "TT34" Then
> AttArray(I).TextString = "--------"
> ElseIf AttArray(I).TagString = "TT9" Then
> AttArray(I).TextString = "130"
> ElseIf AttArray(I).TagString = "TT10" Then
> AttArray(I).TextString = "TBD"
> ElseIf AttArray(I).TagString = "TT7" Then
> AttArray(I).TextString = "RMS"
> ElseIf AttArray(I).TagString = "TT6" Then
> AttArray(I).TextString = "JDW"
> ElseIf AttArray(I).TagString = "TT12" Then
> AttArray(I).TextString =
> ThisDrawing.Application.ActiveDocument.FullName
> ElseIf AttArray(I).TagString = "TT4" Then
> AttArray(I).TextString =
> Mid$(ThisDrawing.Application.ActiveDocument.Name, 5, 2)
>
> MaJicMrLn wrote:
>
> > Thanx for the Help (as always)
> >
> > Chris
> >
> > "Frank Oquendo" wrote in message
> > news:[email protected]...
> > > Use the BeginSave event to create a filtered selection set containing
only
> > your
> > > title block(s). From there, iterate the set, retreive the attributes,
> > iterate
> > > the attributes until you find the tag you're interested in and change
the
> > > TextString property.
> > >
> > > --
> > > http://www.acadx.com
> > > Win a free autographed copy of
> > > "AutoCAD 2000 VBA Programmer's Reference"
> > >
> > > "MaJicMrLn" wrote in message
> > > news:[email protected]...
> > > > I dont know if this possible, but this is what I would like to do:
> > > >
> > > > When a drawing is opened (any drawing), through my computer,
Mechanical
> > > > Desktop will search for either a text string or attribute and
replace it
> > > > with the drawing's file name (less the .dwg).
> > > >
> > > > I basically want to make a tool that will automatically fill in the
> > drawing
> > > > number when the file is saved as its drawing number (eliminate the
> > drawing
> > > > file name and the title block drawing number not matching)
> > > >
> > > > --
> > > > Chris
> > > >
> > >
>
0 Likes
Message 6 of 8

Anonymous
Not applicable
Sorry, with the following declarations :
Dim Obj As Object
Dim BlkRef As AcadBlockReference

You would use:
For Each Obj In 'the name of your filtered sset (which is faster in big
drawings) _
or ThisDrawing.ModelSpace if you don't have a sset of the blocks
If TypeOf Obj Is AcadBlockReference Then 'you only need this if you
didn't filter for blocks
Set BlkRef = Obj
'you can also check the name of the block here if you didn't
filter for it by using:
'if blkref.name = "yattayatta"
If BlkRef.HasAttributes Then

If you've already built a filtered selection set, which contains only blocks
with your title block, you can shorten all this to just:

for each blkref in sset

But you can not use for each blkref in thisdrawing.modelspace, because the
first time the loops sees a entity that is not a block reference, you will get
a type mismatch error. Are you doing this to a large number of drawings? Do you
have MS Office on your system? If so, I may have something pretty much tailored
to what you want, I would just need to clear out customer stuff and post it. If
you want, just post the block name of your title block and I'll post back after
lunch. Then you'll just have to patch it up with your tag names and the info
you want filled in.
-Josh 🙂

MaJicMrLn wrote:

> How do you identify that the BlkRef refers to the Title Block???
>
> Chris
>
> "Minkwitz Design" wrote in message
> news:[email protected]...
> > Here's a code clip from one of the numerous tblock subs I've written. I
> usually
> > use the select case statement these days, it's less typing, but none the
> less, a
> > picture says a thousand words 🙂
> >
> > If BlkRef.HasAttributes Then
> > AttArray = BlkRef.GetAttributes
> > For I = LBound(AttArray) To UBound(AttArray)
> > If AttArray(I).TagString = "TT2" Then
> > AttArray(I).TextString = DateTime.Date
> > ElseIf AttArray(I).TagString = "LDR_BY" Then
> > AttArray(I).TextString = "JDW"
> > ElseIf AttArray(I).TagString = "LCHKD_BY" Then
> > AttArray(I).TextString = "RMS"
> > ElseIf AttArray(I).TagString = "LDRAWN_DATE" Then
> > AttArray(I).TextString = DateTime.Date
> > ElseIf AttArray(I).TagString = "LCHKD_DATE" Then
> > AttArray(I).TextString = "AUG 99"
> > ElseIf AttArray(I).TagString = "TT17" Then
> > AttArray(I).TextString = "53020799/53020800"
> > ElseIf AttArray(I).TagString = "TT29" Then
> > AttArray(I).TextString =
> ThisDrawing.Application.Name
> > ElseIf AttArray(I).TagString = "TT1" Then
> > AttArray(I).TextString = "---------"
> > ElseIf AttArray(I).TagString = "TT26" Then
> > AttArray(I).TextString = "1999"
> > ElseIf AttArray(I).TagString = "TT3" Then
> > AttArray(I).TextString = "FULL"
> > ElseIf AttArray(I).TagString = "TT34" Then
> > AttArray(I).TextString = "--------"
> > ElseIf AttArray(I).TagString = "TT9" Then
> > AttArray(I).TextString = "130"
> > ElseIf AttArray(I).TagString = "TT10" Then
> > AttArray(I).TextString = "TBD"
> > ElseIf AttArray(I).TagString = "TT7" Then
> > AttArray(I).TextString = "RMS"
> > ElseIf AttArray(I).TagString = "TT6" Then
> > AttArray(I).TextString = "JDW"
> > ElseIf AttArray(I).TagString = "TT12" Then
> > AttArray(I).TextString =
> > ThisDrawing.Application.ActiveDocument.FullName
> > ElseIf AttArray(I).TagString = "TT4" Then
> > AttArray(I).TextString =
> > Mid$(ThisDrawing.Application.ActiveDocument.Name, 5, 2)
> >
> > MaJicMrLn wrote:
> >
> > > Thanx for the Help (as always)
> > >
> > > Chris
> > >
> > > "Frank Oquendo" wrote in message
> > > news:[email protected]...
> > > > Use the BeginSave event to create a filtered selection set containing
> only
> > > your
> > > > title block(s). From there, iterate the set, retreive the attributes,
> > > iterate
> > > > the attributes until you find the tag you're interested in and change
> the
> > > > TextString property.
> > > >
> > > > --
> > > > http://www.acadx.com
> > > > Win a free autographed copy of
> > > > "AutoCAD 2000 VBA Programmer's Reference"
> > > >
> > > > "MaJicMrLn" wrote in message
> > > > news:[email protected]...
> > > > > I dont know if this possible, but this is what I would like to do:
> > > > >
> > > > > When a drawing is opened (any drawing), through my computer,
> Mechanical
> > > > > Desktop will search for either a text string or attribute and
> replace it
> > > > > with the drawing's file name (less the .dwg).
> > > > >
> > > > > I basically want to make a tool that will automatically fill in the
> > > drawing
> > > > > number when the file is saved as its drawing number (eliminate the
> > > drawing
> > > > > file name and the title block drawing number not matching)
> > > > >
> > > > > --
> > > > > Chris
> > > > >
> > > >
> >
0 Likes
Message 7 of 8

Anonymous
Not applicable
Beware!! I created a mess using the SELECT method in BeginSave. Everything worked fine until autosave kicked in. Autosave also triggers the BeginSave event, and somehow doing a select in the BeginSave event causes an infinite loop during an autosave.
0 Likes
Message 8 of 8

Anonymous
Not applicable
Unless I'm missing something in your request, it
seems like you don't need code at all for this. I use Rtext for this kind of
thing, from the express tools menu (stands for reactive text).

 

Type RTEXT, then D for Diesel, then type this in
dialog box:


size=2>$(substr,$(getvar,dwgname),1,$(-,$(strlen,$(getvar,dwgname)),4))

 

this will return just the drawing name, minus the
extension.
0 Likes