Just published a quick little extension I made for my personal use. This one lets you export the selected entities as an SVG. Can be used for signage and other details on scale models, logos and more. Just make sure to orient your entities with the front side up.
This can also be used as a code examples for extension developers, showing concepts such as traversing/walking the model and resolving inherited material and visibility.
Thank you very much for this open source extension !
I’m searching a way to close the outlines, could you give me a little push?
I think it’s here :
# Generate SVG path.
#
# @param face [Sketchup::Face]
# @param transformation [Geom::Transformation] from local space to paper space.
# @param color [Sketchup::Color]
#
# @return [String]
def self.svg_path(face, transformation, color)
d = face.outer_loop.vertices.map do |vertex|
position = vertex.position.transform(transformation)
"L #{format_length(position.x)} #{format_length(position.y)}"
end.join(" ")
# First "command" should be move to, not line to.
d[0] = "M"
# Inner loops, skip loops[0] as it is the outer loop.
face.loops[1..-1].each do |loop|
d_inner = loop.vertices.map do |vertex|
position = vertex.position.transform(transformation)
"L #{format_length(position.x)} #{format_length(position.y)}"
end.join(" ")
d_inner[0] = "M"
d += d_inner
end
I must add “L Xfirst_point Yfirst_point” at the end of the path. These values are the “M” values. Could you explain the syntax to do that. (I’m a newbie in Ruby for SU) ?
Best regards,
Renaud
Should be a native import / export capability of SU and LO and a universal open source vector file format… but big thanks Christina for updating this capability for users
As of now the extension only export faces. It’s a very rough extension I made for a specific project more options are available if you do a native PDF export and convert to an SVG in a separate software.