• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Navisworks API

    Reply
    Active Contributor
    Posts: 32
    Registered: ‎11-14-2012
    Accepted Solution

    From ModelItem to Timeliner Task(s)

    163 Views, 6 Replies
    12-16-2012 03:03 PM

    Hi,

     

    I am trying to find TimeLiner Task(s) that contain(s) a given ModelItem. I'd like to avoid looping on all tasks as this may be extremely time consuming considering the number of tasks.

     

    Using the PropertyCategories.DataProperties I can find names and basic properties of the tasks a ModelItem is linked to, but they are all of type "DisplayString". Can I retrieve the TimeLiner Task instance from there?

     

    My goal would be achieve by either displaying "Synchronization ID" or "Display ID" of the TimeLiner task in the ModelItem Property panel (eg PropertyCategory.DataProperties) OR by being able to retrieve the TimeLiner Task instance from the ModelItem (and then read the properties I want with some custom code).

     

    Thank you for your suggestions,

    -Nicolas

    Please use plain text.
    ADN Support Specialist
    xiaodong.liang
    Posts: 805
    Registered: ‎06-12-2011

    Re: From ModelItem to Timeliner Task(s)

    01-07-2013 10:38 PM in reply to: ngombault

    Hi,  

     

    TimelinerTasks is a collection of ICollection which supports LINQ. You can search it without iterating.

              

    Nw.Document doc = Nw.Application.ActiveDocument;

    Nw.DocumentParts.IDocumentTimeliner tl = doc.Timeliner;

    Tl.DocumentTimeliner tl_doc = (Tl.DocumentTimeliner)tl; 

     

    IEnumerable<SavedItem> items =

            from x in tl_doc.Tasks

            where x.DisplayName == "task1"

            select x;

     

    MessageBox.Show(items.Count<SavedItem>().ToString());



    Xiaodong Liang
    Developer Technical Services
    Autodesk Developer Network

    Please use plain text.
    Active Contributor
    Posts: 32
    Registered: ‎11-14-2012

    Re: From ModelItem to Timeliner Task(s)

    01-07-2013 10:53 PM in reply to: xiaodong.liang

    Hi xiaodong,

     

    Thank you for answering to me, again.

     

    I understand this method you propose, it sure requires less lines of code than an iteration loop although it might be just what LINQ is doing behind...

     

    I am surpirsed that there is no link between a model item and its timeliner tasks; especially, an item can be in a task with a none unique name and thus the LINQ query will return multiple match that I'll have to go through to find the correct one, am I correct?

     

    also, can the timeliner be scrolled to a task programaticaly? Say I find the task I was looking for, can I get the timeliner to zoom on it rather that have the user scroll down and expand collapse nodes manually?

     

    Thank you.

    Nic

    Please use plain text.
    ADN Support Specialist
    xiaodong.liang
    Posts: 805
    Registered: ‎06-12-2011

    Re: From ModelItem to Timeliner Task(s)

    01-10-2013 11:51 PM in reply to: ngombault

    I am surpirsed that there is no link between a model item and its timeliner tasks; especially, an item can be in a task with a none unique name and thus the LINQ query will return multiple match that I'll have to go through to find the correct one, am I correct?

    It looks to me you are correct. And I did not find a property to identify two tasks with same display name. I am not sure there is any solution. It not, this is a good wish.

     

    also, can the timeliner be scrolled to a task programaticaly? Say I find the task I was looking for, can I get the timeliner to zoom on it rather that have the user scroll down and expand collapse nodes manually?

     

    I am not clear the question. From task you can know the attached object. it will not difficult to zoom to the objects. Why it requires to scroll down to select the task and select selection?



    Xiaodong Liang
    Developer Technical Services
    Autodesk Developer Network

    Please use plain text.
    Active Contributor
    Posts: 32
    Registered: ‎11-14-2012

    Re: From ModelItem to Timeliner Task(s)

    01-11-2013 04:36 AM in reply to: xiaodong.liang

    Because I'd like to retrieve the timelinertask a model item is attached too.

     

    If I select a model item that is in a task the information I get from the Property panel are very limited, if I want to find out the Synchronization ID of the TimelinerTask or its Activity ID then I need to be able to find the TimelinerTask from the model item.

     

    My only goal here, is to get the timelinertask ID from a selected model item.

     

    I'm gonna go for the option you first proposed and then loop through the matches to check if the model item is in the attachments.

     

    cheers,

    -Nic

    Please use plain text.
    Active Contributor
    Posts: 32
    Registered: ‎11-14-2012

    Re: From ModelItem to Timeliner Task(s)

    01-11-2013 04:58 AM in reply to: ngombault

    Sorry, I only read the end of your answer, I thought the rest was quote.


    I'd like to be able to highligh/show/scroll to the task in the timeliner because that is one of the navigation I need when assigning attachment to tasks; sometimes I need to select an object and easily go to the task it belongs to and do some attachment management there...

     

    I think this is currently not possible; thank you for your help anyway.

     

    -Nic

    Please use plain text.
    ADN Support Specialist
    xiaodong.liang
    Posts: 805
    Registered: ‎06-12-2011

    Re: From ModelItem to Timeliner Task(s)

    01-14-2013 08:06 PM in reply to: ngombault

    Thanks for the description. I think I understand it now. If there were a property/method to set current timeliner task (like the user selects a row/sub-row), your requirement would be possible. Unfortunetly, it looks to me no such API either. :smileysad:

     

    I logged wishes for the two requirements. 



    Xiaodong Liang
    Developer Technical Services
    Autodesk Developer Network

    Please use plain text.