Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

FaceCollector to Face

Creator
Creator

I use BlockStyler to create dialog for my application. I need to transorm FaceCollector to Face. I use CType method, but it don't work and I take a message "cannot convert type value "NXOpen.BlockStyler.FaceCollector" to "NXOpen.Face"". How I can do this?

30 REPLIES 30

Re: FaceCollector to Face

Gears Phenom Gears Phenom
Gears Phenom

The FaceCollector on the dialog is the block you see when the dialog is shown. It is not a Face itself.

To get the face(s) selected by the user you need to call the getSelectedObjects() method of FaceCollector:

FaceCollector myFaceCollector;
...
...
TaggedObject[] taggedObjects = myFaceCollector.getSelectedObjects();

As you can see this returns an array of TaggedObject. Because this is a FaceCollector you can be sure that these TaggedObjects are Face objects so you can cast them to Face:

for(TaggedObject taggedObject : taggedObjects){
   Face face = (Face)taggedObject;
   // Do whatever you like with the face object
}

Note the above is Java. Not sure what language you are using but you should get the idea...

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Dell 7530 Precision, Win10, 32GB. Developing in: Java | C | KF
Production: [NX12.0.2 MP1]

Re: FaceCollector to Face

Creator
Creator
I use vb.net language, but I understand an idea) Thanks a lot.

Re: FaceCollector to Face

Pioneer
Pioneer
Is there like some setting that should be first set, because, i get an empty list when i do that

Re: FaceCollector to Face

Gears Phenom Gears Phenom
Gears Phenom

You'll only get some objects returned if the user has selected one or more faces.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Dell 7530 Precision, Win10, 32GB. Developing in: Java | C | KF
Production: [NX12.0.2 MP1]

Re: FaceCollector to Face

Pioneer
Pioneer
That what should happen, but as i said i get an empty list, or better saying a vector with the size =0

Re: FaceCollector to Face

Gears Phenom Gears Phenom
Gears Phenom

Can you attach your code?

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Dell 7530 Precision, Win10, 32GB. Developing in: Java | C | KF
Production: [NX12.0.2 MP1]

Re: FaceCollector to Face

Pioneer
Pioneer
in Header Datei : the header datei is auto generated and does have this following attribute :
NXOpen:: BlockStyler:: FaceCollector* face_select0;

In cpp file in the apply function :
std:: vector < NXOpen:: TaggedObject * > selectedObj = face_select0->GetSelectedObjects();

Re: FaceCollector to Face

Pioneer
Pioneer
An actually calling this function results in a run time exception

Re: FaceCollector to Face

Gears Phenom Gears Phenom
Gears Phenom

Sorry, I don't have any experience with C++, so I can't easily get a working example with that.

However, attached is a C# journal and DLX file that exemplifies the use of the Face Collector.

If you unzip the contents you will get FaceCollector.cs and FaceCollector.dlx.

Edit FaceCollector.cs to hard code the path of the DLX file (for testing easier than trying to install the DLX in your environment). Look at line 87 and change the path to where you unzipped the files to.

When you execute the journal, select some faces and then press Apply or OK and you will get a message box saying how many faces were selected.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Dell 7530 Precision, Win10, 32GB. Developing in: Java | C | KF
Production: [NX12.0.2 MP1]