Cancel
Showing results for 
Search instead for 
Did you mean: 

Object list

Experimenter
Experimenter

 Hi all,

 

I would like to know if there is a way to get a list of all the objects present in the document and then, filter by name (e.g. all the objects starting with letter J). I need to select all the humans, in order to get ergonomic reports. 

 

Thank you in advance,

Valentina

8 REPLIES

Re: Object list

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Hi Valentina,

 

The function below gets all the descendants objects that pass the specific type .

TxObjectList GetAllDescendants(ITxTypeFilter filter);

 

Every class that implements the ITxObjectCollection interface has this method.

 

The filter parameter lets you specify the type of object you want to get. 

 

The code to use in your case  (get all the human objects ) will be as follow:

 

TxPhysicalRoot study = TxApplication.ActiveDocument.PhysicalRoot;
TxTypeFilter humanFilter = new TxTypeFilter(typeof(TxHuman));
TxObjectList humans = study.GetAllDescendants(humanFilter);

 

Thanks,

AdiAvron

 

Re: Object list

Creator
Creator

I created an extension so that can get what im looking for without having to cast back and forth

 

public static class ITxObjectCollectionEx

{

public static List<T> GetAllDescendants<T>(this ITxObjectCollection obj)
where T:ITxObject
{
var filter = new TxTypeFilter(typeof(T));
var objects = obj.GetAllDescendants(filter).OfType<T>();
return objects.ToList();
}
/// <summary>
/// Helper to assist for enumeration
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="obj"></param>
/// <returns></returns>
public static List<T> GetDirectDescendants<T>(this ITxObjectCollection obj)
where T:ITxObject
{
var filter = new TxTypeFilter(typeof(T));
var objects = obj.GetDirectDescendants(filter).OfType<T>();
return objects.ToList();
}
}

Re: Object list

Pioneer
Pioneer
Which control should be used to get the list of particular type of objects and what changes require in properties of that control

Re: Object list

Valued Contributor
Valued Contributor

Luisy,

 

it is not any control, that will give you the list of types. To get the planning object type (I suppose, that you mind the planning object type of the object, not the .NET type) you should use PlanningRepresentation property of the ITxProcessModelObject interface. This returns the ITxPlanningObject, which has property PlanningObjectType.

Re: Object list

Creator
Creator
Thank you Witalij,

I need to get list of types in the Windows Form. Suppose i click a button and a list of types should be displayed in a Listbox or Listview or any in any other control of tecnomatix.

But main task of mine is to get types as list using windows form.

Thanks

Re: Object list

Creator
Creator

Hello Witalij, 

 

Like in picture attached here, i want to get types of object as list. Suppose i click on the list and it will displayed list. 

 

 

Re: Object list

Valued Contributor
Valued Contributor

Bishen,

 

I don't undestand what is your problem. To get a list of types? I suppose, that you mind an eM-Server types. In this case you need the eM-Server libraries. Please check if anywhere in your installation exists file eM-PlannerAPIManual.chm (file name might be slightly different) and you will figure out how to get the list of the defined types.

To populate the Windows Forms ListBox with the entries? Than it is a wrong place to find the answer on this question.

Re: Object list

Pioneer
Pioneer

Hi, Witalij,

 

I got e-Mserver same file as u mentioned. 

Thanx