Пример #1
0
        private void clearAppearance() //清除所有表达
        {
            Search search = new Search();

            search.Selection.SelectAll();

            //oDoc.Models.ResetAllPermanentMaterials();

            VariantData oData = VariantData.FromDisplayString("门");

            SearchCondition oSearchCondition = SearchCondition.HasPropertyByDisplayName("项目", "类型");

            oSearchCondition = oSearchCondition.EqualValue(oData);
            search.SearchConditions.Add(oSearchCondition);
            ModelItemCollection items = search.FindAll(oDoc, false);

            oDoc.Models.OverridePermanentColor(items, Autodesk.Navisworks.Api.Color.Blue);
            oDoc.Models.OverridePermanentTransparency(items, 0.5);

            Search search1 = new Search();

            search1.Selection.SelectAll();
            oData = VariantData.FromDisplayString("房间");

            oSearchCondition = SearchCondition.HasPropertyByDisplayName("项目", "类型");
            oSearchCondition = oSearchCondition.EqualValue(oData);
            search1.SearchConditions.Add(oSearchCondition);
            items = search1.FindAll(oDoc, false);
            oDoc.Models.OverridePermanentColor(items, Autodesk.Navisworks.Api.Color.White);
            oDoc.Models.OverridePermanentTransparency(items, 1);
            //oDoc.CurrentSelection.CopyFrom(items);
        }
Пример #2
0
        private object createSearch(object category, object property, object value, object Negate)
        {
            //https://adndevblog.typepad.com/aec/2012/08/add-search-selectionset-in-net.html

            Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;

            //Create a new search object
            Search          s      = new Search();
            SearchCondition sc     = SearchCondition.HasPropertyByDisplayName(category.ToString(), property.ToString());
            bool            negate = Negate != null?bool.Parse(Negate.ToString()) : false;

            if (negate)
            {
                sc = sc.Negate();
            }


            s.SearchConditions.Add(sc.EqualValue(VariantData.FromDisplayString(value.ToString())));


            //Set the selection which we wish to search
            s.Selection.SelectAll();
            s.Locations = SearchLocations.DescendantsAndSelf;

            //halt searching below ModelItems which match this
            s.PruneBelowMatch = true;

            return(s);
        }
Пример #3
0
        private object createSearchSet(object name, object category, object property, object value)
        {
            //https://adndevblog.typepad.com/aec/2012/08/add-search-selectionset-in-net.html

            Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;

            //Create a new search object
            Search          s  = new Search();
            SearchCondition sc = SearchCondition.HasPropertyByDisplayName(category.ToString(), property.ToString());

            s.SearchConditions.Add(sc.EqualValue(VariantData.FromDisplayString(value.ToString())));


            //Set the selection which we wish to search
            s.Selection.SelectAll();
            s.Locations = SearchLocations.DescendantsAndSelf;

            //halt searching below ModelItems which match this
            s.PruneBelowMatch = true;

            //get the resulting collection by applying this search
            ModelItemCollection searchResults = s.FindAll(Autodesk.Navisworks.Api.Application.ActiveDocument, false);
            SelectionSet        selectionSet  = new SelectionSet();

            selectionSet.DisplayName = name.ToString();
            selectionSet.CopyFrom(s);
            Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.InsertCopy(0, selectionSet);
            var ss = Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.ToSavedItemCollection();


            return(ss);
        }