public override int Execute(params string[] parameters)
        {
            // current document
            Document doc = Application.ActiveDocument;
            // COM state object
            InwOpState10 cdoc = ComApiBridge.State;
            // current selected items
            ModelItemCollection items = doc.CurrentSelection.SelectedItems;
            // convert ModelItem to COM Path
            InwOaPath citem = ComApiBridge.ToInwOaPath(items[0]);
            // Get item's PropertyCategoryCollection object
            InwGUIPropertyNode2 cpropcates = (InwGUIPropertyNode2)cdoc.GetGUIPropertyNode(citem, true);
            // Get PropertyCategoryCollection data
            InwGUIAttributesColl propCol = cpropcates.GUIAttributes();

            // loop propertycategory
            foreach (InwGUIAttribute2 i in propCol)
            {
                // if category's name match
                if (i.UserDefined && i.ClassUserName == "Premier League")
                {
                    // overwritten the existing propertycategory with
                    // newly created propertycategory(existing + new)
                    cpropcates.SetUserDefined(1, "Premier League", "PremierLeague_InternalName",
                                              AddNewPropertyToExtgCategory(i));
                }
            }

            return(0);
        }
        public override int Execute(params string[] parameters)
        {
            // current document (.NET)
            Document doc = Application.ActiveDocument;
            // current document (COM)
            InwOpState10 cdoc = ComApiBridge.State;
            // current selected items
            ModelItemCollection items = doc.CurrentSelection.SelectedItems;

            if (items.Count > 0)
            {
                // input dialog
                InputDialog dialog = new InputDialog();
                dialog.ShowDialog();
                foreach (ModelItem item in items)
                {
                    // convert ModelItem to COM Path
                    InwOaPath citem = (InwOaPath)ComApiBridge.ToInwOaPath(item);
                    // Get item's PropertyCategoryCollection
                    InwGUIPropertyNode2 cpropcates = (InwGUIPropertyNode2)cdoc.GetGUIPropertyNode(citem, true);
                    // create a new Category (PropertyDataCollection)
                    InwOaPropertyVec newcate = (InwOaPropertyVec)cdoc.ObjectFactory(nwEObjectType.eObjectType_nwOaPropertyVec, null, null);
                    // create a new Property (PropertyData)
                    InwOaProperty newprop = (InwOaProperty)cdoc.ObjectFactory(nwEObjectType.eObjectType_nwOaProperty, null, null);
                    // set PropertyName
                    newprop.name = dialog.PropertyName + "_InternalName";
                    // set PropertyDisplayName
                    newprop.UserName = dialog.PropertyName;
                    // set PropertyValue
                    newprop.value = dialog.PropertyValue;
                    // add PropertyData to Category
                    newcate.Properties().Add(newprop);
                    // add CategoryData to item's CategoryDataCollection
                    cpropcates.SetUserDefined(0, dialog.CategoryName, dialog.CategoryName + "_InternalName", newcate);
                }
            }
            return(0);
        }
コード例 #3
0
ファイル: SetValueByCatProp.cs プロジェクト: vnoves/ENGyn
 private static void setProperty(NavisProperties properties, int index, InwGUIPropertyNode2 propertyNode)
 {
     propertyNode.SetUserDefined(index, properties.CategoryName, properties.CategoryName, properties.PropertyVec);
 }
コード例 #4
0
ファイル: SetValueByCatProp.cs プロジェクト: vnoves/ENGyn
 private static void setCategoryAndProperty(NavisProperties properties, InwGUIPropertyNode2 propertyNode)
 {
     try { propertyNode.SetUserDefined(0, properties.CategoryName, properties.CategoryName, properties.PropertyVec); }
     catch (Exception exception) { MessageBox.Show(exception.Message); }
 }