How to get the model from a modelitems using Jlink?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
How to get the model from a modelitems using Jlink?
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.
- Labels:
-
Jlink
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Are your model items components ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanku sjuraj ,How to access the model by its id ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
