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: 

Project Scripting Question

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
674 Views, 14 Replies

Project Scripting Question

Hi,

 

I'm having some trouble with a project script that I'm writing. The script is as follows;

 

//Add task to the order
item.grid[0].SPAWNED_ORDER.project.addTask(item.SALES_ORDER_NUMBER.grid[10].TEST_TASK);

//Add task to the order
item.grid[1].SPAWNED_ORDER.project.addTask(item.SALES_ORDER_NUMBER.grid[11].TEST_TASK);

 

If I run either of these lines in isolation then the script runs fine. The task is added to the relevant item. However, when I try to run the script as shown then both tasks are added to the first SPAWNED_ORDER item only. I have attached a screenshot.

 

Thanks in advance for your help,

 

David.

14 REPLIES 14
Message 2 of 15
Anonymous
in reply to: Anonymous

Additional image

Message 3 of 15
jpiggee
in reply to: Anonymous

David,

 

Can you please attach the full script (with libraries if it uses any), I need to see what all of everything is going on in it.

Joseph Piggee
Fusion 360 Administrator
TPI Composites
jpiggee@tpicomposites.com
Message 4 of 15
Anonymous
in reply to: jpiggee

Joe,

 

PM me your email address and I'll add you to our tenant.

 

David.

Message 5 of 15
Anonymous
in reply to: Anonymous

OK. I think I added you to the tenant (I found your email address)

 

The action script you're looking for is '_TSM_OAIssued'

 

Thanks,

 

David

Message 6 of 15
jpiggee
in reply to: Anonymous

David,

 

This could be one of two things, so let’s check the easier one first.

If you were to condense the spawn location to a variable and then try to operate the script do you still get the same results?

 

Ie:

var spawnA=item.grid[0].SPAWNED_ORDER.project;

var spawnB=item.grid[1].SPAWNED_ORDER.project;

spawnA.addTask(item.SALES_ORDER_NUMBER.grid[10].TEST_TASK);

spawnB.addTask(item.SALES_ORDER_NUMBER.grid[11].TEST_TASK);

 

Also food for thought:

What is your plan for when you have more than two task to add and can you always insure the locations of the items are going to be where you say they are going to be?

 

The theory behind what you are trying to do is good, but I think you might find some issues with it down the road.

Joseph Piggee
Fusion 360 Administrator
TPI Composites
jpiggee@tpicomposites.com
Message 7 of 15
Anonymous
in reply to: jpiggee

Hi Joe,

 

I tried your modified script. Same problem remains. Perhaps I could use loadItem() to force the second project item to load??

 

Regarding my strategy for multiple tasks on projects - I have a plan. The main problem is that you cannot create relationships between items in the same script that spawns the itemm- but you can create links. So behind each project I have another workspace that links project numbers to tasks via the grid. So each column in the grid (apart from the first one that contains the project id) has a link to a different type of spawned task. So in one script I can spawn the project and tasks - then in the next I can link them all together. Rows in the grid will have different combinations of tasks depending on the type of project they are.

 

David.

Message 8 of 15
Anonymous
in reply to: Anonymous

OK,

 

using loadItem doesn't solve it either. I'm probably not using it correctly (actually I'm not eve sure what loadItem is for) but it was worth a shot.

 

//Add task to the order
item.grid[0].SPAWNED_ORDER.project.addTask(item.SALES_ORDER_NUMBER.grid[10].TEST_TASK);

//Add task to the order
var test = loadItem(item.grid[1].SPAWNED_ORDER.descriptor.dmsID);
test.project.addTask(item.SALES_ORDER_NUMBER.grid[11].TEST_TASK);

Message 9 of 15
Anonymous
in reply to: Anonymous

Hi Joe,

 

Any update on this?

 

David.

Message 10 of 15
Anonymous
in reply to: Anonymous

Hi Joe,

 

Based on our conversation today I tested a modified script that does not utilise any linking via grids. Guess what? Same problem occurs. It looks like a problem with the project scripting. What do you think?

 

var task1 = loadItem(12186)
var order1 = loadItem(12187);
order1.project.addTask(task1);

var task2 = loadItem(12188)
var order2 = loadItem(12185);
order2.project.addTask(task2);

Message 11 of 15
Anonymous
in reply to: Anonymous

 Joe,

 

I simplified the script even further to remove the linked tasks from the scope. The same issue still persists. Both tasks are created on the first project.

 

var order1 = loadItem(12187);
order1.project.addTask('Test1');

var order2 = loadItem(12185);
order2.project.addTask('Test2');

Message 12 of 15
jpiggee
in reply to: Anonymous

David,

 

Trung and I did some testing and this does fall into the limitation of the scripting engine. The limitation is that we can only write to multiple records if we are writing to the details tab only. If you need to write to a different tab then that is currently limited to a one to one relationship.

Joseph Piggee
Fusion 360 Administrator
TPI Composites
jpiggee@tpicomposites.com
Message 13 of 15
Anonymous
in reply to: jpiggee

OK. Thanks guys.

 

Is this a limitation that can be corrected easily or should I look at alternative scripting/design solutions?

 

David.

Message 14 of 15
jpiggee
in reply to: Anonymous

David,

 

At this point I would look for an alternative method of development.

Joseph Piggee
Fusion 360 Administrator
TPI Composites
jpiggee@tpicomposites.com
Message 15 of 15
Anonymous
in reply to: jpiggee

Guys,

 

Just FYI. Further testing has revealed that this limitation applies to reading as well as writing from the project tab. 

 

David.

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

Post to forums  

Autodesk Design & Make Report