Deleting Layers - or....
-
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
-
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... -
Brilliant! Still so many things to learn...
Thanks
D
-
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
-
I moved the vol.erase! line to just after
vol.set_attribute("Volume","Tag",true) ### v1.8
in Volume::processand 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
-
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...
Advertisement