interactive selection of STL model triangles and edit ASCII STL file

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
sps
Posts: 22
Joined: Thu Aug 31, 2017 2:15 pm

Re: interactive selection of STL model triangles and edit ASCII STL file

Post by sps »

wmayer wrote: Fri Sep 15, 2017 12:43 pm look here: https://github.com/FreeCAD/FreeCAD/blob ... n.cpp#L392
But this is C++ code...I'll see later. So where is that function in the GUI? :? :|
Last edited by sps on Tue Sep 19, 2017 8:29 am, edited 1 time in total.
wmayer
Founder
Posts: 20301
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: interactive selection of STL model triangles and edit ASCII STL file

Post by wmayer »

sps wrote: Fri Sep 15, 2017 12:58 pm
wmayer wrote: Fri Sep 15, 2017 12:43 pm look here: https://github.com/FreeCAD/FreeCAD/blob ... n.cpp#L392
But this is C++ code...I'll see later. So where is that function the GUI? :? :|
It's also possible in Python but then you have to do the highlighting of the selection all on your own. You will find the function in the Mesh menu under Remove components. This is a dialog where you can select a range using a lasso, individual triangles or components a triangle is part of.
https://github.com/FreeCAD/FreeCAD/blob ... s.cpp#L140

I think it would be best if we implemented a Python binding for the MeshSelection class.
sps
Posts: 22
Joined: Thu Aug 31, 2017 2:15 pm

Re: interactive selection of STL model triangles and edit ASCII STL file

Post by sps »

wmayer wrote: Fri Sep 15, 2017 1:32 pm You will find the function in the Mesh menu under Remove components. This is a dialog where you can select a range using a lasso, individual triangles or components a triangle is part of.
Again, I've already seen that, and I tried to get the python code, but it seems not to work as I reported here
sps
Posts: 22
Joined: Thu Aug 31, 2017 2:15 pm

Re: interactive selection of STL model triangles and edit ASCII STL file

Post by sps »

Let's take stock of the situation.

For now I'm trying to get my goal with a python script (because of some troubles with C++ IDE environment).
I'm looking for some functions to let me select triangles by mouse click and get their specific data, that is their three points and their normals.
To do that I'm trying to understand how 'Cut mesh' function works, but I can't get its python code, as I asked here
Up to now nothing help I've got on that.

I don't know what else method I can use to get the three points and the normal definition of each selected triangle.
sps
Posts: 22
Joined: Thu Aug 31, 2017 2:15 pm

Re: interactive selection of STL model triangles and edit ASCII STL file

Post by sps »

wmayer wrote: Fri Sep 15, 2017 1:32 pm I think it would be best if we implemented a Python binding for the MeshSelection class.
How could I start?

:geek: Waiting for more detailed instructions :geek: (in the while I solve my C++ IDE issue)
wmayer
Founder
Posts: 20301
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: interactive selection of STL model triangles and edit ASCII STL file

Post by wmayer »

In the script I posted here https://forum.freecadweb.org/viewtopic. ... 48#p189711 you get at some point a face_detail object. See also: https://grey.colorado.edu/coin3d/classSoFaceDetail.html

This gives you access to a SoPointDetail that gives you the index of the corner point in the point array. and the normal can already be accessed with the SoPickedPoint as you can see here: https://grey.colorado.edu/coin3d/classS ... Point.html
Post Reply