Fabrication API "Custom Data" field referencing.

Anonymous

Fabrication API "Custom Data" field referencing.

Anonymous
Not applicable
var baseDim10 = value.CustomData[0].Data.Id;
var baseDim11 = value.CustomData[1].Data.Id;

I have two custom data fields, I am able to show the Data ID so I know I am referencing the right one. However, I want be able to reference what is actually in the Custom Data field. (SEE PHOTO)

0 Likes
Reply
Accepted solutions (1)
777 Views
2 Replies
Replies (2)

jazpearson
Autodesk
Autodesk
Accepted solution

Hi tmistretta,

 

I'm not 100% sure what you're asking, so i'll do my best to help you. 

 

Firstly, it looks like you are looking at the CustomItemData collection on the Item class. Is that right?

That class is an abstract type, which means the objects you want to reference derive from this class. Looking at the picture, it looks like they could be CustomDataStringValue objects.

 

So to reference them properly, you can do something like this:

 

var baseDim10 = (value.CustomData[0].Data) as CustomDataStringValue;

or 

if (value.CustomData[0].Data is CustomDataStringValue)
{
    var stringValue = value.CustomData[0].Data as CustomDataStringValue;
    var value = stringValue.Value;   
}

Hope that helps!

 

Anonymous
Not applicable

Thanks again Jaz. I did end up figuring it out on my own but your method was actually shorter and more simple!

0 Likes