コード例 #1
0
        /// <summary>
        /// Set the specified document property's value.  If the iproperty name exist it will set the value.
        /// If the name does not exist, it will add the property with the value you have specified in the
        /// "User Defined Properties" property set.  The long signature function must be used to specify custom
        /// property groups.
        /// </summary>
        /// <param name="document">Inventor.Document</param>
        /// <param name="propertySetName">Property Set Name as a string</param>
        /// <param name="propertyName">Property Name as a string</param>
        /// <param name="value"></param>
        public static void SetPropertyValue(this Document document, string propertySetName, string propertyName, object value)
        {
            PropertySets documentPropertySets = document.PropertySets;

            //If the property set exists, set the value, or add it if needed...
            if (PropertySetExists(document, propertySetName))
            {
                try
                {
                    documentPropertySets[propertySetName][propertyName].Value = value;
                    return;
                }
                catch
                {
                    documentPropertySets[propertySetName].Add(value, propertyName);
                }
            }
            else
            {
                try
                {
                    documentPropertySets.Add(propertySetName);
                    documentPropertySets[propertySetName].Add(value, propertyName);
                }
                catch { };
            }
        }
コード例 #2
0
ファイル: UnitTests.cs プロジェクト: 89096000/Maxscript-1
        public void PropertyTypeTest()
        {
            using (PropertySets propertySets = new PropertySets(s_testFile, false))
            {
                Console.WriteLine("Before:");
                DumpPropertySets(propertySets);

                if (propertySets.Contains(PropertySetIds.UserDefinedProperties))
                {
                    /* Clear all custom properties */
                    propertySets[PropertySetIds.UserDefinedProperties].Delete();
                }

                PropertySet custom = propertySets.Add(PropertySetIds.UserDefinedProperties, false);

                custom.Add("TestString", "Hello");
                custom.Add("TestDate", DateTime.Now);
                custom.Add("TestDouble", 1.0d);
                custom.Add("TestBoolean", false);

                Console.WriteLine();
                Console.WriteLine("After:");
                DumpPropertySets(propertySets);
            }
        }
コード例 #3
0
        /// <summary>
        /// Adds a new client PropertySet to the PropertySets collection. If a client property set
        /// of the same name exists, the method returns.
        /// </summary>
        /// <param name="displayName"></param>
        public void AddClientPropertySet(string displayName)
        {
            if (IsClientPropertySet(displayName))
            {
                return;
            }
            var newPropSet = PropertySets.Add(displayName);

            propertySetsList.Add(newPropSet);
            clientPropertySetsList.Add(newPropSet);
        }
コード例 #4
0
        public static Inventor.PropertySet GetPropertySet(PropertySets sets, string name, bool createIfDoesNotExist = true)
        {
            foreach (Inventor.PropertySet set in sets)
            {
                if (set.Name == name)
                {
                    return(set);
                }
            }

            return(createIfDoesNotExist ? sets.Add(name) : null);
        }
コード例 #5
0
ファイル: UnitTests.cs プロジェクト: 89096000/Maxscript-1
        public void ModifyDeleteAddPropertyTest()
        {
            using (PropertySets propertySets = new PropertySets(s_testFile, false))
            {
                Console.WriteLine("Before:");
                DumpPropertySets(propertySets);

                PropertySet projectInfo = null;
                if (propertySets.Contains(PropertySetIds.ProjectInformation))
                {
                    projectInfo = propertySets[PropertySetIds.ProjectInformation];
                }
                else
                {
                    projectInfo = propertySets.Add(PropertySetIds.ProjectInformation, false);
                }

                Property docNumber = null;
                if (projectInfo.Contains(ProjectInfoIds.DocumentNumber))
                {
                    docNumber = projectInfo[ProjectInfoIds.DocumentNumber];
                }
                else
                {
                    docNumber = projectInfo.Add(ProjectInfoIds.DocumentNumber, string.Empty);
                }
                docNumber.Value = "Testing";
                Console.WriteLine();
                Console.WriteLine("After modification:");
                DumpPropertySets(propertySets);

                docNumber.Delete();
                Console.WriteLine();
                Console.WriteLine("After deletion:");
                DumpPropertySets(propertySets);

                docNumber = projectInfo.Add(ProjectInfoIds.DocumentNumber, "New property");
                Console.WriteLine();
                Console.WriteLine("After adding:");
                DumpPropertySets(propertySets);
            }
        }
コード例 #6
0
ファイル: UnitTests.cs プロジェクト: 89096000/Maxscript-1
        public void DeleteAddPropertySetTest()
        {
            File.Copy(s_testFile, s_testFile + ".tmp");
            using (PropertySets propertySets = new PropertySets(s_testFile + ".tmp", false))
            {
                Console.WriteLine("Before deletion:");
                DumpPropertySets(propertySets);

                if (propertySets.Contains(PropertySetIds.SummaryInformation))
                {
                    propertySets[PropertySetIds.SummaryInformation].Delete();
                }

                PropertySet summaryInfo = propertySets.Add(PropertySetIds.SummaryInformation, false);

                summaryInfo.Add(SummaryInfoIds.Author, "Me");
                summaryInfo.Add(SummaryInfoIds.Created, DateTime.Now);

                Console.WriteLine();
                Console.WriteLine("After adding:");
                DumpPropertySets(propertySets);
            }
            File.Delete(s_testFile + ".tmp");
        }