- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear Inventors,
while coding my Inventor-Plugin I hit a problem:
In order to identify parts in my company, there is an ID in the "Inventor User Defined Properties".
Now in order to extract the ID, I want to access the PropertySet using my property name. In VBA no problem with the .Item() method. But this doesn't exist in the .net API?
The only method I found that works is:
foreach (Property _p in (Inventor.PropertySet)_ps)
{
try
{
if (_p.Name == "PART_ID")
{
id = _p.Value.ToString();
return id;
}
}
catch { }
}
But that is way too slow for my application (I have to iterate 1000+ parts).
So then I fount the GetPropertyInfo() function of the PropertySet - but using that gives me a "Object reference not set to an instance..." error?
Inventor.PropertySet _psc = ((Inventor.PropertySet)_ps);
_psc.GetPropertyInfo(out int[] pids, out string[] Names, out object[] Values);
// fails with Object reference not set to an instance... error
if (pids != null)
{
id = Values[Array.IndexOf(Names, "PART_ID")].ToString();
}
So what is your advice to most efficiently get one Property from a parts PropertySet in C#?
Thank you so much,
Robert
Solved! Go to Solution.