[Bug] Modify a sketchText with an empty string gives weird result

[Bug] Modify a sketchText with an empty string gives weird result

JeromeBriot
Mentor Mentor
313 Views
0 Replies
Message 1 of 1

[Bug] Modify a sketchText with an empty string gives weird result

JeromeBriot
Mentor
Mentor

Hello,

 

Here is a script that creates a sketchText object with an empty string (i.e. ''). Then it modifies the text inside the object.

import adsk.core, traceback # pylint: disable=import-error

import math

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

        sketchTextInput = sketchTexts.createInput('', 1.0, adsk.core.Point3D.create(1.0, 1.0, 1.0))
      
        sketchText = sketchTexts.add(sketchTextInput)       

        sketchText.text = 'example'

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

 

Here is the result:

 

bug-sketchtext-empty-string-01.png

 

And when editing the sketch :

 

bug-sketchtext-empty-string-02.png

 

The height of the text should be 10mm but it is 38.344mm

bug-sketchtext-empty-string-03.png

Thank you

 

0 Likes
314 Views
0 Replies
Replies (0)