Tuesday, May 1, 2007

Translate layers using Laytrans on the command line

If you want to use the Layer Translator command Laytrans in a script file (SCR) or an AutoLISP file (LSP) here is how it can be done.

The use of the LISP function requires that you have already created and saved a layer translation mapping using the dialog version. The syntax is as follows:

(acet-laytrans <file name> [<bits>])

<file name> is a required argument. It is the name of a dwg or dws file that contains saved layer mappings. This file would need to have been created during a manual translation operation with Layer Translator.

[<bits>] is an optional argument. This is a bit code sum indicating which options should be used during translation. These correspond to the same options in the Settings dialog in Layer Translator. If the argument is not provided, the function uses the Layer Translator dialog's last settings.

The bits are as follows:

  • bit = 1: Force color to Bylayer
  • bit = 2: Force linetype to Bylayer
  • bit = 4: Translate into blocks
  • bit = 8: Write the translation log file

Examples:
(acet-laytrans "standard.dws")
Uses the previously saved file "standard.dws" (which contains layer mappings) and the last used options.

(acet-laytrans "standard.dws" (+ 1 2))
Uses the previously saved file "standard.dws" and forces color and linetype to BYLAYER.

(acet-laytrans "standard.dws" (+ 1 2 8))
Uses the previously saved file "standard.dws", forces color and linetype to BYLAYER and writes a translation log.

(cond ((not (member "laytrans.arx" (arx))) (arxload "laytrans")))
(acet-laytrans "standard.dws" (+ 1 4))
Make sure that laytrans.arx is loaded and use bit 1 and bit 4.

9 comments:

  1. Nice info, however it should really be noted that if you are trying to use this routine on a template drawing, with lots of layers that have nothing on then because it's a template drawing so folks can have the layers that they need, acet-laytrans will delte all the unused layers and there's nothing it seems that can change that.

    ReplyDelete
  2. naturat, thanks for the tip!

    ReplyDelete
  3. Wow! Nice info? You must be kidding! I have been looking for this for years, trying lots of other things like Toolpac, StanConvert etc. Layer translations on multiple drawings is a must to have tool for every CAD office, as it enables you to meet any client's layering standard without changing your menus, and without loosing CAD productivity by not using your menus! With this command line option you can run laytrans function on any number of drawings using script or (better) lisp batch processor. The laytrans command has always been better then anything else on the market, because it allows layer merge duringb translation, but it was almost useless to me until now. I will test it, and if it really works from the command line, it will be one of the most powerful tools in our CAD office.
    Jimmy, if this is you again helping me so much with my CAD management tools? Thank you! I'll be using this laytrans command line function running by your CAD automation tools.

    ReplyDelete
  4. Is there a way to retrieve the layer mapping info directly from the DWS file (in case I deleted the translation log)?
    That would be so helpful!
    Thanks.

    ReplyDelete
  5. It is probably possible to get layer mapping info from the DWS file. But I don't know how without investigating further.

    ReplyDelete
  6. Great, Jimmy. Where should the DWS be saved? How does it know where to find it? Thanks, Scott.

    ReplyDelete
  7. Great, Jimmy. Where must the DWS file be saved? How does the LISP know where to find it? Thanks, Scott.

    ReplyDelete
  8. Scott, I think it is found if it is in any of AutoCAD's support paths, otherwise I think you can specify the path as well.

    ReplyDelete

Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner

Contact Us | About JTB World | Website General Terms of Use | Privacy Policy
^ Top of page

© 2004- JTB World. All rights reserved.