Turn Layers On and Off?

  • Jared Davis
    Jared Davis

    Can you give me a hint or some sample code to turn off a layer on the current drawing?

    • Ed Karlo
      Ed Karlo

      This really needs some new methods to turn layers on and off in a simple manner.  However, you have access to all the sections, tables and entities of a loaded drawing and you can modify anything directly.  To turn layers on and off you can do something like this:

      Yxxf D; // loaded drawing
      YxxfTblLayer layer =
      if (layer != null) // layer found
          layer.aci = -Math.abs(layer.aci); // negative color means layer is off

      Take a look at the Javadoc for Yxxf (the drawing), YxxfSecTables (the tables section) and YxxfTblLayer (the layer table) for more info and other methods that might be useful.