Select face and add sketch

Hi together,

i created a UI Block Designer where i can select a face the ID will be face_select0.

I try to find the face with:

NXOpen.Face face1 = (NXOpen.Face)workPart.FindObject("face_select0");

But this does not work. I get the error " No obect with this name found in NXOpen.NXObject.FindObject(String journalIdentifier)

Where is my problem?

Afterwards i want to add a sketch on this selected face. Maybe anybody can tell me what should be the first step!

Best regards!

The selection function should return a face object or the tag of the face object. If it returns the tag, you can get the object using the NXObject manager.

Dim theFace as Face
theFace = Utilities.NXObjectManager.Get(theFaceTag)

Thanks for your response.

Is there no possibility to get the object by searching the BlockID. I am not quite sure if there is an Tag created or where i can find this.

Just a quick update from my side.

Following code works quide well for me to select a face by TAG.

I know there are many things in the code that are not needed, but i really like WriteLines :D


UFSession ufs = UFSession.GetUFSession();
NXObject selobj;
int type;
int subtype;
ListingWindow lw = theSession.ListingWindow;
UI theUI = UI.GetUI();
int numsel = theUI.SelectionManager.GetNumSelectedObjects();
theUI.SelectionManager.GetType();
theUI.SelectionManager.GetSelectedObject(0);

lw.Open();
lw.WriteLine("Selected objects: " + numsel.ToString() + theUI.SelectionManager.GetSelectedTaggedObject(0));

selobj = (NXObject)theUI.SelectionManager.GetSelectedTaggedObject(0);
ufs.Obj.AskTypeAndSubtype(selobj.Tag, out type, out subtype);
lw.WriteLine("Object: " + selobj.ToString());
lw.WriteLine(" Tag: " + selobj.Tag.ToString());
lw.WriteLine(" Type: " + type.ToString());
lw.WriteLine(" Subtype: " + subtype.ToString());
lw.WriteLine("");

Face face1 = (Face)NXObjectManager.Get(selobj.Tag);

Next step will be adding a sketch on the selected face.
Hopefully this woll be easier for me..