Batch Renaming of Xref Drawings' "Saved Paths"

Discussion in 'AutoCAD' started by kzalec, Nov 9, 2004.

  1. kzalec

    kzalec Guest

    We are faced with a problem at work. Hundreds of drawings have been created with lots of XREFs "Overlayed" in each drawing. The client is now saying that they have a different standard for naming drawings that are used as XREFs. We can easily use Windows Explore to rename the XREF files in the XREF directory. However, once we do that, none of those XREFs will be found when we open the (hundreds of) drawings which have them "Overlayed". We'd like to find some way to BATCH rename the XREFs (Saved Path name) inside AutoCAD. Please note that we aren't concerned with the "Reference Name" inside the "Xref Manager" dialog box. We are only concerned with the name of the XREFs as they appear in the "Saved Path" part of the "Xref Manager" dialog box. I think this is going to be very difficult, if not impossible. But if there are any AutoLISP geniuses out there, perhaps you may know a way to do this. We are hoping that we don't have to manually reoverlay/reattach every Xref file after renaming the Xref files in Windows Explore.
     
    kzalec, Nov 9, 2004
    #1
  2. kzalec

    T.Willey Guest

    I'm no genius, but I think it might be easy as long as no one has the drawings open. Maybe do it over night. Set it up to open all the drawings you want, search for all the xref listed in the drawing. Have a list that has the new name and the old ones. The use the (vl-file-rename to rename the files, then save that to the xref path of the xref. Maybe even set it up so that it will make a txt file for the list and tell which one's were renamed and which one's weren't.

    Just thinking out loud.
    Tim
     
    T.Willey, Nov 9, 2004
    #2
  3. kzalec

    kzalec Guest

    Unfortunately, I'm not good enough at AutoLISP or any other programming language to be able to do what you have described. I'm sure it could be done, but no doubt, it would require a lot of code.
     
    kzalec, Nov 9, 2004
    #3
  4. kzalec

    T.Willey Guest

    Do you have a list of a couple for drawing names that will change, say like three. I might have some time and would like to try some things, but I'm not sure how soon I can finish it, but I might be able to get it started and some one could jump in. There might already be a solution out there, so you might want to check some more to see if there is a program that you could use, either buy or freeware.

    Tim
     
    T.Willey, Nov 9, 2004
    #4
  5. kzalec

    kzalec Guest

    Okay, here are three examples. The first part is the old file name and the second part is the new file name:
    1. X-ALIGN-HORZ.DWG (old)......X300-S-TS-W001.DWG (new) 2. X-ALIGN-HORZ (SITE20).DWG (old).....X300-S-TS-W002.DWG (new) 3. X-ALIGN-HORZ (SITE40).DWG (old)......X300-S-TS-W003.DWG (new). Perhaps we can work it out as a team effort. Thanks again for your help.
     
    kzalec, Nov 9, 2004
    #5
  6. kzalec

    Rudy Tovar Guest

    Just use dbx, and rename them in 2 seconds...

    Ok, maybe 3 seconds...

    Use part of the code I gave to Willey, and access the object properties, and
    rename the path or name, whatever...

    Use the vl-directory...etc. function to gather all the files, and then
    simply use (while (nth <count> <list>) ;Mod Object Properties)

    If you really want to get technical about the order use a excel.csv file
    with "," delimitation and sort by those fields.

    --
    MASi
    Copyright 2004 by Cadentity
    www.Cadentity.com
    Autodesk
    Authorized Developer
     
    Rudy Tovar, Nov 9, 2004
    #6
  7. kzalec

    hulioman Guest

    Its a good thing you replied.
     
    hulioman, Nov 10, 2004
    #7
  8. kzalec

    T.Willey Guest

    Rudy,

    How would you get the path of an xref through object dbx? When I dumped one this is all I got:
    Command: (vlax-dump-object tm1)
    ; IAcadBlock: A block definition containing a name and a set of objects
    ; Property values:
    ; Application (RO) = Exception occurred
    ; Count (RO) = 0
    ; Document (RO) = #<VLA-OBJECT IAxDbDocument 0306d078>
    ; Handle (RO) = "D5D"
    ; HasExtensionDictionary (RO) = 0
    ; IsLayout (RO) = 0
    ; IsXRef (RO) = -1
    ; Layout (RO) = AutoCAD.Application: The property is not available in current
    state
    ; Name = "X-ALIGN-HORZ (SITE20)"
    ; ObjectID (RO) = 2130237736
    ; ObjectName (RO) = "AcDbBlockTableRecord"
    ; Origin = (233.813 179.875 0.0)
    ; OwnerID (RO) = 2130219544
    ; XRefDatabase (RO) = AutoCAD.Application: No database
    T

    I didn't see anything about a path. How I got "tm1", I searched through the block list, found one that was and xref and asigned that vla-object to tm1.

    Any help is again appreciated.
    Tim
     
    T.Willey, Nov 10, 2004
    #8
  9. kzalec

    Rudy Tovar Guest

    Note the code I wrote to modify a layer and illustrate the blockreference
    acquiring the xref path. Note that the path is dumped as such....read
    below...

    (vl-load-com)
    (defun c:dbxlayer (/ dbxDoc dwgname la cn lp it co)
    (setq dwgname (getfiled "Select Drawing File" "" "dwg" 4))
    (if dwgname
    (progn
    (setq dbxDoc
    (vla-GetInterfaceObject
    (vlax-get-acad-object)
    "ObjectDBX.AxDbDocument"
    )
    )
    (vla-open dbxDoc DwgName)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;GATHER ALL LAYERS AND COLOR ASSIGNMENTS AND SWITCH;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (setq la (vla-get-layers dbxdoc)
    cn (vla-get-count la)
    lp 0
    )

    (repeat cn
    (setq it (vla-item la lp)
    co (vla-get-color it)
    )
    (if (= co 18)
    (progn
    (vla-put-color it 31)
    )
    )
    (setq lp (1+ lp))

    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;GATHER ALL ENTITIES AND COLOR ASSIGNMENTS AND SWITCH
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (setq la (vla-get-modelspace dbxdoc)
    cn (vla-get-count la)
    lp 0
    )
    (repeat cn
    (setq it (vla-item la lp)
    co (vla-get-color it)
    na (vla-get-objectname it)
    )
    ;(prompt (strcat "\n" na))
    (if (= na "AcDbBlockReference")
    (progn
    (vlax-dump-object it t)
    (prompt "\n")
    )
    )

    (if (= co 18)
    (progn

    (vla-put-color it 31)
    )
    )
    (setq lp (1+ lp))

    )
    (vla-saveAs dbxdoc (vla-get-name dbxdoc))

    (vl-catch-all-apply
    '(lambda () (vla-close DBXDOC ':VLAX-TRUE 'ITEM))
    )

    (VL-CATCH-ALL-APPLY
    'vlax-release-object

    (list *acad* dbxDoc for-item name na color dwgname la cn lp it co)

    )
    (vlax-release-object dbxDoc)

    (setq dbxDoc nil)
    )
    )
    (princ)
    )



    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;This is returned as a dumped object data NOTE THE PATH AND NAME OF XREF;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ; IAcadExternalReference: IAcadExternalReference Interface
    ; Property values:
    ; Application (RO) = Exception occurred
    ; Color = 123
    ; Document (RO) = #<VLA-OBJECT IAxDbDocument 0e7accd8>
    ; Handle (RO) = "B4BC"
    ; HasAttributes (RO) = 0
    ; HasExtensionDictionary (RO) = -1
    ; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0ef59874>
    ; InsertionPoint = (837.304 -650.509 0.0)
    ; Layer = "ELEV-DWG"
    ; Linetype = "ByLayer"
    ; LinetypeScale = 1.0
    ; Lineweight = -1
    ; Name = "x203301Mpbldg"
    ; Normal = (0.0 0.0 1.0)
    ; ObjectID (RO) = 1161777888
    ; ObjectName (RO) = "AcDbBlockReference"
    ; OwnerID (RO) = 1172655352
    ; Path = "E:\\02033\\02033.01\\Condocs\\Xref\\x203301Mpbldg.dwg"
    ; PlotStyleName = "Color_123"
    ; Rotation = 0.0
    ; Visible = -1
    ; XScaleFactor = 1.0
    ; YScaleFactor = 1.0
    ; ZScaleFactor = 1.0
    ; Methods supported:
    ; ArrayPolar (3)
    ; ArrayRectangular (6)
    ; Copy ()
    ; Delete ()
    ; Explode ()
    ; GetAttributes ()
    ; GetBoundingBox (2)
    ; GetConstantAttributes ()
    ; GetExtensionDictionary ()
    ; GetXData (3)
    ; Highlight (1)
    ; IntersectWith (2)
    ; Mirror (2)
    ; Mirror3D (3)
    ; Move (2)
    ; Rotate (2)
    ; Rotate3D (3)
    ; ScaleEntity (2)
    ; SetXData (2)
    ; TransformBy (1)
    ;
     
    Rudy Tovar, Nov 10, 2004
    #9
  10. What exactly do you think this is? Do you realize that
    this code doesn't do what you seem to think it does?

    Do you realize that this code does not even work, and
    returns an error?
     
    Tony Tanzillo, Nov 10, 2004
    #10
  11. kzalec

    Rudy Tovar Guest

    I'll have to check my source code...I could have posted the wrong
    one....thanks...

    I was cutting and pasting a lot today...

    You see Tony, we're not blessed like you, we test, run crash until we get it
    right and on occasion we sometimes forget to clean up the code...

    Nonetheless it would help if you kept your degrading comments to yourself
    and just offer what you've learned so that we may all get to your level, if
    that means anything.

    I should talk, but at least I know I'm not perfect.

    I'm commenting on this because of the other thread, just to bring everyone
    to speed...

    Personally I enjoy learning by trial and error and could careless for your
    smart remarks...
     
    Rudy Tovar, Nov 10, 2004
    #11
  12. kzalec

    Joe Burke Guest

    Rudy,

    Personally, I enjoy Tony's "smart remarks", even when they are addressed to me.

    I think this forum is so sanitized with enforced politeness... it makes me gag
    sometimes.

    I just mean polite is nice if that's your preference. But it shouldn't exclude Tony's
    way, by virtue of his experience.

    Joe Burke
     
    Joe Burke, Nov 10, 2004
    #12
  13. kzalec

    kzalec Guest

    I have no knowledge of dbx, so this won't help me at all. I'm looking for some SPECIFIC script file, AutoLISP code, etc. - line for line. So far, T. Willey's AutoLISP code seems the most promising. Now I just need the script file to open, execute and then save the files automatically (batch process). Your suggestion may help someone else with knowledge of dbx, however.
     
    kzalec, Nov 10, 2004
    #13
  14. kzalec

    Rudy Tovar Guest

    Do you mean Professional Experience?

    If so, his method is not professional...

    Clean, Sanitized, Polite, Virtue?

    Virtue:
    1.. Moral excellence and righteousness; goodness.
    2.. An example or kind of moral excellence: the virtue of patience.
    3.. the quality of doing what is right and avoiding what is wrong
    I must say at one time I rather enjoyed this resource, but now I've seen his
    other side...arrogant...

    Arrogant:
    1.. Having or displaying a sense of overbearing self-worth or
    self-importance.
    2.. Marked by or arising from a feeling or assumption of one's superiority
    toward others:
     
    Rudy Tovar, Nov 10, 2004
    #14
  15. I have read all this and think the idea of writing it from scratch is not worth the time.
    It is worth knowing how to do it so you can write other tools, but this tool is already slicked out by Terry Dotson.

    Get a copy of Dotsoft Toolpack 8 and use the Drawing->Repather tool.
    It has a listbox where you tell it what to look for and what to replace it with.
    It will do xrefs and other files too such as images. It is simply way way better than anything I have seen.
    The dialog box is well developed, not some quick tool thrown together.
    It lets you save the search and replace list to a file.
    I recommend doing that for one item, save it to file, then edit the file and reimport.
    Editing the file is nicer than a dialog box when many items are involved.
    The cool thing is that it wiull replace a portion, or all of the file path and name, not just the path like Autocad's
    reference manager tool.

    Toolpack is like $200 I think, go to dotsoft.com and look it up. It is worth $1000 if you ask me.
    thanks


    kzalec <>
    |>We are faced with a problem at work. Hundreds of drawings have been created with lots of XREFs "Overlayed" in each drawing. The client is now saying that they have a different standard for naming drawings that are used as XREFs. We can easily use Windows Explore to rename the XREF files in the XREF directory. However, once we do that, none of those XREFs will be found when we open the (hundreds of) drawings which have them "Overlayed". We'd like to find some way to BATCH rename the XREFs (Saved Path name) inside AutoCAD. Please note that we aren't concerned with the "Reference Name" inside the "Xref Manager" dialog box. We are only concerned with the name of the XREFs as they appear in the "Saved Path" part of the "Xref Manager" dialog box. I think this is going to be very difficult, if not impossible. But if there are any AutoLISP geniuses out there, perhaps you may know a way to do this. We are hoping that we don't have to manually reoverlay/reattach every Xref file
    after
    |>renaming the Xref files in Windows Explore.

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Nov 10, 2004
    #15
  16. kzalec

    T.Willey Guest

    Rudy,

    It looks to me as if you are selection the xref by the object, not through the block collection? What if there is multiply paper spaces? I guess I don't know enough about how to find objects with object dbx, because I'm not sure how hard this code would be to write if you method is the only way to select the xref to change there paths. I was thinking you could get all that information from the block collection, then change it there, but I'm not if you can do that.

    Could you please clarify some things?
    Can you change the path of an xref from the block collection?
    How easy it is to select all spaces (model and multiply paper)?

    Thanks a lot, this has been most helpful.
    Tim
     
    T.Willey, Nov 10, 2004
    #16
  17. kzalec

    kzalec Guest

    This is welcome information to many, I'm sure. But I'm very grateful for a quick, easy and FREE AutoLISP routine and/or script file that will do what we want. We don't have any money in our budget for additional software, so I'm very grateful to T. Willey and others for making an effort. Also, it's good brain exercise and helps me learn more about AutoLISP, etc. Keep up the good work, guys! You're almost there...
     
    kzalec, Nov 10, 2004
    #17
  18. kzalec

    Dave Jones Guest

    a quick, easy and FREE AutoLISP routine and/or script file that will do what
    we want. We don't have any money in our budget for additional software, so
    I'm very grateful to T. Willey and others for making an effort. Also, it's
    good brain exercise and helps me learn more about AutoLISP, etc. Keep up
    the good work, guys! You're almost there...

    the money spent on the time you've been here dealing with trying to figure
    it out would have paid for ToolPac 8.0. You're spending a dollar trying to
    save a dime. Check out TP8...it's the best set of AutoCAD productivity tools
    available anywhere in a package IMO. Big bang for the buck for sure.
    Dave
    DDP
    not affiliated with Dotsoft or ToolPac, just a happy user since TP4
     
    Dave Jones, Nov 10, 2004
    #18
  19. uh, a "a quick, easy and FREE AutoLISP routine" is not what you asked for.
    I would not have revealed what you just said as people in this NG get tired of people wanting a rabbit pulled out of a
    hat for free and with llittle effort.
    Do you realize that what you want is not simple?
    Experienced people might be able to put together stuff that seems simple, but this is because they have spent the time
    to know how to write slick code.

    If you don't have $200 for a super slick powerful prog that took probably 40 or more hours to develop, and does exactly
    what you need, what is your reality? My gosh, we bill $90 an hour. Havent you already spent 2 hours fiddling with
    this?

    If you want to learn, that is one thing, but what I see is you directing a bunch of experienced developers so you can
    save money. Have at him Rudy!

    kzalec <>
    |>This is welcome information to many, I'm sure. But I'm very grateful for a quick, easy and FREE AutoLISP routine and/or script file that will do what we want. We don't have any money in our budget for additional software, so I'm very grateful to T. Willey and others for making an effort. Also, it's good brain exercise and helps me learn more about AutoLISP, etc. Keep up the good work, guys! You're almost there...

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Nov 10, 2004
    #19
  20. I wrote my reply before seeing Dave Jones'.
    Glad someone else sees the naked king!

    James Maeding <>
    |>uh, a "a quick, easy and FREE AutoLISP routine" is not what you asked for.
    |>I would not have revealed what you just said as people in this NG get tired of people wanting a rabbit pulled out of a
    |>hat for free and with llittle effort.
    |>Do you realize that what you want is not simple?
    |>Experienced people might be able to put together stuff that seems simple, but this is because they have spent the time
    |>to know how to write slick code.
    |>
    |>If you don't have $200 for a super slick powerful prog that took probably 40 or more hours to develop, and does exactly
    |>what you need, what is your reality? My gosh, we bill $90 an hour. Havent you already spent 2 hours fiddling with
    |>this?
    |>
    |>If you want to learn, that is one thing, but what I see is you directing a bunch of experienced developers so you can
    |>save money. Have at him Rudy!
    |>
    |>kzalec <>
    |>|>This is welcome information to many, I'm sure. But I'm very grateful for a quick, easy and FREE AutoLISP routine and/or script file that will do what we want. We don't have any money in our budget for additional software, so I'm very grateful to T. Willey and others for making an effort. Also, it's good brain exercise and helps me learn more about AutoLISP, etc. Keep up the good work, guys! You're almost there...
    |>
    |>James Maeding
    |>jmaeding at hunsaker dot com
    |>Civil Engineer/Programmer

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Nov 10, 2004
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.