Author Topic: Attribute change batch  (Read 4911 times)

0 Members and 1 Guest are viewing this topic.

VerticalMojo

  • Guest
Attribute change batch
« on: February 23, 2007, 03:31:51 PM »
Hello swampers...

Okay, I thought I knew how to do this but for some reason I cant figure out an easy way and I am limited on time.

I have around 250 drawings that need the initials of an engineer in a attribute inside a block. What would be the easiest route to take?

Thanks for the help!

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #1 on: February 23, 2007, 03:32:27 PM »
scr file and small dvb I have to do it.  Ill post in a minute
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #2 on: February 23, 2007, 03:34:53 PM »
Code: [Select]
Public Function ACADSelSet(funcObjSelSet As AcadSelectionSet, funcSelectionSetName As String)
    Dim objSelCol As AcadSelectionSets

    On Error GoTo Err_Control

    Set objSelCol = ThisDrawing.SelectionSets
    For Each funcObjSelSet In objSelCol
        If funcObjSelSet.Name = funcSelectionSetName Then
            funcObjSelSet.Clear
            funcObjSelSet.Delete
            Exit For
        End If
    Next

    Set funcObjSelSet = objSelCol.Add(funcSelectionSetName)

Exit_Here:
    Exit Function
Err_Control:
    Select Case Err.Number
    Case -2145386300
        MsgBox "ACAD_Functions.ACADSelSet" & vbCrLf & Err.Number & " - " & Err.Description
    Case Else
        MsgBox "ACAD_Functions.ACADSelSet" & vbCrLf & Err.Number & " - " & Err.Description
        'ACADBugReportFiller "ACAD_Functions.ACADSelSet", Err.Number, Err.Description
    End Select

End Function

Public Function TagStringEdit( _
       strblockname As String, _
       strTagName As String, _
       Optional strOrigTagValue As String, _
       Optional strNewTagValue As String)

    Dim objSelSet As AcadSelectionSet
    Dim objBlkRef As AcadBlockReference
    Dim objAttRef As AcadAttributeReference
    Dim varAtts As Variant
    Dim varData(1) As Variant
    Dim intType(1) As Integer
    Dim intAElems As Integer

    On Error GoTo Err_Control

    ACADSelSet objSelSet, "vbdblkrefset"
    intType(0) = 0
    varData(0) = "INSERT"
    intType(1) = 2
    varData(1) = strblockname
    objSelSet.Select Mode:=acSelectionSetAll, filtertype:=intType, filterdata:=varData

    For Each objBlkRef In objSelSet
        If objBlkRef.HasAttributes Then
            varAtts = objBlkRef.GetAttributes
            For intAElems = LBound(varAtts) To UBound(varAtts)
                Set objAttRef = varAtts(intAElems)
                If objAttRef.TagString = strTagName Then
                    strOrigTagValue = objAttRef.TextString
                    If Len(strNewTagValue) > 0 Then
                        objAttRef.TextString = strNewTagValue
                        Exit For
                    End If
                End If
            Next intAElems
        End If
    Next objBlkRef

Exit_Here:
    Exit Function
Err_Control:
    Select Case Err.Number
    Case Else
        MsgBox "Blocks.TagStringEdit" & vbCrLf & Err.Number & " - " & Err.Description
    End Select

End Function

example of calling it
Code: [Select]
Private Sub cmdOK_Click()
    TagStringEdit "TITLINFO", "TECH", , cboTech.Value
    TagStringEdit "TITLINFO", "DFTM", , cboDraftman.Value
    TagStringEdit "TITLINFO", "CHKRNAME", , cboCheckedBy.Value
    TagStringEdit "TITLINFO", "TECHDATE", , TextBox8
    TagStringEdit "TITLINFO", "DFTMDATE", , TextBox8
    TagStringEdit "TITLINFO", "CHKRDATE", , TextBox8
    TagStringEdit "TITLINFO", "ENGNAME", , cboEng.Value
    Unload Me
End Sub
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #3 on: February 23, 2007, 03:36:32 PM »
basically, you call TagStringEdit and pass the BlockName, Tag your looking for, and Value to put in
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #4 on: February 23, 2007, 03:39:14 PM »
And if they are all in a folder or sub folder, you can batch it all within VBA
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #5 on: February 23, 2007, 03:40:07 PM »
You could script it, can call the VBA from LISP also
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

VerticalMojo

  • Guest
