Loading specific version of a derived component via API or Text Commands

Loading specific version of a derived component via API or Text Commands

CL604
Participant Participant
1,178 Views
10 Replies
Message 1 of 11

Loading specific version of a derived component via API or Text Commands

CL604
Participant
Participant

Hi guys,

 

for my case I need to load a specific version of a derived component. So far I can refresh the derived components to the newest version via TextCommand:

 

 

# Force a deep refresh to update all external references
app.executeTextCommand(u'Commands.Start PLM360DeepRefreshDocumentCommand')

 

 
Also I am able to load a specific file version when I open a single file on its own:

 

# Open a specific file version
adsk.core.Application.get().documents.open(file_version)

 

 
I can not find anything in the API Reference Manual and so far I have not found a good documentation on all available text commands.
 
Thanks for helping me out here or point me in the right direction to get this working.
0 Likes
1,179 Views
10 Replies
Replies (10)
Message 2 of 11

BrianEkins
Mentor
Mentor

Here's some example code that should do it. I found a bug where the call to change the version is erroring even though it appears to be successful. I'll see if a bug can get logged for this.

 

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

        occ: adsk.fusion.Occurrence = ui.selectEntity('Select an occurrence.', 'Occurrences').entity

        if not occ.isReferencedComponent:
            ui.messageBox('The selection component must be an external reference.')
            return
        
        docRef = occ.documentReference
        versionCount = docRef.dataFile.versions.count
        if versionCount == 1:
            ui.messageBox('The referenced file must have more than one version.')
            return

        currentVersion = docRef.dataFile.versionNumber
        if currentVersion == 1:
            # The first version is active so use the second version.
            version = 2
        else:
            # Get the previous version number.
            version = currentVersion - 1

        docRef.version = version
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 11

CL604
Participant
Participant

 

Hello Brian,

 

Thank you very much for your response and the code you provided—it’s been incredibly helpful. After spending some time tinkering, I’ve been able to make some progress, and I noticed that the initial bug has since been resolved.

However, I’m encountering a persistent issue related to accessing documentReference. Specifically:

 

 

 

docRef = occ.documentReference

 

 

 

This works well for inserted components but not for derived components. Although derived components have versions available, attempting to check documentReference results in an error, as it seems this reference is not available for derived components, even thought those are external components.
 

The Fusion Support Team suggested that I post here to potentially bring this to the development team’s attention. It would be a huge benefit if there were a way to get and set the version of a derived component via documentReference.

 

Any insights or solutions would be greatly appreciated. Thank you in advance for any guidance or suggestions!

0 Likes
Message 4 of 11

BrianEkins
Mentor
Mentor

I looked into this and it seems there is an issue with derived components. The API has never been updated to support derived components and it looks like they're being left out of the referenced components list so there's no way to access them. I think for now, this isn't possible until support for derive is added.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 11

CL604
Participant
Participant

Hello Brian,

 

thanks for looking into that matter.

Yes, isReferencedComponent returns false.

What would you suggest in order to get derived components listet in the referenced components list, since they are referenced but not listed yet? Would you suggest reporting this as a bug, or perhaps submitting a feature request to get derived components included in that list?

 

Thanks in advance for your answer!

0 Likes
Message 6 of 11

BrianEkins
Mentor
Mentor

I've talked to the API team about this and it's already in their backlog.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 7 of 11

CL604
Participant
Participant

Hello Brian,

 

I wanted to check in if you have heard anything from the API team. Unfortunately, the last months we did not receive any update about this matter. I've seen there have been some changes to the history placement and GUI interface and was very much hoping for this bug to be fixed as well.

 

It would be very helpful for us to know the status because it's almost been a year since we / you initially reported about this problem and a fix would be very important for us.

 

Thanks for your answer in advance.

0 Likes
Message 8 of 11

CL604
Participant
Participant

@BrianEkins have you received any feedback from the dev team? If you could write us a quick update, it would be greatly appreciated. Thanks in advance!

0 Likes
Message 9 of 11

BrianEkins
Mentor
Mentor

No additional work has been done to support derived components in the API. I don't know when it might be supported.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 10 of 11

CL604
Participant
Participant

Hello @BrianEkins thanks a lot for the update, do you think there is anything we can do to get the developers to expedite the support since it's already in their backlog for so long?

0 Likes
Message 11 of 11

BrianEkins
Mentor
Mentor

I checked, and no additional progress has been made on this. They do expect to start looking at the issue soon, though.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes