Message 1 of 2
Moving text within a sketch breaks the world

Not applicable
09-17-2017
02:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
import adsk.core, adsk.fusion, traceback def Point3D(x, y): return adsk.core.Point3D.create(x, y, 0) def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface des = adsk.fusion.Design.cast(app.activeProduct) root = des.rootComponent sketch = root.sketches.add(root.xYConstructionPlane) msg = ( 'this is my string it might be long\n' 'and multi lined.\n\n' 'I would like to be able to center it\n' 'in the sketch space.') text_input = sketch.sketchTexts.createInput(msg, 0.25, Point3D(1, 1)) text_input.fontName = 'Consolas' txt = sketch.sketchTexts.add(text_input) text_p = txt.boundingBox.maxPoint.copy() text_p.x = -(text_p.x - 1) / 2 text_p.y = -(text_p.y - 1) / 2 text_p.z = 0 txt.position = text_p except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
This code breaks the drawing it is run in. Documentation states that text position can be SET but when you do set it the UCS icon vanishes and it's impossible to zoom/pan to anything.