Feature.linkedFeatures property

Feature.linkedFeatures property

kandennti
Mentor Mentor
164 Views
0 Replies
Message 1 of 1

Feature.linkedFeatures property

kandennti
Mentor
Mentor

Hi there.

Please let me know about the Feature.linkedFeatures property.

 

From the documentation description, it seems like I can get the related features.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-7c8c7b91-476d-4e44-a557-11d45f7e27aa 

 

I have created the following script and checked the linkedFeatures.count for some data, but it always returns 0.

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui = adsk.core.UserInterface.cast(None)
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct

        if des.designType != adsk.fusion.DesignTypes.ParametricDesignType:
            return

        timeline: adsk.fusion.Timeline = des.timeline
        backupMarker = timeline.markerPosition

        lst = []

        for idx in range(timeline.count):
            timeObj: adsk.fusion.TimelineObject = timeline.item(idx)

            feat: adsk.fusion.Feature = adsk.fusion.Feature.cast(timeObj.entity)
            if not feat:
                continue

            timeObj.rollTo(True)
            before = feat.linkedFeatures.count

            timeObj.rollTo(False)
            after = feat.linkedFeatures.count

            lst.append(f'{feat.name} : {before} - {after}')

        timeline.markerPosition = backupMarker

        dump('** linkedFeatures.count **')
        dump('Feature Name : Before Count - After Count')
        dump('-------')
        if len(lst):
            dump('\n'.join(lst))

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

def dump(s):
    print(s)
    adsk.core.Application.get().log(s)

This script does not work in direct mode, but I have confirmed that the linkedFeatures property returns "None" in direct mode.

 

Is the linkedFeatures property working?
If so, under what data conditions can the features be retrieved?

(If the pattern's Object Type is set to feature, the count is 0.)

0 Likes
165 Views
0 Replies
Replies (0)