Results 1 to 2 of 2

Thread: Change an Attibute value by its Attribute tag in multiple drawings

  1. #1
    Member
    Join Date
    2016-05
    Posts
    4
    Login to Give a bone
    0

    Cool Change an Attibute value by its Attribute tag in multiple drawings

    Hi I have something like 160 separate dxf files. Each one of them has a common attribute that exist in each file that I need to edit/change/update from time to time.

    They are self contained files that can be inserted into other drawings as blocks, but are not blocks of themselves, each file is jsut a simple collection of geometry and some visible text attiributes.

    My problem (other than opening 160 file and editing the attribute text value) is that Id like to be able to automate this in some way. I have the scriptpro tool that can do some useful stuff like do a save as for hundreds of files at a time.

    Anyone know of lisp routine (must admit I dont know much about lisp) that may be able to do this. IF I could call the list routine from script pro, I can feed it the file names and it can run a simple bit of lisp to search each file in turn for my attribute tag name, and set it to a new default value (common to all of them). Then it could be automated.

    Any ideas or suggestions would be welcolmed.

    Currently running ACAD MEP 2015.

    Thanks

  2. #2
    Member
    Join Date
    2016-05
    Posts
    4
    Login to Give a bone
    0

    Default Re: Change an Attibute value by its Attribute tag in multiple drawings

    ok As I can write a bit of VB Ive actually sorted this out:
    If its of interest to anyone else
    I use Scriptpro to run the vba command : from the command line: (see the simple script below which is called for each and every dxf file in the task list)

    -vbarun D:\AutoDesk\Attribs.dvb!UpdateAttribs.UpdateAttibs
    save

    Heres the vba Code to actually search for my named attirbute and to update it. I just needed them all to be reset to have no value

    Public Sub UpdateAttibs()
    Dim AttTagName As String
    Dim AttValue As String
    Dim Cntr As Integer

    AttTagName = "TAGNAME"
    AttValue = ""
    Dim sset As AcadSelectionSet
    Set sset = ThisDrawing.SelectionSets.Add("FindAttrib")

    Dim filterType As Variant
    Dim filterData As Variant
    Dim p1(0 To 2) As Double
    Dim p2(0 To 2) As Double

    Dim grpCode(0) As Integer
    grpCode(0) = 2 'see DXF file specs for group codes this is fot text or att defs
    filterType = grpCode

    Dim grpValue(0) As Variant
    grpValue(0) = AttTagName
    filterData = grpValue

    sset.Select acSelectionSetAll, p1, p2, filterType, filterData

    If sset.Count = 1 Then
    'should only be one tag name 0 based index
    sset(0).TextString = AttValue
    sset(0).Update
    'ThisDrawing.Save
    Debug.Print "Entities: " & Str(sset.Count) & " updated"
    End If



    sset.Delete


    End Sub

Similar Threads

  1. Making the same change in multiple drawings
    By Darren Allen in forum AutoLISP
    Replies: 6
    Last Post: 2014-03-02, 01:15 AM
  2. Replies: 13
    Last Post: 2012-09-18, 07:51 PM
  3. Changing attribute tags in multiple drawings
    By caburke in forum AutoCAD General
    Replies: 5
    Last Post: 2012-05-01, 05:10 PM
  4. Replies: 13
    Last Post: 2009-12-14, 12:39 AM
  5. Replies: 8
    Last Post: 2006-05-29, 05:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •