sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Deleting Layers - or....

    Scheduled Pinned Locked Moved Plugins
    6 Posts 2 Posters 182 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      kybasche
      last edited by

      Hey folks.

      I've been messing around with the VolumeCalculator21 plugin, trying to figure out what controls the addition of the copied volume to a new layer. I'd like to have the plugin NOT create the new layer and copied volume (or, alternatively, delete them after they are created and used).

      Is there a way to delete a layer and its contents from within ruby?
      Can anyone tell me which lines of this plugin are "copying" the selected volume into the newly created layer within the plugin?

      I've attached the plugin for reference.

      Thanks!

      Derek


      VolumeCalculator21.rb

      1 Reply Last reply Reply Quote 0
      • TIGT Online
        TIG Moderator
        last edited by

        To make it so that it always uses the 'default layer' as the default value in the dialog, change
        values = [@units,@layer,@hidden,@colour,@hide]
        to read
        values = [@units,**dlayer**,@hidden,@colour,@hide]
        OR before @layer is used to set a layer put '#' in front of each of these lines
        layerVolume=@layer if layerVolume layerVolume=model.layers.add(layerVolume) layerVolume.page_behavior=(LAYER_IS_HIDDEN_ON_NEW_PAGES | LAYER_HIDDEN_BY_DEFAULT) layerVolume.visible=true end#if
        and add
        layerVolume=nil
        To put the volume-text onto the default layer add a '#' in front of all lines of this code, so no layer is made used
        layerVolumeText=@layer+"-TEXT" if layerVolumeText layerVolumeText=model.layers.add(layerVolumeText) layerVolumeText.page_behavior=(LAYER_IS_HIDDEN_ON_NEW_PAGES | LAYER_HIDDEN_BY_DEFAULT) layerVolumeText.visible=true end#if txt.layer=layerVolumeText
        To remove the object you might think to use this just before the ' end#def Volume::process' line...
        vol.erase!
        BUT then that will erase the text too !!
        So to keep just the volume's text use
        ventities.erase_entities(ventities.to_a-[txt])
        To explode the text so it's no longer inside a group you can add
        vol.explode
        after erasing everything except the text [txt]...
        Remember that none of the tool's 'listing' code will now work as there are no 'volumes' to process...

        TIG

        1 Reply Last reply Reply Quote 0
        • K Offline
          kybasche
          last edited by

          Brilliant! Still so many things to learn...

          Thanks πŸ˜„

          D

          1 Reply Last reply Reply Quote 0
          • K Offline
            kybasche
            last edited by

            I spoke too soon!!!!

            I think I followed your instructions well (though, I don't rule out user error) - but when I run the script and actually pay attention I noticed that the volume and text are NOT being deleted.

            In the ruby console I get an error that:
            Error: #<NameError: undefined local variable or method `vol' for Volume:Class>

            Have I put the vol.erase! line in the wrong place? I located it, as you said, just before the Process code ends.

            Any ideas?

            Thanks πŸ˜„

            D

            1 Reply Last reply Reply Quote 0
            • K Offline
              kybasche
              last edited by

              I moved the vol.erase! line to just after
              vol.set_attribute("Volume","Tag",true) ### v1.8
              in Volume::process

              and it seems to be working.

              Is there something between
              vol.set_attribute("Volume","Tag",true) ### v1.8
              and the end of that defwhich makes volno longer available?

              D

              1 Reply Last reply Reply Quote 0
              • TIGT Online
                TIG Moderator
                last edited by

                Around line #302 is the text
                end#def Volume::process
                place you additional code on its own line, just before that - vol.erase! etc to remove the vol-group etc...

                TIG

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement