Create new CustomObject

Create new CustomObject

Anonymous
Not applicable
773 Views
4 Replies
Message 1 of 5

Create new CustomObject

Anonymous
Not applicable

Is it possible to create a new CustomObject through the API?

Going through the Object Browser, it looks like its only possible to create a CustomObjectDefinition (AddCustomObjectDefinition)

 

 

0 Likes
Accepted solutions (1)
774 Views
4 Replies
Replies (4)
Message 2 of 5

Markus.Koechl
Autodesk
Autodesk

You can create any custom object once you know the id of the custom object definition. The concept is getting the definition ID, creating the new object and finally adding property values.

Compare the sample to create custom objects "Task":

#region Create Task
	$mCustentDefId = ($vault.CustomEntityService.GetAllCustomEntityDefinitions() | Where-Object { $_.DispName -eq "Task"}).Id
	$mCustentName =$JobAttributes.Number
	$mNewCustent = $vault.CustomEntityService.AddCustomEntity($mCustentDefId , $mCustentName)
	
	$propInstParamArray = New-Object Autodesk.Connectivity.WebServices.PropInstParamArray
	$CustentPropDefs = $vault.PropertyService.GetPropertyDefinitionsByEntityClassId("CUSTENT")

	#create property def.id/value pairs 
	#ToDo: replace by looping the Attributes
	$propInstParam = New-Object Autodesk.Connectivity.WebServices.PropInstParam
	$propInstParam.PropDefId = ($CustentPropDefs | Where-Object { $_.DispName -eq "Title"}).Id
	$propInstParam.Val = $JobAttributes.Title
	$propInstParamArray.Items += $propInstParam

	$propInstParam = New-Object Autodesk.Connectivity.WebServices.PropInstParam
	$propInstParam.PropDefId = ($CustentPropDefs | Where-Object { $_.DispName -eq "Description"}).Id
	$propInstParam.Val = $JobAttributes.Description
	$propInstParamArray.Items += $propInstParam

$vault.CustomEntityService.UpdateCustomEntityProperties(@($mNewCustent.Id), $propInstParamArray)


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks Markus - I will give it a try:-)

 

But please enligthen me. What is the difference between a CustomEntity and a CustomObject?

 

/Michael

 

0 Likes
Message 4 of 5

Markus.Koechl
Autodesk
Autodesk
Accepted solution

It is the same; Custom Object is the name in the user interface, Custom Entity is the name in the API.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
Message 5 of 5

Anonymous
Not applicable

I am trying to convert the ps to vb, but run into trouble, when creating the parameter array object.

The .Items is nothing, which causes a runtime error. What am I missing here?

Dim iCustEnt(0) As Long
            iCustEnt(0) = connection.WebServiceManager.CustomEntityService.AddCustomEntity(3, "My great custom object").Id
            Dim oParams(0) As PropInstParamArray
            oParams(0) = New PropInstParamArray
            For Each oPropDef As PropDef In connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("CUSTENT")
                If oPropDef.DispName = "CC GroupId" Then
                    Dim oPropParam As New PropInstParam
                    oPropParam.PropDefId = oPropDef.Id
                    oPropParam.Val = "myVal1"
                    Dim i As Int16 = oParams(0).Items.Count ' Fails in this line
                    oParams(0).Items.Append(oPropParam)
                End If
            Next
            connection.WebServiceManager.CustomEntityService.UpdateCustomEntityProperties(iCustEnt, oParams)

-------

Before spending too much time on this track, I would like to know if using CustomObjects is a good idea? Asking because it seems the api is unsupported.

I want to use the Vault list to control the jobprocessor. ie, when a custom object is approved, it should trigger the JobProcessor to start an action.

Instead of using a Custom Object, I could also just use a folder with "dummyfiles", as the API to handle files looks more mature?

 

Thanks in advance.

 

 

 

 

 

 

 

 

 

0 Likes