Hi,
Can you try uploading your code again? I don't see it attached.
The example in this DevBlog searches for items using the number property. (not sure if it will be any help)
http://adndevblog.typepad.com/manufacturing/2012/08/get-where-used-information-for-an-item.html
Thanks,
Wayne
Hi,
I updated the Vault SDK ItemEditor sample so it gets a couple of properties. This sample is here on my system:
C:\Program Files (x86)\Autodesk\Autodesk Vault 2014 SDK\VS10\CSharp\ItemEditor
The attached zip file has the updated project. You will probably need to add the references back in to get it to build. It is not doing everything you wanted but it should be a starting point for getting properties of items.
Here is the function that gets the property. Some of the code is an update from an example in the SDK help. (LINQ is Your Friend - topic)
//wB added
String myGetItemPropertyByPropertyNameOld(Item mySuppliedItem, string myPropertyName)
{
string returnString = string.Empty;
try
{
PropDef[] itemProps = m_connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("ITEM");
// use LINQ to query the array IEnumerable<PropDef> selection =
from propDef2 initemProps
wherepropDef2.DispName == myPropertyName
selectpropDef2;
if(selection.Count() == 0)
thrownewException("Property not found");
PropDefitemNamePropDef = selection.First();
long[] itemIdArray = new long[] { mySuppliedItem.Id };
PropInst[] propValues = m_connection.WebServiceManager.PropertyService.GetProperties(
"ITEM", itemIdArray, new long[] { itemNamePropDef.Id });
// LINQ will sort for you IEnumerable<PropInst> sortedValues =
from value in propValues
orderby value.Val
selectvalue;
PropInst[] values1 = sortedValues.ToArray();
PropInstmyPropInst = values1[0];
if (myPropInst.Val != null)
{
returnString = myPropInst.Val.ToString();
}
}
catch (Exceptionex) { }
finally{ }
return returnString;
}
//wB end added
Thanks,
Wayne
Hi,
I don't see the attachment. Adding again. (if it doesn't work I will email it to you)
Thanks,
Wayne
Hi,
I used the GetProperties of the PropertyService because GetPropertyValue() of PropertyManager takes an IEntity and Item does not derive from IEntity. I was getting a compile error or a runtime error when I tried to cast the Item. I ased a colleague in engineering about this. Here is an excerpt of their reply:
>> >>
While the Autodesk.Connectivity.WebServices.Item class does not implement the IEntity interface, the VDF’s Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.ItemRevision class does and can be constructed from an Item object. See this article for more info on converting between the web service proxy classes and VDF currency classes: http://help.autodesk.com/view/VAULT/Help/ENU/?guid=GUID-67E7D386-9361-4CA0-B878-E1B337A89AB6. Once you have the VDF’s ItemRevision instance, you should be able to use the PropertyManager to retrieve item properties. An additional benefit of using the VDF layer to retrieve properties is that it will handle caching for you.
I’m not sure what the one or two hops question is about, necessarily. Going through the VDF layer might result in multiple web service calls while going directly through the web services API will only result in one, but still, using the VDF layer typically will see better performance, I believe, because of optimizations such as caching.
<< <<
Thanks,
Wayne