// add new property to existing category
        public InwOaPropertyVec AddNewPropertyToExtgCategory(InwGUIAttribute2 propertyCategory)
        {
            // COM state (document)
            InwOpState10 cdoc = ComApiBridge.State;
            // a new propertycategory object
            InwOaPropertyVec category = (InwOaPropertyVec)cdoc.ObjectFactory(
                nwEObjectType.eObjectType_nwOaPropertyVec, null, null);

            // retrieve existing propertydata (name & value) and add to category
            foreach (InwOaProperty property in propertyCategory.Properties())
            {
                // create a new Property (PropertyData)
                InwOaProperty extgProp = (InwOaProperty)cdoc.ObjectFactory(nwEObjectType.eObjectType_nwOaProperty,
                                                                           null, null);
                // set PropertyName
                extgProp.name = property.name;
                // set PropertyDisplayName
                extgProp.UserName = property.UserName;
                // set PropertyValue
                extgProp.value = property.value;
                // add to category
                category.Properties().Add(extgProp);
            }

            // create a new PropertyData and add to category
            InwOaProperty newProp = (InwOaProperty)cdoc.ObjectFactory(nwEObjectType.eObjectType_nwOaProperty,
                                                                      null, null);

            newProp.name     = "2021Champions_Internal";
            newProp.UserName = "******";
            newProp.value    = "Who Knows!!";
            category.Properties().Add(newProp);
            return(category);
        }
Ejemplo n.º 2
0
        private static void SetValues(ModelItem m, string CategoryName, string PropertyName, string value)
        {
            state = ComApiBridge.State;
            InwOaPath oPath = ComApiBridge.ToInwOaPath(m);

            // get properties collection of the path

            InwGUIPropertyNode2 propertyNode = state.GetGUIPropertyNode(oPath, true) as InwGUIPropertyNode2;

            // creating tab (Category), property null variables as placeholders
            InwGUIAttribute2 existingCategory = null;

            //Index of userDefined Tab
            int index = 1;

            //Case 1: Look for an existing category with the same CategoryName

            foreach (Autodesk.Navisworks.Api.Interop.ComApi.InwGUIAttribute2 attribute in propertyNode.GUIAttributes())
            {
                if (attribute.UserDefined)
                {
                    if (attribute.ClassUserName == CategoryName)
                    {
                        existingCategory = attribute;
                        NavisProperties properties = new NavisProperties(PropertyName, value, existingCategory);
                        setProperty(properties, index, propertyNode);
                        return;
                    }

                    index++;
                }
            }


            //Case 2: Category doesn´t exist, create category and property
            if (existingCategory == null)
            {
                NavisProperties properties = new NavisProperties(PropertyName, value, CategoryName);
                setCategoryAndProperty(properties, propertyNode);
                return;
            }
        }
Ejemplo n.º 3
0
            public NavisProperties(string name, string value, InwGUIAttribute2 existingCategory)
            {
                newP.name  = name;
                newP.value = value;

                CategoryName = existingCategory.ClassUserName;
                foreach (InwOaProperty item in existingCategory.Properties())
                {
                    if (item.name != name)
                    {
                        //Cant be the same item? do i need to re create it everytime?
                        InwOaProperty existingProp = state.ObjectFactory(nwEObjectType.eObjectType_nwOaProperty) as InwOaProperty;
                        existingProp.name  = item.name;
                        existingProp.value = item.value;

                        PropertyVec.Properties().Add(existingProp);
                    }
                }

                PropertyVec.Properties().Add(newP);
            }