Cancel
Showing results for 
Search instead for 
Did you mean: 

How to select only "Part List" in c#.

Experimenter
Experimenter

I want to select only part list and not other component in drafting mode or in modeling.

But my assemebly is able to select all i.e. it select component as well as part list. But i want to validate only for "Part List" selection in drafting mode.

 

Main File ....

theProgram = new Program();

//TODO: Add your application code here

Part selectedPart = null; utils.selectComponentWithPart(theUI, "Select Part List", ref selectedPart); if (selectedPart == null) { return retValue; }

// Function public Selection.Response selectComponentWithPart(UI theUI, string prompt, ref Part obj) { //NXObject selobj; TaggedObject selobj; UI ui = theUI; Selection.MaskTriple[] mask = new Selection.MaskTriple[1]; { mask[0].Type = UFConstants.UF_component_type; mask[0].Subtype = UFConstants.UF_component_subtype; //mask[0].SolidBodySubtype = UFConstants..UF_UI_SEL_FEATURE_BODY; } Point3d cursor = default(Point3d); Selection.Response resp = ui.SelectionManager.SelectTaggedObject(prompt, prompt, Selection.SelectionScope.AnyInAssembly, Selection.SelectionAction.EnableSpecific, false, false, mask, out selobj, out cursor); if (resp == Selection.Response.ObjectSelected | resp == Selection.Response.ObjectSelectedByName) { obj = (Part)((NXObject)NXOpen.Utilities.NXObjectManager.Get(selobj.Tag)).OwningPart; return Selection.Response.Ok; } else { return Selection.Response.Cancel; } }
2 REPLIES

Re: How to select only "Part List" in c#.

Honored Contributor
Honored Contributor

Re: How to select only "Part List" in c#.

Experimenter
Experimenter

Thanks Cowski1

 

This is really helpfull.

 

I also did like this... Thanks.

theProgram = new Program();

//TODO: Add your application code here            
            
Part selectedPart = null;
Type varTypeOfObject = null;
TaggedObject selobj = null;

utils.selectComponentWithPart(theUI, "Select Part List", ref selectedPart, ref varTypeOfObject, ref selobj);

NXOpen.Tag tempTag = Tag.Null;  

// This tempTag is a selected partlist id.

theUfSession.Obj.CycleObjsInPart(selectedPart.Tag, UFConstants.UF_tabular_note_type, ref tempTag);            

Int32 type;
Int32 subtype;

theUfSession.Obj.AskTypeAndSubtype(tempTag, out type, out subtype);

if (subtype == UFConstants.UF_parts_list_subtype)
{
                  theUfSession.Plist.Update(tempTag);
                  theUfSession.Plist.AskObjects(tempTag, out objectnum, out objects);
}

 

public Selection.Response selectComponentWithPart(UI theUI, string prompt, ref Part obj, ref Type varTypeOfObject, ref TaggedObject selobj)
        {
            UI ui = theUI;
            Selection.MaskTriple[] mask = new Selection.MaskTriple[1];
            {
                mask[0].Type = UFConstants.UF_component_type;
                mask[0].Subtype = UFConstants.UF_component_subtype;               
            }
            Point3d cursor = default(Point3d);

            Selection.Response resp = ui.SelectionManager.SelectTaggedObject(prompt, prompt, Selection.SelectionScope.AnyInAssembly,
            Selection.SelectionAction.EnableSpecific, false, false, mask, out selobj, out cursor);
            
            if (resp == Selection.Response.ObjectSelected | resp == Selection.Response.ObjectSelectedByName)
            {
                varTypeOfObject = selobj.GetType();
                
                obj = (Part)((NXObject)NXOpen.Utilities.NXObjectManager.Get(selobj.Tag)).OwningPart;
                return Selection.Response.Ok;
            }
            else
            {
                return Selection.Response.Cancel;
            }
        }