extrude text in a script

extrude text in a script

fon-tijn
Observer Observer
460 Views
2 Replies
Message 1 of 3

extrude text in a script

fon-tijn
Observer
Observer

im trying to extrude text in a fusion 360 script but when i try to do it i get an error error: 

Traceback (most recent call last):

text = texts.profiles.item(0)

AttributeError: 'SketchTexts' object has no attribute 'profiles'

 

how do i get the text profile?

0 Likes
461 Views
2 Replies
Replies (2)
Message 2 of 3

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

The error you get is because the object "texts" of type "SketchTexts" doesn't have a property "profile".

The outlines of the text is available on SketchText.asCurves() method.

 

Here there is an example of a extruded text:

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        rootComp = adsk.fusion.Design.cast(app.activeProduct).rootComponent
        sketches = rootComp.sketches
        sketch: adsk.fusion.Sketch = sketches.add(rootComp.xYConstructionPlane)
        sketch.name = 'texts'

        skTexts = sketch.sketchTexts
        txtInput = skTexts.createInput2("Test", 2)
        txtInput.setAsMultiLine(adsk.core.Point3D.create(0,0,0),
                                adsk.core.Point3D.create(4,10,0),
                                adsk.core.HorizontalAlignments.CenterHorizontalAlignment,
                                adsk.core.VerticalAlignments.MiddleVerticalAlignment,
                                10)
        skText = skTexts.add(txtInput)

        hg = adsk.core.ValueInput.createByString("5 mm")
        efInput = rootComp.features.extrudeFeatures.createInput(skText, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        extHh = adsk.fusion.DistanceExtentDefinition.create(hg)
        efInput.setOneSideExtent(extHh, adsk.fusion.ExtentDirections.PositiveExtentDirection)
        extrudedText = rootComp.features.extrudeFeatures.add(efInput)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Hope this help.

 

Regards,

Jorge

Message 3 of 3

fon-tijn
Observer
Observer

it works now. Thanks a lot

0 Likes