RH-84304 is fixed in Rhino 8 Service Release 14
Hi @CallumSykes
can you please see what can be done so we can select objects from an imported SVG so they can be altered for dark mode?
I made this SVG in Rhino and imported it.
If I could make a wish it would be that all objects that are BLACK are turned WHITE automatically with out us doing anything at all, when the dark mode is used.
Or have I missed something?
Here is the SVG if you want to test it out.
Iām working on improving what can be edited so this can be possible.
I can understand that. but this can have the effect of it swapping even if you donāt want it to.
Currently you can add special attributes that will flip the colours.
<path fill="black" fill-dark="white" ... />
<path stroke="red" stroke-dark="green" ... />
First of all, how do I do that? In a text editor? And I have 40 buttons that I need to edit so donāt think thatās a viable option. Right now itās better to just tell the guys to stay away from dark mode maybe.
Yep.
@bfrederick created a tool to do a whole folder for you.
OK, but can I link an SVG to a toolbar button? I thought I had to import it one by one for each button. When I overwrite those SVGās nothing happens to the buttons so I have to import them again. (I am manually making a toolbar, this is not through some fancy plugin making programming tools you guys probably use)
Not that Iām aware of, you have to import them same as pngs
I think I know what you have in mind, but then you would have satellite files, which can lead to even more confusion.
I once proposed to have a drag&drop mechanism.
Drop a SVG file onto a toolbar button, Rhino asks āDo you want to use this SVG for Light or Dark?ā [Light] [Dark] [Cancel].
But that isnāt there.
@Callum here is a little video of how I make my SVGās.
I made a python script that does most of my work for me.
It accepts curves, hatches and text only, and converts text to objects to work around the previous limitations you guys had (donāt know if you have fixed text now, but this is future proof as long as the text font is a good font (no self intersecting boundry curves))
I have a rhino file with all the icons layed out so I can easily copy paste stuff from one icon to the next one. The file is sat up with layers for the basic colors and print widths for hatches and curves. (And I use move_to_front when needed)
Each Icon has a space of 40x40mm and I export the SVG to that same size.
It makes a new view that zooms in on the content so the print to svg works well.
Maybe it can inspire you, and maybe somebody else finds this usefull.
(Use at own risk)
With this tool I can basically do everything I need to make OK icons from within Rhino, with out the need to use other tools, and I can quickly edit them and export again if I see that they donāt work as intended in the toolbar. I have more than 120 icons to vectorize so the task needs to be as streamlined as possible, and with this workflow it isnāt half bad.
So maybe we can start using Rhino 8 fulltime soon
@gustojunk You might want to test it out if you are going to move on to vectorized icons.
I have this script on a button to quickly access it.
Just add this to a button:
_-RunPythonScript ( paste-script-here )
SVG ICON exporter
import rhinoscriptsyntax as rs
objs = rs.GetObjects("Objects for SVG export", rs.filter.curve + rs.filter.hatch +rs.filter.annotation, preselect=True)
if objs:
rectangle = rs.GetRectangle()
if rectangle:
rs.EnableRedraw(False)
rectangle_id = rs.AddPolyline((rectangle[0],rectangle[1],rectangle[2],rectangle[3],rectangle[0]))
rs.SelectObject(rectangle_id)
rs.Command("_NewFloatingViewport CopyActive Enter", False)
view = rs.CurrentView(view=None, return_name=False)
rs.Command("_-ViewportProperties Size 480 480 Enter", False)
rs.Command("_Zoom Selected",False)
rs.DeleteObject(rectangle_id)
# --- CHECK FOR TEXT
textHatches = []
for obj in objs:
if rs.IsText(obj):
color = rs.ObjectColor(obj)
curves = rs.ExplodeText(obj)
hatches = rs.AddHatches(curves)
for hatch in hatches:
rs.ObjectColor(hatch,color)
rs.ObjectPrintColor(hatch,color)
textHatches.append(hatch)
rs.DeleteObjects(curves)
# --- Select Objects
for obj in objs:
if not rs.IsText(obj):
rs.SelectObject(obj)
rs.SelectObjects(textHatches)
# --- Export
rs.Redraw()
rs.SelectObjects(objs)
rs.Sleep(0)
rs.CurrentView(view)
rs.Command("!_Export", False)
rs.Sleep(0)
rs.CurrentView(view)
rs.Command("_CloseViewport")
# --- Clean up
rs.DeleteObjects(textHatches)
rs.EnableRedraw(True)
3 posts were split to a new topic: Toolbars show empty icons
@Holo Iāve edited your post, to make the code display well
A post was merged into an existing topic: Toolbars show empty icons
Thatās really cool @Holo! The only limiting part of this workflow might be that you are not seeing a preview of the icon until after you exported/imported as a new button, correct?
If you run your viewport in PrintDisplay does it help you to preview the line thicknesses?
Also have you found a wait to do gradient fills? The main reason I started my icons in Illustrator is that I can do gradient fools and also change the style of corners and ends of curves (rounded/flat/etc.) but maintaining the icons in Illustrator and using its curve editing tools sucks. this might be a better way.
G
Thatās a great idea, Iāll test out the possibilities!
ideally I would do it in layout, but I need to call up a new viewport for the export to orient the print correctly. (And that doesnāt work in layout) And after a while I have developed a feel for the line thickness, and my icons are for internal use, so good enough is good enough.
Iāll kick it around some more and maybe bake it into a small plugin if that would work better for you.
NICE!!! This works great on Rhino 8, so no need to test out a āLayoutā workflow.
This is so much better than Rhino 7 and finally a tool that can be used to preview 1:1 2D stuff in modelspace. Great input Gustavo.
HI @Holo Great to know this is working well. For me, the PrintDisplay stuff is soooo close to replacing Illustrator for this type of work, but itās missing 2 major things I cannot go without:
- stroke cap, corner and alignemt options
- gradient fills (linear and radial)
On the other hand, Iām wondering if using 3D shaded objects and exporting them as bitmaps from Rhino to SVG (combined with vector output of exportable vector elements would be the ideal workflow instead of faking and 2D āshadingā things to look 3D.
How awesome would it be if when I make my icon like thisā¦
The matcap sphere also exports as a bitmap, right now it gets omitted from selectable objects to export:
G
Unless Iām confused about your comments both of these are already available in Rhino. Linetypes have cap/join settings and hatches have gradient fills.
hi @stevebaer, you are correct, I was the confused one! I didnāt know you guys had implemented gradients and stroke options yet. Very cool.
Hereās an example of a test icon made with vectors and gradient fills in Rhino, and exported with @Holoās script. You can see the export of the gradient is not great. Iām not sure if this is a setting in the SVG exporter (original Rhino icon on left, exported SVG on Illustrator floating window on right)
Same happens in the icon preview when I import it:
@Holo, what setting do I use to export the correct padding here? Look at the differences between the viewport vs. the extents? It seems like needed does a proper fit to the selected rectangle?
@stevebaer, what do you think about including pixel output into the SVG? Icon playtime aside, this might be an excellent feature for many illustration workflows, right?
This all looks very promising and useful as it is right now. Time to start making some new icons.
BTW, hereās the test file in Rhino that outputs this:
holo_icon_mater_test_with_gradient_fills_01_gf_250310.3dm (104.3 KB)
G
This is OT from this thread, but I am getting some erratic behavior if I make a hatch from a circle, but if I rebuild it first then itās all good. Try making a circle, add a radial hatch and then try to 1D scale it with the Gumball widget. Here that messes up. Also if I trim the circle into a half circle and hatch that. Suddenly the hatch breaks up and Undo doesnāt work.
And hereās an updated script for you @gustojunk . Today my script created fat letters, probably because it included the outline of the text or something. (hasnāt happened before as far as I am concerned, but it does not happen with the updated script)
Updated SVG script
import rhinoscriptsyntax as rs
def exportSVG(obj_ids, rectangle):
rs.UnselectAllObjects()
rs.EnableRedraw(False)
rectangle_id = rs.AddPolyline((rectangle[0],rectangle[1],rectangle[2],rectangle[3],rectangle[0]))
bbox = rs.BoundingBox(rectangle_id)
factor = 0.9
rectangle_id = rs.ScaleObject(rectangle_id, (bbox[0]+bbox[2])/2, (factor,factor,factor),False)
rs.Command("_NewFloatingViewport CopyActive Enter", False)
view = rs.CurrentView(view=None, return_name=False)
rs.Command("_-ViewportProperties Size 480 480 Enter", False)
rs.SelectObject(rectangle_id)
rs.Command("_Zoom Selected",False)
rs.DeleteObject(rectangle_id)
# --- CHECK FOR TEXT
textHatches = []
textObjs = []
for obj in obj_ids:
if rs.IsText(obj):
color = rs.ObjectColor(obj)
curves = rs.ExplodeText(obj)
hatches = rs.AddHatches(curves)
for hatch in hatches:
rs.ObjectColor(hatch,color)
rs.ObjectPrintColor(hatch,color)
textHatches.append(hatch)
rs.DeleteObjects(curves)
textObjs.append(obj)
# --- Hide text objects
rs.HideObjects(textObjs)
# --- Select Objects
for obj in obj_ids:
if not rs.IsText(obj):
rs.SelectObject(obj)
rs.SelectObjects(textHatches)
rs.SelectObjects(obj_ids)
# --- Export
rs.Redraw()
rs.SelectObjects(obj_ids)
rs.Sleep(0)
rs.CurrentView(view)
rs.Command("!_Export", False)
rs.Sleep(0)
rs.CurrentView(view)
rs.Command("_CloseViewport")
# --- Clean up
rs.DeleteObjects(textHatches)
rs.ShowObjects(textObjs)
rs.EnableRedraw(True)
def runScript():
obj_ids = rs.GetObjects("Objects for SVG export", rs.filter.curve + rs.filter.hatch +rs.filter.annotation, preselect=True)
if not obj_ids: return
rectangle = rs.GetRectangle()
if not rectangle:return
exportSVG(obj_ids, rectangle)
runScript()
I see that Rhino interprets gradients in SVGās a bit different from Google Crome too:
PS! @gustojunk You do know that you can add transparency to gradient colors and curve colors too?
But for some reason transparency seem to work better on a gradient than by using a solid hatch with a transparent color:
MATCAP icon gradient.3dm (1.1 MB)