Re: Attribute change batch
« Reply #6 on: February 23, 2007, 03:41:56 PM »
Sorry, I am unfamiliar on how to begin using this, can you walk me through starting this? We recently obtained the full version of autocad 2006 here so dvb files are new to me and I rarely use scripts... only for small things.



David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #7 on: February 23, 2007, 03:43:50 PM »
Are all the files in one folder or sub folder?  Do you have them organized someway?  Do you have a list electronically to work from?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #8 on: February 23, 2007, 03:44:24 PM »
What is your block name, and Tag name? (Im making you a dvb file)
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

VerticalMojo

  • Guest
Re: Attribute change batch
« Reply #9 on: February 23, 2007, 03:46:30 PM »
all the files are in one folder.

Block name: recorddrawing
tag: by

I need to add the initials: KAH (capital letters)

thanks this is going to save me a bunch of time!

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #10 on: February 23, 2007, 03:52:35 PM »
Save this in your path
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #11 on: February 23, 2007, 03:52:57 PM »
If you rename it to acad.dvb it will autoload
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #12 on: February 23, 2007, 03:54:24 PM »
Script would look like
Quote
open dwgname1 (command "-vbarun" "Mario") qsave close
open dwgname2 (command "-vbarun" "Mario") qsave close
open dwgname3 (command "-vbarun" "Mario") qsave close
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #13 on: February 23, 2007, 03:58:10 PM »
And you can build a scr file REALLY fast by going to that folder in a DOS prompt, and typing in
Quote
Dir *.dwg /b /s > MT.scr
where MT.scr is name of scr file (any name works)  Note the spaces in the typing.  Then open notepad and Search/Replace the drive letter with open and drive letter, then .dwg with .dwg and rest of scr.  Save and run

Quote
example S/R
find u:\
replace w\  Open u:\

find .dwg
replace w\   .dwg" (command "-vbarun" "Mario") qsave close
« Last Edit: February 23, 2007, 11:53:49 PM by CmdrDuh »
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

VerticalMojo

  • Guest
Re: Attribute change batch
« Reply #14 on: February 23, 2007, 04:01:10 PM »
Thanks Im gonna give it a try...

VerticalMojo

  • Guest
Re: Attribute change batch
« Reply #15 on: February 23, 2007, 04:03:38 PM »
Save this in your path

Can you explain this?

sorry for the questions...

Guest

  • Guest
Re: Attribute change batch
« Reply #16 on: February 23, 2007, 04:06:33 PM »
I think he meant one of the AutoCAD preference paths - from the Options dialog box.

VerticalMojo

  • Guest
Re: Attribute change batch
« Reply #17 on: February 23, 2007, 04:15:50 PM »
I think he meant one of the AutoCAD preference paths - from the Options dialog box.

got it!

okay is there a way to get the drawing file names from explore?

VerticalMojo

  • Guest
Re: Attribute change batch
« Reply #18 on: February 23, 2007, 04:23:35 PM »
would I have to put each drawing file name into the script? is there a way to just add a folder?

uncoolperson

  • Guest
Re: Attribute change batch
« Reply #19 on: February 23, 2007, 04:39:24 PM »
would I have to put each drawing file name into the script? is there a way to just add a folder?

I believe that was this, right?

And you can build a scr file REALLY fast by going to that folder in a DOS prompt, and typing in
Quote
Dir *.dwg /b /s > MT.scr
where MT.scr is name of scr file (any name works)  Note the spaces in the typing.  Then open notepad and Search/Replace the drive letter with open and drive letter, then .dwg with .dwg and rest of scr.  Save and run

Quote
example S/R
find u:\
replace w\  Open u:\

find .dwg
replace w\   .dwg" (command "-vbarun" "Mario") qsave close


I need to add the initials: KAHN!!!!

sorry needed a star trek reference today..
« Last Edit: February 23, 2007, 11:54:47 PM by CmdrDuh »

VerticalMojo

  • Guest
Re: Attribute change batch
« Reply #20 on: February 23, 2007, 05:29:51 PM »
Thanks for all the help!

I talked to CmdrDuh on the phone and he walked me through it!

real cool stuff!
« Last Edit: February 23, 2007, 11:55:40 PM by CmdrDuh »

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Attribute change batch
« Reply #21 on: February 23, 2007, 11:57:01 PM »
Not a problem.  Thats what we are here for.  Glad it worked out so you could start your weekend on time.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)