Exemple #1
0
        //Function to return the taks and its attached model item to the  TYPESwitch class
        public void ShowTasks(Tl.TimelinerTask Task)
        {
            DateTime           PlannedStartDate       = new DateTime();
            DateTime           PlannedEndDate         = new DateTime();
            string             activytyDescription    = null;
            List <ElementData> TempListofSafetyIssues = new List <ElementData>();

            if (Task.Children.Count == 0)
            {
                PlannedStartDate = (DateTime)Task.PlannedStartDate;
                PlannedEndDate   = (DateTime)Task.PlannedEndDate;
                Tl.TimelinerSelection timeLinerSelection = Task.Selection;

                if (timeLinerSelection != null)
                {
                    if (timeLinerSelection.HasExplicitSelection)
                    {
                        activytyDescription = Task.DisplayName;
                        Nw.ModelItemCollection           oExplicitSel = timeLinerSelection.ExplicitSelection;
                        Nw.ModelItemEnumerableCollection modelItemEnumerableCollection = oExplicitSel.Descendants;
                        foreach (Nw.ModelItem modelItem in modelItemEnumerableCollection)
                        {
                            NewTYPESwitch.ModelItem = modelItem;
                            NewTYPESwitch.ElementSelector(activytyDescription);
                        }
                    }
                }
            }

            // If a task has children/subtasks, call it recursively till the end node is reached
            foreach (Tl.TimelinerTask childTask in Task.Children)
            {
                ShowTasks(childTask);
            }
        }
        private void addProperty(NVApi.ModelItem PropModelItem, string strPropName, string strPropValue)
        {
            try
            {
                COM.InwOpState10 state;
                state = ComApiBridge.State;
                // get current selection
                NVApi.ModelItemCollection modelItemCollectionIn = new NVApi.ModelItemCollection();
                modelItemCollectionIn.Add(PropModelItem);
                // get the selection in COM
                Autodesk.Navisworks.Api.Interop.ComApi.InwOpSelection comSelectionOut = ComApiBridge.ToInwOpSelection(modelItemCollectionIn);
                // get paths within the selection
                COM.InwSelectionPathsColl oPaths = comSelectionOut.Paths();
                COM.InwOaPath3            oPath  = (COM.InwOaPath3)oPaths.Last();
                // get properties collection of the path
                COM.InwGUIPropertyNode2 propn = (COM.InwGUIPropertyNode2)state.GetGUIPropertyNode(oPath, true);

                // create new property category
                // (new tab in the properties dialog)
                COM.InwOaPropertyVec newPvec = (COM.InwOaPropertyVec)state.ObjectFactory(COM.nwEObjectType.eObjectType_nwOaPropertyVec, null, null);
                // create new property
                COM.InwOaProperty newP = (COM.InwOaProperty)state.ObjectFactory(COM.nwEObjectType.eObjectType_nwOaProperty, null, null);
                // set the name, username and value of the new property
                newP.name     = "lc" + strPropName;
                newP.UserName = strPropName;
                newP.value    = strPropValue;
                // add the new property to the new property category
                newPvec.Properties().Add(newP);
                // add the new property category to the path
                propn.SetUserDefined(0, "NV-AddedProety", "lcNVAddedProety", newPvec);
            }
            catch
            {
                throw;
            }
        }