Vault Customization

Vault Customization

Reply
Active Contributor
orbjeff
Posts: 31
Registered: ‎08-15-2011
Message 1 of 3 (237 Views)
Accepted Solution

Assign Property to a Category

237 Views, 2 Replies
03-01-2012 12:36 PM

Using the Vault 2012 API, I am able to create a new category and property definition. I'd like to then assign this new property definition to my new category.

 

Maybe another way to say this is that I want to make my new property a behavior of my new category. I've searched the API document and this forum but I can't figure out how to do that.

 

1.) Is this possible through the API?

2.) If yes which service and method would I use?

 

Thank you,

 

Jeff

Jeff Johnson
Technical Consultant
DataWorks MGI | a division of MasterGraphics Inc.

Yes, you can assign property definitions to a category through the API.  It's not a very intuitive set of functions.

 

 

Background:

A category is a collection of behaviors. A behavior is just a piece of functionality. Currently a category can have 3 types of behaviors: lifecycle definitions, revision schemes, and property definitions. In your case, it's the property definition behavior that you want to edit.

 

Solution:

The function you need to call is UpdateCategoryBehaviorAssignmentTypes in the CategoryService.

Here is what you do for each parameter:

categoryId - The ID of the category you are editing

behaviorClassName - pass in "UserDefinedProperty"

allowNoBehavior - I don't think this parameter applies to the property behavior. Vault Explorer passes in YES so you should do that too.

behaviorIds - pass in an array of all property definition IDs you want associated with this category. Since you are adding a prop def you need to pass in an array of all existing prop definitions with the new prop definition added.  (see next section)

behaviorAssignTypes - Again, I don't think this applies to categories. Just pass in an array of DEFAULT since that is what Vault Explorer does.

disableAllThenApply - Pass in TRUE here.

 

Finding the existing property definitions on a category:

GetCategoryConfigurationById should give you what you want. Pass in the category ID and tell it you want the UserDefinedProperty behavior.

It will give you back a CatCfg object which has the information you need. The BhvCfgArray[0].BhvArray property will be an array of all the existing property definition IDs for that category.

Employee
Redmond.D
Posts: 814
Registered: ‎12-12-2006
Message 2 of 3 (223 Views)

Re: Assign Property to a Category

03-05-2012 09:52 AM in reply to: orbjeff

Yes, you can assign property definitions to a category through the API.  It's not a very intuitive set of functions.

 

 

Background:

A category is a collection of behaviors. A behavior is just a piece of functionality. Currently a category can have 3 types of behaviors: lifecycle definitions, revision schemes, and property definitions. In your case, it's the property definition behavior that you want to edit.

 

Solution:

The function you need to call is UpdateCategoryBehaviorAssignmentTypes in the CategoryService.

Here is what you do for each parameter:

categoryId - The ID of the category you are editing

behaviorClassName - pass in "UserDefinedProperty"

allowNoBehavior - I don't think this parameter applies to the property behavior. Vault Explorer passes in YES so you should do that too.

behaviorIds - pass in an array of all property definition IDs you want associated with this category. Since you are adding a prop def you need to pass in an array of all existing prop definitions with the new prop definition added.  (see next section)

behaviorAssignTypes - Again, I don't think this applies to categories. Just pass in an array of DEFAULT since that is what Vault Explorer does.

disableAllThenApply - Pass in TRUE here.

 

Finding the existing property definitions on a category:

GetCategoryConfigurationById should give you what you want. Pass in the category ID and tell it you want the UserDefinedProperty behavior.

It will give you back a CatCfg object which has the information you need. The BhvCfgArray[0].BhvArray property will be an array of all the existing property definition IDs for that category.



Doug Redmond
Software Engineer
Autodesk, Inc.
http://justonesandzeros.typepad.com/

Active Contributor
orbjeff
Posts: 31
Registered: ‎08-15-2011
Message 3 of 3 (180 Views)

Re: Assign Property to a Category

04-20-2012 04:28 AM in reply to: Redmond.D

Doug,

 

Thanks for your help and the additional write up (with code) on your blog page. For anyone else interested its located here:

 

http://justonesandzeros.typepad.com/blog/2012/03/setting-the-properties-on-a-category.html

 

 

Jeff Johnson

 

Jeff Johnson
Technical Consultant
DataWorks MGI | a division of MasterGraphics Inc.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.