Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
I have a model in my session.Using ModelItems i Sent my model into modelitems and get the Id of features.
Session session=pfcGlobal.GetProESession(); //GET MODEL Model mod=session.GetCurrentModel(); ModelItems item; item=mod.ListItems(ModelItemType.ITEM_FEATURE);
I get all the Id's inside a model.Now What i want,Access each model based on the Id using Jlink program.Please help me to solve my problem.
Solved! Go to Solution.
You do not have to list ModelItems, you can directly list components. This code will add models in your assembly to Models object:
Assembly asm = (Assembly) session.GetActiveModel();
Features components = asm.ListFeaturesByType(null, FeatureType.FEATTYPE_COMPONENT);
Models models = Models.create();
for(int i = 0; i < components.getarraysize(); i++) {
ComponentFeat component = (ComponentFeat) components.get(i);
ModelDescriptor md = component.GetModelDescr();
Model model = session.GetModelFromDescr(md);
models.append(model);
}
Are your model items components ?
You do not have to list ModelItems, you can directly list components. This code will add models in your assembly to Models object:
Assembly asm = (Assembly) session.GetActiveModel();
Features components = asm.ListFeaturesByType(null, FeatureType.FEATTYPE_COMPONENT);
Models models = Models.create();
for(int i = 0; i < components.getarraysize(); i++) {
ComponentFeat component = (ComponentFeat) components.get(i);
ModelDescriptor md = component.GetModelDescr();
Model model = session.GetModelFromDescr(md);
models.append(model);
}
Thanku sjuraj ,How to access the model by its id ?
I think this is not possible to get model by id https://community.ptc.com/t5/Additional-Creo-Questions/How-to-get-session-id-of-a-model-using-toolkit/td-p/101410
To access model use ModelDescriptor instead. It is more complex and built for handling models.