Use CreateTask Button using Python

Hello,

 

I have written a Python script in “Work Process” component to change the value of ‘Task’ , ‘ListOfProdID’ , ‘NewProdID’. Value has changed but I am not able to assign these values to the Work Process. It means I have to Click on “CreateTask” button to assign the values to “Work Process”, but I am not able to understand how to do it using Python script.

Can anyone help me on this?

Hi,

As far as I know, it’s not possible to trigger a button property from Python.

If you like to add a task to Work Process from a python script, just edit the Note behavior “Task::Task” directly. The text is in the “Note” property e.g.:

task_note =process_comp.findBehaviour(“Task::Task”)

note_content = task_note.Note

and write new content e.g.: task_note.Note = “New content…”

alternatively access the behavior property directly:

note_prop = process_comp.getProperty(“Task::Task::Note”)

and set it’s value by assigning to note_prop.Value = “New content…”

 

The most difficult part is to parse the Note (string) line by line and know to what line to add your task. You can take a look how it’s done in “TaskCreation” script’s create function.

I might ran in a similar problem, not completly sure what youre trying to do though. I wanted to set ProdID on multiple Works Processes automatically. So i used the #Comonent;;UserVariables::abc - Syntax on the Task::Task - Note and assigned the Property UserVariables::abc through a Controller-Component.You can look up the syntax in the Works-Tasks-Docs-File.

Not sure if thats what youre trying to do tho.

Hello,

 

Thanks to Jouha and RonSwansonIRL for the solution.

I want to fetch the data from SQL DB and according to data it should assign to components in 3D world. This should work through Python only. That’s why I was trying to use “CreateTask” button through Python.