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: 

create Item UPDs per Api - how to create PropConstr-objexts

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ewcv
1010 Views, 4 Replies

create Item UPDs per Api - how to create PropConstr-objexts

the UPD is created by AddPropertyDefinition("Name", String,"Default_Value",null, null, null, null) and

UpdatePropertyDefinition(newId, ("Name", true, true, "Default_Val", new string() {"ITEM"} )

and is seen in Vault Explorer.

UpdatePropertyDefinitionInfo(newPropDef, eClsCtntSrcPropDefs, baseConstraints,null) fails: (IllegalInputParam [137]

the params:

eClsPropDefs[0] = new Autodesk.Connectivity.WebServices.EntClassCtntSrcPropCfg();

eClsPropDefs[0].EntClassId = "ITEM";

eClsPropDefs[0].CanCreateNewArray = new bool[] { false };

PropConstr[] baseConstraints = new Autodesk.Connectivity.WebServices.PropConstr[1];

baseConstraints[0] = new Autodesk.Connectivity.WebServices.PropConstr();

baseConstraints[0].CatId = -1;

baseConstraints[0].PropDefId = propInfo.PropDef.Id;

baseConstraints[0].PropConstrTyp = Autodesk.Connectivity.WebServices.PropConstrTyp.RequiresValue; baseConstraints[0].Val = "false";

but I don't have an ID for baseConstraints[0].Id

I noticed, when I assign e.g. a minimum length by Vault Explorer, there was a new entry in the table

PropConstraint with my newly created PropertyDefId and value.

I suppose, this PropConstraintId is the needes value, but I don't find a function like "AddPropertyConstraint"

What is to do?

4 REPLIES 4
Message 2 of 5
Daniel.Dulzo
in reply to: ewcv

Hi ewcv,

 

I don't think the issue is because you don't have an ID for the PropConstr. I think you're issue is caused by your EntClassCtntSrcPropCfg array. If you're trying to put a new constraint on a property, I would suggest just passing in the existing EntClassCtntSrcPropCfg array from the PropDefInfo of the PropDef you're trying to update. For example, try the following:

 

// create the udp

udp = wsManager.PropertyService.AddPropertyDefinition("UDP", DataType.String, false, true, "Default", null, null, null, null);

udp = wsManager.PropertyService.UpdatePropertyDefinition(udp.PropDef.Id, "UDP", true, true, "Default", newstring[] { "ITEM" });

 

PropConstr[] baseConstraints = newPropConstr[1];

baseConstraints[0] = newPropConstr();

baseConstraints[0].CatId = -1;

baseConstraints[0].PropDefId = udp.PropDef.Id;

baseConstraints[0].PropConstrTyp = PropConstrTyp.RequiresValue;

baseConstraints[0].Val = "false";

 

udp = wsManager.PropertyService.UpdatePropertyDefinitionInfo(udp.PropDef, udp.EntClassCtntSrcPropCfgArray, baseConstraints, null);



Daniel Dulzo
Software Engineer
Autodesk, Inc.
Message 3 of 5
ewcv
in reply to: ewcv

Hi Daniel,

thank you, but this helps only a few.

udp = wsManager.PropertyService.UpdatePropertyDefinition​(udp.PropDef.Id, "UDP", true, true, "Default", newstring[] { "ITEM" })  returns upd.EntClassCtntSrcPropCfgArray=null and upd.

PropConstrArray = null (see attachment Screenshot-PropDefInfo.JPG).

Because PropConstrTyp.Re​quiresValue=false is default, I tried with MinimumValue=1 and MaximumValue=100

UpdatePropertyDefinitionInfo​() is succesful, I see new 2 entries in table PropConstraint, but in Vault Explorer, i don't see minimum and maximum length (see Property.pdf).

I can assign all Item-categories, but no one has a minimum ormaximum length.

What do I have to do in addition?

Erika

Message 4 of 5
Daniel.Dulzo
in reply to: ewcv

So it sounds like you're trying to set multiple constraints for a property but you're only seeing one of the constraints being set? I'm not entirely sure what the problem might be without seeing more of the code you're using for creating the propety constraints array that you are passing into the UpdatePropertyDefinitionInfo() method, but I'd like to point out that you have to make sure all the contraints for the property are in that array, not just the ones you want to add. For example, to add a miminum length constraint, you could use code similar to the following:

 

PropConstr[] baseConstraints;

if(udp.PropConstrArray != null)

{

     baseContraints = new PropConstr[udp.PropConstrArray.Length + 1];

     udp.PropConstrArray.CopyTo(baseConstraints, 0);

}

else

     baseConstraints = new PropConstr[1]; 

int lastIndex = baseConstraints.Length - 1;

baseConstraints[lastIndex] = new PropConstr();

baseConstraints[lastIndex].CatId = -1;

baseConstraints[lastIndex].PropDefId = udp.PropDef.Id;

baseConstraints[lastIndex].PropConstrTyp = PropConstrTyp.MinimumLength;

baseConstraints[lastIndex].Val = "1";

udp = wsManager.PropertyService.UpdatePropertyDefinitionInfo(udp.PropDef, udp.EntClassCtntSrcPropCfgArray, baseConstraints, null);

 

Using this code, all constraints that were previously on the property are there, and a new constraint will be added. Also, you can verify that the constraints are added to the property by looking at the PropDefInfo object returned by the UpdatePropertyDefinitionInfo() method. If this still doesn't help, looking at more of the code you're using  to set up the parameters used for the UpdatePropertyDefinitionInfo() method might be helpful.



Daniel Dulzo
Software Engineer
Autodesk, Inc.
Message 5 of 5
ewcv
in reply to: ewcv

Hi Daniel,

I'm sorry, my bad: I specified PropConstrTyp.MinimumValue unstead of MinimumLength.

Thank you for your help anyway

Erika

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

Post to forums