RoboFont › Forums › Help / General › Add an anchor
This topic contains 13 replies, has 3 voices, and was last updated by qkeave 6 years, 9 months ago.
-
AuthorPosts
-
November 15, 2013 at 22:22 #5732
Simple question, how the heck do I add an anchor? (in python)
November 15, 2013 at 23:16 #5733g = CurrentGlyph() g.appendAnchor("name", (100, 100))
see also http://www.robofab.org/objects/glyph.html
good luck
November 26, 2013 at 06:54 #5736thank you!
November 26, 2013 at 08:05 #5737Thanks and sorry! I’m probably not as good at searching as I thought I was.
– BUT –
this of course leads to more questions.– How do I set guides to measure
– How do I ACTUALLY remove guides (because I can’t get removeGuide() to work)I’ve attached the little tool I’m making below for context.
___________________________
g = CurrentGlyph() ancs = [] gd = ['Radial 0deg','Radial 20deg','Radial 40deg','Radial 60deg','Radial 80deg','Radial 100deg','Radial 120deg','Radial 150deg','Radial 160deg'] for a in g.anchors: b = a.name ancs.append(b) if 'Radial Guide' not in ancs: g.appendAnchor("Radial Guide", (500, 500)) for a in g.guides: if a.name in gd: #THIS IS WHERE I WANT TO REMOVE THE GUIDE #removeGuide(a) print g.guides for a in g.anchors: if a.name == 'Radial Guide': x = a.x y = a.y g.addGuide((x, y), 90, name="Radial 0deg") g.addGuide((x, y), 110, name="Radial 20deg") g.addGuide((x, y), 130, name="Radial 40deg") g.addGuide((x, y), 150, name="Radial 60deg") g.addGuide((x, y), 170, name="Radial 80deg") g.addGuide((x, y), 190, name="Radial 100deg") g.addGuide((x, y), 210, name="Radial 120deg") g.addGuide((x, y), 230, name="Radial 150deg") g.addGuide((x, y), 250, name="Radial 160deg") #I JUST NEED TO SET THESE TO MEASURE print '' print 'Digested by Python.'
November 26, 2013 at 15:25 #5738try this:
g.removeGuide(a)
November 26, 2013 at 18:40 #5740thanks Thom that works,
now I just need to figure how to turn on measurements with python
November 30, 2013 at 15:12 #5752As measurements are a UI related attribute, it is not added to the robofab-like guide object.
However you can change the display of measurements of a guide with:
glyph = CurrentGlyph() guide = glyph.addGuide((100, 100), 90, "my guide") guide.naked().showMeasurements = True
to remove all guides you can also use
glyph.clearGuides()
good luck!
November 30, 2013 at 15:14 #5753and from a programming point of view it is maybe better to use
range(start, end, steps)
# print out an angle between 0° and 360° in steps of 15 for angle in range(0, 360, 15): print angle
December 3, 2013 at 07:13 #5754December 3, 2013 at 07:13 #5756Frederik, you are the man! I really appreciate the programming point.
That being said I want to report a bug. >_<
When you set the measurements via the scripting window it isn’t reflected in the WYSIWYG editor, even after CurrentFont().update().Attachments:
You must be logged in to view attached files.December 4, 2013 at 12:44 #5758mm, I cannot reproduce this bug
sample script:
glyph = CurrentGlyph() glyph.clearGuides() for a in glyph.anchors: for angle in range(0, 180, 15): guide = glyph.addGuide((a.x, a.y), angle) guide.naked().showMeasurements = True
January 9, 2014 at 21:41 #5763Well this is what I used (https://github.com/qkeave/Robofab-tools/blob/master/Radial%20Guides.py)
PS. How do I enable PrettyPrint on my code?
# Add Radial Guides - Quinn Keaveney g = CurrentGlyph() ancs = [] gd = [] for angle in range(0, 180, 15): gd.append("Radial {0}deg".format(angle)) for a in g.anchors: b = a.name ancs.append(b) if 'Radial Guide' not in ancs: g.appendAnchor("Radial Guide", (500, 500)) for a in g.guides: if a.name in gd: g.removeGuide(a) for a in g.anchors: if a.name == 'Radial Guide': x = a.x y = a.y for angle in range(0, 180, 15): g.addGuide((x, y), angle, name=("Radial {0}deg".format(angle))) guide = g.addGuide((x, y), angle, name=("Radial {0}deg".format(angle))) guide.naked().showMeasurements = True CurrentFont().update() print '' print 'Digested by Python.'
January 10, 2014 at 14:12 #5767see http://docs.python.org/library/pprint.html
import pprint data = [["nested Item1", "nested Item2", "nested Item3", "nested Item4"], "item1", "item2"] pprint.pprint(data)
good luck!
January 14, 2014 at 07:33 #5770Thanks!
-
AuthorPosts
You must be logged in to reply to this topic.