Cancel
Showing results for 
Search instead for 
Did you mean: 

Particular type of object pick

Pioneer
Pioneer

Hello,

I have added a TxObjEditCtrlBox to windows form and set property (Validator type=component and picklevel=component).Then, with the pick event i want to pick only TxPlanningPart(only parts and assembly under Parts folder of Tree). As In training videos , it is shown how to pickup Robot but for TxPlanningTask i couldnt get proper result.

Can u help for that?

 

Thankx

 

 

6 REPLIES

Re: Particular type of object pick

Legend
Legend

Hello @Luisy

 

You need to setup a specific  filter that can collect compoundpart (TxCompoundPart) and part (TxComponent) and, when initializing the form with your control box, you need to set your customized filter to the box validator property.

 

// Create a new filter for compound part
TxTypeFilter pickTypeFilter = new TxTypeFilter(typeof(TxCompoundPart));
// Add a included filter for part pickTypeFilter.AddIncludedType(typeof(TxComponent));
// Create a new validator with specific filter TxTypeFilterValidator typeValidator = new TxTypeFilterValidator(pickTypeFilter); // Set the filter to the object control box yourEditBox.SetValidator(typeValidator);

Regards

Re: Particular type of object pick

Pioneer
Pioneer
Hello,

It looks quite new coding. I am very thankful to you for creating complete coding..i will try it tomorrow. And hopefully it works.

Thank you

Re: Particular type of object pick

Pioneer
Pioneer

Hello @FredCastro

 

Ur given Filter i applied and tried, It works perfectly. But now Txcomponent means there are lot of components in study like, FENCE. I want to pick only component which are present only under "Parts" mainfolder. How can i do it.

 

Thanx

Re: Particular type of object pick

Legend
Legend

Hello @Luisy

 

I actually don't know what is a fence object, but I assume is not under Parts folder. In my scenario this filter is ok, but it looks like TxComponent filter more than parts.

 

If you want only to get parts in your filter, one workaround you can try is to implement ITxProcessModelObject for the picked object (this will check if there are planning representation for the object) and then get the planning representation of the object. 

 

Part objects are TxComponents in engineering representation but they are TxPlanningPart in planning representation. So if you check for the planning representation during the pick event of the TxComponent object, you may achieve your goal.

 

Regards,

 

 

Re: Particular type of object pick

Pioneer
Pioneer

Hello,

 

Yes Fence is not under "Parts" main folder. But i could not understand your answer. I have always problem with planningrepresentation.. Its very kind of you , if u can  a bit code give me. So that i can understand it in better way.

 

Thank you...!!!

 

 

Re: Particular type of object pick

Legend
Legend

@Luisy

 

Another way you can also try is to implement your own class inherited from ITxValidator interface. You'll need to implement four methods (take a look in TX API Manual), and in the validation methods of this class you can test for the planning representation.

 

Sample below is just to give you an idea on how to develop the code. Initial list has all components, but with the check for planning representation you can analyze if it is a part.

 

TxObjectList list = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(new TxTypeFilter(typeof(TxComponent)));
            ITxProcessModelObject obj = list[0] as ITxProcessModelObject;

            bool valid = false;

            if (obj != null)
                if (obj.PlanningRepresentation.GetType() == typeof(TxPlanningPart))
                    valid = true;