Decal API in direct modeling mode raises "RuntimeError: 2 : InternalValidationError : timelineObj"

Decal API in direct modeling mode raises "RuntimeError: 2 : InternalValidationError : timelineObj"

hajime2MRG3
Enthusiast Enthusiast
382 Views
1 Reply
Message 1 of 2

Decal API in direct modeling mode raises "RuntimeError: 2 : InternalValidationError : timelineObj"

hajime2MRG3
Enthusiast
Enthusiast

I tested new Decal API and it works well in parametric modeling mode. But I think it doesn't in direct modeling mode.

The code below runs OK for parametric modeling mode, but not for direct modeling mode.

import traceback
import sys
import pathlib
import adsk.core as ac
import adsk.fusion as af

IMG_PATH = pathlib.Path(sys.base_prefix).absolute() / 'Python/AddInSamples/CommandSample/commands/Basic/resources/32x32.png'


def run(context):
    app: ac.Application = ac.Application.get()
    try:
        ui = app.userInterface
        test_decal(app, True)
        test_decal(app, False)

    except Exception:
        msg = traceback.format_exc()
        print(msg)
        if ui is not None:
            ui.messageBox('Failed:\n{}'.format(msg))


def should_true(x):
    if not x:
        raise Exception()


def create_profile(root_comp: af.Component):
    s = root_comp.sketches.add(root_comp.xYConstructionPlane)
    should_true(s.sketchCurves.sketchLines.addTwoPointRectangle(
        ac.Point3D.create(-1., -2., 0.),
        ac.Point3D.create(2., 1., 0.)
    ))
    return s.profiles.item(0)


def create_face(root_comp: af.Component):
    profile = create_profile(root_comp)
    pfs = root_comp.features.patchFeatures
    p_in = pfs.createInput(profile, af.FeatureOperations.NewBodyFeatureOperation)
    pf = pfs.add(p_in)
    return pf.bodies[0].faces[0]


def test_decal(app: ac.Application, is_parametric_mode):
    _ = app.documents.add(ac.DocumentTypes.FusionDesignDocumentType)
    app.activeProduct.designType = af.DesignTypes.ParametricDesignType if is_parametric_mode else af.DesignTypes.DirectDesignType
    root_comp: af.Component = app.activeProduct.rootComponent

    face = create_face(root_comp)

    if is_parametric_mode:
        base_feature = root_comp.features.baseFeatures.add()
        should_true(base_feature.startEdit())

    o = ac.Point3D.create()
    di = root_comp.decals.createInput(str(IMG_PATH), [face], o)

    if is_parametric_mode:
        di.targetBaseFeature = base_feature
        should_true(base_feature.finishEdit())

    _ = root_comp.decals.add(di)

The exception is "RuntimeError: 2 : InternalValidationError : timelineObj" at "root_comp.decals.add(di)".

0 Likes
383 Views
1 Reply
Reply (1)
Message 2 of 2

hajime2MRG3
Enthusiast
Enthusiast

Anyone? I tried with Fusion 2.0.20754 x86_64 and this problem still occur.

0 Likes