Grasshopper

algorithmic modeling for Rhino

Hey

Im trying to make a component for previewing text as curves (since GH cant work with text objects) and then bake them as text when a button is pushed, so they can be edited further in rhino or illustrator for example. The component needs to be mac compatible, that's why I want to do it with python and rhino common.

So far I've managed to make this happen for one letter with a single outline (when the string I input only gets one outline when exploded, to be precise). 

I'd be very greatfull for any tips on how to "coerce" more than one curve so they can be previewed through grasshopper before anything is baked. Attached is the component so far.

Views: 1733

Attachments:

Replies to This Discussion

Just realized i forgot to post the code right here in the discussion, you'll find it below.

Any help or tips appriciated, really need to get this problem sorted and I just don't get what Im doing wrong or what Im missing. Thanks a bunch!

Code:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino as r

sc.doc = r.RhinoDoc.ActiveDoc

geoList =[]

preText = rs.AddText(text, plane, height, font, font_style=0, justification=None)
textGeo = rs.ExplodeText(preText, True)

ghGeo = rs.coercegeometry(textGeo)

for item in textGeo:
rs.DeleteObject

if BAKE == True:
bakeText = rs.AddText(text, plane, height, font, font_style=0, justification=None)

Alright... Attached is an updated script.

I must say I find all the different scripting languages confusing, and Im not entierly sure what I can or cant use to make the script run on Mac. For instance... Can I use the rhinoscriptsyntax commands found here: http://developer.rhino3d.com/api/RhinoScriptSyntax/win/?? It says they're intended for Python, but they're also called "rhinoscriptsyntax" and RhinoScript doesnt work on Mac... But is this RhinoScript, or mere functions that just happen to have a rather similar name? RhinoScript code looks very different to me after all.

Anyways, here's the code I have now which works fine on my PC for what I want to do, but it seems the "ExplodeText" doesnt work on Mac. It returns the text one more time even though it's set to only return outlines (see script).

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino as r

sc.doc = r.RhinoDoc.ActiveDoc

geoList = []

preText = rs.AddText(text, plane, height, font, font_style=fontStyle, justification=None)
textGeo = rs.ExplodeText(preText, True)

for i in textGeo:
    geoList.append(rs.coercegeometry(i))


for i in textGeo:
    rs.DeleteObject(i)

if BAKE == True:
    bakeText = rs.AddText(text, plane, height, font, font_style=0, justification=None)

Attachments:

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service