YD
Hello Community,
I have a question regarding to the retrieval of parent model.
If I have a ObjDef now and I would like to get the model to which the object belongs, how should I do that ?
Thanks in advance!
Best
The parent models are models in which occurrences exist that have your ObjDef as an object definition, aren't they?
Since your ObjDef can have multiple occurrences in multiple different models, there isn't "the" parent model, instead it's a list of models that can contain
- no models (if you deleted the only occurrence without deleting the object definition)
- one model (if you freshly created the occurrence and object definition, and didn't reuse the object definition in another model for another occurrence yet)
- multiple models (if you re-used the object definition at least once in another model)
The way I would solve your problem:
- Get a list of all object occurrences of your ObjDef
- Create an empty array
- For each found object occurrence just push the containing model into the previously created array
- In the end use the ArisData.Unique(...) method to ensure your array contains each model only one time at most
Should work something like this
var selObjDefs = ArisData.getSelectedObjDefs(); for each (var singleObjDef in selObjDefs){ var arrayForModelCollection = []; var occList = singleObjDef.OccList(); for each(var singleObjOcc in occList){ arrayForModelCollection.push(singleObjOcc.Model()); } var arrayOfUniqueModels = ArisData.Unique(arrayForModelCollection) }