#Author- Autodesk #Description- Multiline text import adsk.core, adsk.fusion, traceback def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface design = app.activeProduct rootComp = design.rootComponent sketches = rootComp.sketches xyPlane = rootComp.xYConstructionPlane sketch = sketches.add(xyPlane) sketchTexts = sketch.sketchTexts cornerPt = adsk.core.Point3D.create(5.0, -10.0, 0.0) diagonalPt = adsk.core.Point3D.create(-10.0, 10.0, 0.0) horizontalAlignment = adsk.core.HorizontalAlignments.CenterHorizontalAlignment verticalAlignment = adsk.core.VerticalAlignments.BottomVerticalAlignment #create the text input sketchTextInput = sketchTexts.createInput2('Multiline Text', 1.5) # make input valid for multiline text type sketchTextInput.setAsMultiLine(cornerPt, diagonalPt, horizontalAlignment, verticalAlignment, 10) # get the MultiLineTextDefinition multilineDef = sketchTextInput.definition # givingrotation to frame about right bottom corner of frame angle = 3.14*0.25 multilineDef.rotate(angle, adsk.fusion.TextBoxKeyPoints.BottomRightTextBoxKeyPoint) # create the SketchText object sketchText = sketchTexts.add(sketchTextInput) verticalAlignment1 = adsk.core.VerticalAlignments.MiddleVerticalAlignment # get the MultiLineTextDefinition multilineDef1 = sketchText.definition #Edit WorkFlow # Change the vertical alignment and sapcing of text multilineDef1.verticalAlignment = verticalAlignment1 # Get the frame edges textFrameEdges = multilineDef1.rectangleLines #add the .shx font cornerPt1 = adsk.core.Point3D.create(0.0, 30.0, 0.0) diagonalPt1 = adsk.core.Point3D.create(20.0, 50.0, 0.0) sketchTextInput1 = sketchTexts.createInput2('TextForSHX', 10) sketchTextInput1.setAsMultiLine(cornerPt1, diagonalPt1, horizontalAlignment, verticalAlignment, 1) sketchText1 = sketchTexts.add(sketchTextInput1) sketchText1.fontName = "Weidner.shx" # Create the extrusion extrudes = rootComp.features.extrudeFeatures extInput = extrudes.createInput(sketchText, adsk.fusion.FeatureOperations.NewBodyFeatureOperation) distance = adsk.core.ValueInput.createByReal(0.8) extInput.setDistanceExtent(False, distance) extInput.isSolid = True ext = extrudes.add(extInput) m = sketch.sketchTexts.count n = sketch.profiles.count ui.messageBox("sketchTexts.count: %i \nprofiles .count: %i" % (m, n)) #sketch = sketches.item(0) #sketchText = sketch.sketchTexts.item(0) #sketchText.text = 'new text' except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))