Does anyone know of an extension that removes the style attribute from every object in a selection? I want it to (optionally?) recurse into groups and subgroups.
When I move or paste objects in my drawing, I want them to inherit the style of the destination layer. However, Inkscape applies the source layer style to the object, overriding the destination layer style.
I often use Inkscape as a proto-CAD application (hence the user name, I suppose) to edit imported pdf and dxf files. Shapes are differentiated by line weights, fill colour, opacity, dash patterns, etc. My habit is to apply styles to parent layers which are then inherited by the unstyled child objects within. I can delete style attributes from a single object using the XML Editor but this is tedious for large selections.
@inklinea: Option 2 is Inkscape's styling strategy and that's what I want to delete. Recursion into groups and tspans is the preferred behaviour.
@TylerDurden: When you copy-paste an unstyled child object from a styled layer or group, Inkscape assigns the source group style to the pasted object inside the target group. Presumably this is intentional behaviour so that the pasted object has the same visual appearance as the original. I want to discard the source layer style and inherit the target layer style.
In this example, none of the objects has a style attribute. Layers, however, have a style attribute with stroke and fill and font definitions. [Move to Layer...] or [Copy] [Paste] adds a style attribute to the pasted or moved object. Deleting this style attribute renders the object with the parent layer style.
I built a really quick and dirty extension that strips ALL style attributes, pretty much as my first attempt at an extension -- I tend to use inkscape to build fairly simple stuff that ends up as inlined svg on web pages, styled by external css, so my workflow is to strip all styling before exporting to plain svg. It's only about half a dozen lines. Not sure if that would be useful as a starting point, but also how best to post it in here ?
Thanks @inklinea, yep it was purely to scratch my own particular workflow itch from a while ago so it's definitely not refined -- just thought it might be useful as a starting point.
Just an extra, gotta say a big thanks to you for your flatten extension that resolves transforms, it makes my cleanup and stripdown process soooo much easier 😀
Thanks Aero, problem solved. I'm awarding you a shamrock!
The source and destination layers belong to different CSS classes and are formatted accordingly. Layers have no style attribute of their own so copy-paste takes no object style to the destination layer.
Does anyone know of an extension that removes the style attribute from every object in a selection? I want it to (optionally?) recurse into groups and subgroups.
When I move or paste objects in my drawing, I want them to inherit the style of the destination layer. However, Inkscape applies the source layer style to the object, overriding the destination layer style.
I often use Inkscape as a proto-CAD application (hence the user name, I suppose) to edit imported pdf and dxf files. Shapes are differentiated by line weights, fill colour, opacity, dash patterns, etc. My habit is to apply styles to parent layers which are then inherited by the unstyled child objects within. I can delete style attributes from a single object using the XML Editor but this is tedious for large selections.
As you probably know, there are 3 sources in svgs for "styling" properties to be stored:
Attributes (old school) ----- fill="black" stroke="red"
style attribute properties ----- style="fill:black;stroke:red;"
classes ----- class="blackAndRed"
Do you want the option to nuke any or all of them, with options to recurse ?
Setting the selected objects to unset before moving does not satisfy the goal?
@inklinea: Option 2 is Inkscape's styling strategy and that's what I want to delete. Recursion into groups and tspans is the preferred behaviour.
@TylerDurden: When you copy-paste an unstyled child object from a styled layer or group, Inkscape assigns the source group style to the pasted object inside the target group. Presumably this is intentional behaviour so that the pasted object has the same visual appearance as the original. I want to discard the source layer style and inherit the target layer style.
In this example, none of the objects has a style attribute. Layers, however, have a style attribute with stroke and fill and font definitions. [Move to Layer...] or [Copy] [Paste] adds a style attribute to the pasted or moved object. Deleting this style attribute renders the object with the parent layer style.
I was presuming that the unset objects would originate in a non-styled layer and then get moved to a styled layer.
Hi @Paddy_CAD
I built a really quick and dirty extension that strips ALL style attributes, pretty much as my first attempt at an extension -- I tend to use inkscape to build fairly simple stuff that ends up as inlined svg on web pages, styled by external css, so my workflow is to strip all styling before exporting to plain svg. It's only about half a dozen lines. Not sure if that would be useful as a starting point, but also how best to post it in here ?
Darren
I've just zipped my extension directory up - maybe that will help you ?
Darren
I've had a look.
The extension strips the style attribute from every element in the svg.
I think PaddyCad wants it to be a bit more specific, just children or all descendants of a specific selected element.
[ Well done on writing your first extension btw :) ]
Thanks @inklinea, yep it was purely to scratch my own particular workflow itch from a while ago so it's definitely not refined -- just thought it might be useful as a starting point.
Just an extra, gotta say a big thanks to you for your flatten extension that resolves transforms, it makes my cleanup and stripdown process soooo much easier 😀
Maybe moving the style attributes from the groups (layers) into a style element will help when copying, pasting and using move to layer.
Thanks Aero, problem solved. I'm awarding you a shamrock!
The source and destination layers belong to different CSS classes and are formatted accordingly. Layers have no style attribute of their own so copy-paste takes no object style to the destination layer.