Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Run a script on all items within a workspace

15 REPLIES 15
Reply
Message 1 of 16
dkeeley
1089 Views, 15 Replies

Run a script on all items within a workspace

Hi,

 

It would be good if there was an easy way to run a script on all items within a workspace.

 

Thanks,

 

David.

Labels (1)
15 REPLIES 15
Message 2 of 16
jared.sund
in reply to: dkeeley

 
Jared Sund
Sr. Product Line Manager, Product Lifecycle Management
Autodesk, Inc.
Message 3 of 16
nguyentru
in reply to: dkeeley

Hi David,

 

With the release of 9.05, the feature to run action script on demand allow users to run the script without being tied to a workflow or behavior.

 

I beleive this will solve you problem to run a script on all items within a workspace.

 

 

thank you,

 

Trung

Trung Nguyen | PLM Product Management | Autodesk, Inc.
Message 4 of 16
dkeeley
in reply to: dkeeley

Hi Trung,

 

I don't think this addresses what I'm looking for. I want a way to run a script on all items within a workspace at once (or at least sequesntially but from a single command). The solution you're discussing, although very welcome, only allows scripts to be run on one item at a time.

 

Regards,

 

David.

Message 5 of 16
gasevsm
in reply to: dkeeley

Hi David, I understand your idea well. Yet i'd like to better understand the problem and the motivation behind it. What are you trying to solve that lead you to this idea? Thanks in advance,

Martin Gasevski | Fusion 360 Team Product Manager
Message 6 of 16
dkeeley
in reply to: dkeeley

Hi Trung,

 

I'll give you an example. I have a workspace at the moment with a couple of thousant items in it. All of those items have milestones. I've decided that I want to stop using milestones in that workspace so I want to remove them from each of the items. I think the only way to do this (apart from the UI) is trough scripting.

 

David.

Message 7 of 16
AstroRossD
in reply to: dkeeley

If I may add a further example...

 

As an Import does not run an on-create script at present, running a script on all items would allow this to be overcome.

 

Alternatively if Imports could run scripts, using an Import to edit item details and then run anon-edit script would be a better solution as it would not require a new on-demand script to be created.

Message 8 of 16
gasevsm
in reply to: dkeeley

Yes agreed - triggering create and edit scripts for new and updated items respectively via import is something we are looking into a near-term.

Martin Gasevski | Fusion 360 Team Product Manager
Message 9 of 16

Hi,

 

Is there still no way to run an action script on all the existing items in a workspace?

 

Thanks,

Jonathan 

Message 10 of 16

There is a rest api to call an on-demand script on a dmsid.

I use a utility to run a report to get the dmsids, then loop through calling on-demand script for each item.

Use a filter on the report to identify items not yet processed, so you can safely restart the task.

 

Both the /reports api, and the on-demand script api, are Gets, not Posts, so they are at the easier end of the Rest api.

 

I've written such a utility for myself, others have done similar too. I use it almost every day for various jobs.

But there is nothing in the product to run anything in batch.

Message 11 of 16

Hey Philip,
Thanks for the quick response. I am very unfamiliar with the REST API as I have only just started to work with Fusion. I do have a programming background, I just don't know where to start with REST. I am also swamped with other work that isn't Fusion focused so the easiest and quickest solution would be great.
What's the easiest way to get started on REST?

Thanks,
Jonathan
Message 12 of 16
sven.dickmans
in reply to: dkeeley

To help you getting started with the REST API, you may want to have a look at my library of code examples: https://knowledge.autodesk.com/support/fusion-360-manage/learn-explore/caas/simplecontent/content/fu...

This library consists of basic building blocks based on node.js that you can use to get familiar with the given API calls. It even contains an example that shows how to run a given script on a defined record (#62).

 

What do you want to achieve with the scripts exactly? I also have a library of 'admin helpers' which automate certain admin activities by using the REST API. Would any of these tools shown below be of help? You could use 'Touch Records' for example to update a defined property on all records in a defined workspace to trigger the edit event for these records and with that enforce the edit event script to run. This is very helpful after data imports (which do not trigger the edit event), but might be useful for your use case as well. If these tools are value for you, I am happy to share them.

 

Screenshot 2022-12-09 at 17.49.47.png

Message 13 of 16
sk11111
in reply to: sven.dickmans

I am experiencing some sort of authentication issue after following the instructions. I found a single posting with the same problem related to general v3 API access but it wasn't resolved, so I am asking here again with respect to this tutorial...

               

If I run the script 00-authenticate.js, it appears to run successfully with the following output:

             Login to tenant XXXXXX successful

 

If I run the script 70-workspaces-get-list.js (or any other than 00), I get:

            
             Login to F3M tenant XXXXXXX successful
             Error: Request failed with status code 401

 

Followed by a very verbose error output and eventually:

             data: {
                errorCode: 'SEC_UNAUTHORIZED',
                message: 'Login failed, no user mapped to the given client.',
                params: null,
                url: null,
                errorClass: 'APIError'
            }

 

Any ideas?

Message 14 of 16
sk11111
in reply to: sk11111

OK, quick response to my own posting.... I was poking around in the Administration-->System Configuration-->General Settings page where you have to set your Client ID obtained from Forge. While doing so, I realized that the Client ID field was truncating. The field allows for 32 characters max but the ClientID is 48 characters.  Using Chrome, I right clicked Inspect and found the text entry box by searching for "Allowed List". I was able to edit this to 48, able to paste in my full Client ID, and almost fell out my chair when I saw it accepted then again when the Node.js script worked.... Sounds like a bug to be fixed but I'll let the experts weigh in...

 

On a related note, where can someone find the "admin-helper" tools referenced in the preceding post?

 

Thanks!

Message 15 of 16
sven.dickmans
in reply to: dkeeley

You're right, the ClientID gets truncated right now when you paste & save it in General Settings. I expect this bug to be resolved soon. I occurs right now because the ClientIDs generated by APS are longer since last week. This is not an issue for the code within node.js - therefore, the script 00-authenticate.js works fine. Only once the code really has to connect to PLM with the ClientID (like in 70-workspaces-*), this is causing problems. I will keep you posted once the ClientIDs in PLM do not get truncated any longer.

The admin-helper utilities are available here: https://github.com/dickmans/plm-utilities. After downloading the package, provide your environment settings in settings.js, then you will be able to run all the utilities in folder admin-helpers using node.js

Message 16 of 16
sven.dickmans
in reply to: dkeeley

@dkeeley The servers got updated yesterday and you can now store the ClientIDs, they do not get truncated any longer.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums