Cancel
Showing results for 
Search instead for 
Did you mean: 

Blockstyler Plane Selection and usage in a method

Creator
Creator

Hi guys,

 

Iam currently working on a small method which should do the following:

 

1. The user picks 3 planes in a Blockstyler UI.

2. Those 3 picked planes should be saved and used in a method to create a coordinate system depending on those three planes.

 

So I have a couple of questions:

1. How do I get the selected plane in C#? Following code at least works and I can get a string out of this:

 

TaggedObject[] ebene1 = sym_ebene_x.GetSelectedObjects();

 

So as far as I have understood the .GetSelectedObjects() is a TaggedObject Array, right?

How can I save this to use it in another method?

 

2. I want to use the selected planes in following code:

 

XOpen.DatumPlane datumPlane1 = (NXOpen.DatumPlane)workPart.Datums.FindObject("Plane Test");
NXOpen.DatumPlane datumPlane2 = (NXOpen.DatumPlane)workPart.Datums.FindObject("DATUM_CSYS(0) XY plane");
NXOpen.DatumPlane datumPlane3 = (NXOpen.DatumPlane)workPart.Datums.FindObject("DATUM_CSYS(0) YZ plane");

 

Currently the creation of the coordinate system just uses the Objects which are being found by the given string. I want to use my three selected planes.

 

Could anyone please help me? I would really appreciate it.

 

Greetings

Tim

2 REPLIES

Re: Blockstyler Plane Selection and usage in a method

Genius
Genius

Hi Tim!

 

Okay, so far you created a simple GUI to select three planes, right?

You can try to cast the 'TaggedObject[]'-Array to 'DatumPlanes':

 

TaggedObject[] ebene1 = sym_ebene_x.GetSelectedObjects();
int numberOfSelectedPlanes = ebene1.Length;
List<NXOpen.DatumPlanes> myNewListOfAllPlanes = new List<NXOpen.DatumPlanes>();
if(numberOfSelectedPlanes == 3)
{
try
{
for(int i =0;i<numberOfSelectedPlanes)
{
NXOpen.DatumPlane bufferPlane = (NXOpen.DatumPlane) ebene1[0];
myNewListOfAllPlanes.Add(bufferPlane);
}
} catch
{
// Some error handling here: The user selected some other stuff than DatumPlanes..
}
}

Depending on how and where you instantiate your List, it can be used by other methods.

 

Your second topic should be solved as well by using the generic list, because you can now

get all the DatumPlanes with the following code:

 

NXOpen.DatumPlane datumPlane1 = myNewListOfAllPlanes.ElementAt(0);
NXOpen.DatumPlane datumPlane2 = myNewListOfAllPlanes.ElementAt(1);
NXOpen.DatumPlane datumPlane3 = myNewListOfAllPlanes.ElementAt(2);

 

I hope that helps!

 

 

Bye,

 

flo

 

Re: Blockstyler Plane Selection and usage in a method

Creator
Creator

Thank you very much. Ive fixed the problem with your help!