Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get UDP from Files

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
meck
694 Views, 4 Replies

Get UDP from Files

Hi All,

I've been chasing my tail on this for a week now and have not figured it out. I'm doing a search by file name and getting the results using the line of code below. Now that I have the file/files is there no way to get a UDP from here? I've read every blog and search through this message board relentlessly. Although I admit not everything I've read have I understood.

 

We have a custom property call "Description" and I just want to get the value of the property. Can someone PLEASE help?

 

Thanks in advance!

 

Dim

files AsFile() = mgr.DocumentService.FindFilesBySearchConditions(NewSrchCond() {Srch}, Nothing, Nothing, False, True, bookmark, status)

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
4 REPLIES 4
Message 2 of 5
Balaji_07
in reply to: meck

Hi Mike,

 

Try this, Hope you don't need any description for the code 😉 Cheers!

 

 Dim filepropDefIds As New List(Of Long)

 Dim props() As PropDef = ServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")

Dim  filepropDefIds() = (from prop in props
                                      where prop.DispName.Equals("Description",StringComparison.InvariantCultureIgnoreCase).Equals(true)
                                      select prop.Id).ToArray()

If filepropDefIds isnot Nothing

 

  Dim _coPropInst() as  PropInst = adminServiceManager.PropertyService.GetProperties("FILE", new long() { _file.Id }, _filepropDefIds)

  Dim value as String = _coPropInst(0).Val

End If

 

Regards,

Balaji A

Message 3 of 5
meck
in reply to: Balaji_07

Worked great! I had to tweek some stuff, but it did the job. I don't understand all of it, but that's not new for me. LOL

Below is your tweeked code.

 

Thanks!!!!!

 

       

Dim props() AsPropDef = mgr.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")

       

Dim filepropDefIds() AsLong = (From prop In props Where prop.DispName.Equals("Description", StringComparison.InvariantCultureIgnoreCase).Equals(True) Select prop.Id).ToArray

       

If filepropDefIds IsNotNothingThen

           

Dim _coPropInst() AsPropInst = mgr.PropertyService.GetProperties("FILE", NewLong() {files(0).Id}, filepropDefIds)

           

Dim value AsString = _coPropInst(0).Val

 

       

EndIf

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
Message 4 of 5
Anonymous
in reply to: meck

Hi Mike,

 

The code which you have provided (thanks for that!) gives me an error: Error 1 Value of type 'Long' cannot be converted to '1-dimensional array of Long'.

Any idea how I can resolve this?

 

Below is the code I'm using.

 

'Get File ID
Dim FileID As Long = CLng(assoc.CldFileId)
'Get PropertyDef ID
Dim props() As PropDef = m_serviceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
Dim filepropDefIds() As Long = (From prop In props Where prop.DispName.Equals("Revision", StringComparison.InvariantCultureIgnoreCase).Equals(True) Select prop.Id).ToArray

 If filepropDefIds IsNot Nothing Then
'Get propertyDef value
Dim _coPropInst As PropInst = m_serviceManager.PropertyService.GetProperties("FILE", FileID, filepropDefIds)'This rule generates the error
Dim FileRev As String = _coPropInst(0).Val

 Thanks

 

Danny

 

Message 5 of 5
Anonymous
in reply to: Anonymous

This did the trick:

 

Dim PropInsts() AsPropInst = m_serviceManager.PropertyService.GetProperties("FILE", NewLong() {FileID}, NewLong() {filepropDefIds(0)})

 

Thanks Mike for your reply.

 

Danny

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report