<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: edit and/or delete a task in Navisworks API Forum</title>
    <link>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8420225#M3813</link>
    <description>&lt;P&gt;@Anonymous,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sorry, I was not able to get back timely.&amp;nbsp;To delete/add/move the child task, the corresponding API is Timeliner.TaskRemoveAt,&amp;nbsp; Timeliner.TaskAddCopy, Timeliner.TaskMove. While the trick is to use the original task as the parent (Group Item), instead of copy. The Copy is mainly for&amp;nbsp;the scenario when you want to edit the properties of a original task. Similarly, when you want to edit a child task, you will need to make copy of child task, while use original parent task as the group item in&amp;nbsp;&lt;I&gt;TaskEdit.&lt;/I&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;The code below explains.&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;I&gt; &amp;nbsp; &lt;/I&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;I&gt;DocumentTimeliner doc_timeliner = doc.GetTimeliner();

TimelinerTask oParentTask = doc_timeliner.Tasks[0] as TimelinerTask;&amp;nbsp;&lt;BR /&gt;
//to delete a child task, call TaskRemoveAt with the source task object
if (oTask.Children.Count &amp;gt; 0) 
&amp;nbsp; &amp;nbsp;//try to delete the first child task 
&amp;nbsp; &amp;nbsp;doc_timeliner.TaskRemoveAt(oParentTask, 1); &lt;BR /&gt;&lt;BR /&gt;//if edit the properties of parent task
TimelinerTask oParentTaskCopy = oTask.CreateCopy();
oParentTaskCopy.DisplayName = "new-" + oParentTaskCopy.DisplayName;
doc_timeliner.TaskEdit(0, oParentTaskCopy);&lt;BR /&gt;&lt;BR /&gt;//if edit the properties of child task&lt;BR /&gt;TimelinerTask oChildTask = oParentTask.Children[0] as TimelinerTask; &lt;BR /&gt;TimelinerTask oChildCopyTask = oChildTask.CreateCopy(); &lt;BR /&gt;oChildCopyTask.DisplayName = "new-" + oChildCopyTask.DisplayName; &lt;BR /&gt;doc_timeliner.TaskEdit(oParentTask, 0, oChildCopyTask);&lt;BR /&gt;&lt;/I&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Nov 2018 09:46:34 GMT</pubDate>
    <dc:creator>xiaodong_liang</dc:creator>
    <dc:date>2018-11-23T09:46:34Z</dc:date>
    <item>
      <title>edit and/or delete a task</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8024283#M3804</link>
      <description>&lt;P&gt;through API is it possible to edit o delete a specific task?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 15:47:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8024283#M3804</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-24T15:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: edit and/or delete a task</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8025785#M3805</link>
      <description>&lt;P&gt;Find timeliner project on sdk&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 07:21:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8025785#M3805</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-25T07:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: edit and/or delete a task</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8026015#M3806</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;can you say me with solution (name of the solution) do you mean please?&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 09:02:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8026015#M3806</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-25T09:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: edit and/or delete a task</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8029232#M3807</link>
      <description>&lt;P&gt;&lt;SPAN&gt;It means to look for navisworks sdk&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 May 2018 00:32:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8029232#M3807</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-28T00:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: edit and/or delete a task</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8029736#M3808</link>
      <description>&lt;P&gt;Could you send me the navisowrks sdk example that you mean please?&lt;/P&gt;</description>
      <pubDate>Mon, 28 May 2018 08:40:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8029736#M3808</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-28T08:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: edit and/or delete a task</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8321802#M3809</link>
      <description>&lt;P&gt;Any solution at the end?&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/823624"&gt;@xiaodong_liang&lt;/a&gt;&amp;nbsp;could you have a look please?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 09:35:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8321802#M3809</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-10-09T09:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: edit and/or delete a task</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8372756#M3810</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous，&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I might probably miss the context. if editing task, it is straightforward. The only trick is to copy a task, edit the copy and set back. e.g.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;         Document doc = Nw.Application.ActiveDocument; 
            DocumentTimeliner doc_timeliner = doc.GetTimeliner();
            TimelinerTask oTask = doc_timeliner.Tasks[0] as TimelinerTask;
            TimelinerTask oTaskCopy = oTask.CreateCopy();
            oTaskCopy.DisplayName = "new-" + oTaskCopy.DisplayName;
            doc_timeliner.TaskEdit(0, oTaskCopy);&lt;/PRE&gt;&lt;P&gt;And I suggest you take a look at the SDK sample&amp;nbsp;@Anonymous&amp;nbsp;mentioned. And also the blogs on&amp;nbsp;&lt;A href="https://adndevblog.typepad.com,&amp;nbsp;" target="_blank"&gt;https://adndevblog.typepad.com,&amp;nbsp;&lt;/A&gt; though some contents might be out of date.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 04:19:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8372756#M3810</guid>
      <dc:creator>xiaodongliang</dc:creator>
      <dc:date>2018-11-01T04:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: edit and/or delete a task</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8373995#M3811</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1152168"&gt;@xiaodongliang&lt;/a&gt;&amp;nbsp;for answering,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried our code, but I get "null" in oTask. Please see the picture attached.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both the SDK sample that&amp;nbsp;@Anonymous&amp;nbsp;mentioned and the blogs &lt;A href="https://adndevblog.typepad.com/aec/2012/10/timeliner-api-part2.html" target="_blank"&gt;https://adndevblog.typepad.com/aec/2012/10/timeliner-api-part2.html&amp;nbsp;&lt;/A&gt;&amp;nbsp;are different method, they use the *csv file as export and import. My purpose is to replace the task direcly in Navisworks: delete the task and put it the new one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="picture1.jpg" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/564448i054E9086EA0766AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="picture1.jpg" alt="picture1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 15:33:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8373995#M3811</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-01T15:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: edit and/or delete a task</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8380938#M3812</link>
      <description>&lt;P&gt;Hello Mr.&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1152168"&gt;@xiaodongliang&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I happen to have the same issue as&amp;nbsp;@Anonymous. The only difference is that I want to edit the Children Tasks from a Task.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code you shared worked perfectly for a normal task, but when I&amp;nbsp;edit the Children Tasks in oTaskCopy, the changes are not reflected in the Timeliner. Here is the code:&lt;/P&gt;&lt;PRE&gt; for (int iPosition = 0; iPosition &amp;lt; 1; iPosition++)
            {&lt;BR /&gt;               //Declaration of variables
                TimelinerTask oTask = StartForm.doc_timeliner.Tasks[0] as TimelinerTask;       //Gets the checked task
                TimelinerTask oTaskCopy = oTask.CreateCopy();       //Creates a copy of the selected task
                TimelinerTask taskToInsert = oTask.CreateCopyWithoutChildren();
&lt;BR /&gt;                //Modifications to the task that is doing to be inserted as a ChildrenTask
                taskToInsert.DisplayName = "Example1";
                taskToInsert.EquipmentCost = Convert.ToDouble(StartForm.taskList[1].taskCost);
&lt;BR /&gt;                //Modification to the task that is going to be inserted as a normal Task
                oTaskCopy.DisplayName = StartForm.taskList[1].taskName;
                DateTime.TryParse(StartForm.taskList[1].EndDate, out hola);
                oTaskCopy.ActualEndDate = hola;
                oTaskCopy.LaborCost = Convert.ToDouble(StartForm.taskList[1].taskCost);
&lt;BR /&gt;                //Methods of editing the Timeliner
                oTaskCopy.Children.Remove(oTaskCopy.Children[1]);
                //oTaskCopy.Children.Insert(1, taskToInsert);
                StartForm.doc_timeliner.TaskEdit(0, oTaskCopy);
         }&lt;/PRE&gt;&lt;P&gt;oTaskCopy has the modifications for the normal Task&lt;/P&gt;&lt;P&gt;taskToInsert has the modifications of the ChildrenTasks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I debug the oTaskCopy.Children[1] it appears to me that the children task in position 1 was removed, but when I use the TaskEdit method&amp;nbsp;in the Timeliner, the modifications in the big task happen like they should, but the children tasks stay exactly the way they were.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another thing is that, when I uncomment the line:&lt;/P&gt;&lt;PRE&gt;//oTaskCopy.Children.Insert(1, taskToInsert);&lt;/PRE&gt;&lt;P&gt;I receive an error that says: " Cannot evaluate expression because the code of the current method is optimized"&lt;/P&gt;&lt;P&gt;I already looked into the blogs and did the solutions they shared, but the error is still there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, just to clarify the question.&lt;/P&gt;&lt;P&gt;How can I manipulate the Children Tasks like the code shared in the previous comment does with the normal tasks?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is going on with the "method is optimized" issue?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Javier&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 16:33:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8380938#M3812</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-05T16:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: edit and/or delete a task</title>
      <link>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8420225#M3813</link>
      <description>&lt;P&gt;@Anonymous,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sorry, I was not able to get back timely.&amp;nbsp;To delete/add/move the child task, the corresponding API is Timeliner.TaskRemoveAt,&amp;nbsp; Timeliner.TaskAddCopy, Timeliner.TaskMove. While the trick is to use the original task as the parent (Group Item), instead of copy. The Copy is mainly for&amp;nbsp;the scenario when you want to edit the properties of a original task. Similarly, when you want to edit a child task, you will need to make copy of child task, while use original parent task as the group item in&amp;nbsp;&lt;I&gt;TaskEdit.&lt;/I&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;The code below explains.&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;I&gt; &amp;nbsp; &lt;/I&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;I&gt;DocumentTimeliner doc_timeliner = doc.GetTimeliner();

