Layer Name Amending Script

Discussion in 'AutoCAD' started by Steve Wojtynek, Jul 28, 2004.

  1. I'd like to get all the layer names in a 3D furniture blocks library to be
    unique, so each layer can be controlled in a rendering program. For
    instance, if I have a block layer called _FABRIC in a hundred different
    blocks, then all the blocks used in the same drawing that happen to have the
    _FABRIC layer will be controlled together in a rendering program, which I
    don't want. I might want to be able to assign different bitmaps to
    different _FABRIC's in different furniture items.

    Is it possible to write a script that will open a drawing, and then
    automatically add the DWGNAME name to the front of all the layers (except 0
    and defpoints) in the block, and then save the block and quit? (For
    instance. the layer _LEATHER in a 3D_WASSILY_CHAIR.dwg block would be
    renamed to 3D_WASSILY_CHAIR_LEATHER.)

    I could then run the magic layer name altering script via ScriptPro on my
    entire 3D blocks library while I walk the dog.
     
    Steve Wojtynek, Jul 28, 2004
    #1
  2. Steve Wojtynek

    dblaha Guest

    Yes, this is entirely possible. You can use TBLNEXT to step through the layer table and rename each layer by adding the current file name (vl-filename-base (getvar "dwgname")) to it.
     
    dblaha, Jul 28, 2004
    #2
  3. Steve Wojtynek

    wccppp Guest

    Suggest using objectDBX if you have lots of drawings to process. Once you have the document object. Something like this might work.

    (setq dwgName (vl-filename-base (vla-get-name dbxDoc)))
    (vlax-for objLayer (vla-get-layers dbxDoc)
    (setq layerName (vla-get-name objLayer))
    (if (and (not
    (vl-position (strcase layerName) (list "0" "DEFPOINTS"))
    )
    (not (vl-string-search "|" layerName)) ;; This is not necessary if all your drawings do not have xrefs.
    )
    (vla-put-name objLayer (strcat dwgName "_" layerName))
    )
    )

    save the document and move to the next drawing.

    regards
     
    wccppp, Jul 28, 2004
    #3
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.