TimelinerTask oParentTask = doc_timeliner.Tasks[0] as TimelinerTask;&amp;nbsp;&lt;BR /&gt;
//to delete a child task, call TaskRemoveAt with the source task object
if (oTask.Children.Count &amp;gt; 0) 
&amp;nbsp; &amp;nbsp;//try to delete the first child task 
&amp;nbsp; &amp;nbsp;doc_timeliner.TaskRemoveAt(oParentTask, 1); &lt;BR /&gt;&lt;BR /&gt;//if edit the properties of parent task
TimelinerTask oParentTaskCopy = oTask.CreateCopy();
oParentTaskCopy.DisplayName = "new-" + oParentTaskCopy.DisplayName;
doc_timeliner.TaskEdit(0, oParentTaskCopy);&lt;BR /&gt;&lt;BR /&gt;//if edit the properties of child task&lt;BR /&gt;TimelinerTask oChildTask = oParentTask.Children[0] as TimelinerTask; &lt;BR /&gt;TimelinerTask oChildCopyTask = oChildTask.CreateCopy(); &lt;BR /&gt;oChildCopyTask.DisplayName = "new-" + oChildCopyTask.DisplayName; &lt;BR /&gt;doc_timeliner.TaskEdit(oParentTask, 0, oChildCopyTask);&lt;BR /&gt;&lt;/I&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 09:46:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/navisworks-api-forum/edit-and-or-delete-a-task/m-p/8420225#M3813</guid>
      <dc:creator>xiaodong_liang</dc:creator>
      <dc:date>2018-11-23T09:46:34Z</dc:date>
    </item>
  </channel>
</rss>

