Using 'convert to points' from the Points WB in the console

Need help, or want to share a macro? Post here!
User avatar
naxq0
Posts: 23
Joined: Wed Apr 25, 2018 7:45 am

Using 'convert to points' from the Points WB in the console

Postby naxq0 » Wed Apr 25, 2018 8:34 am

Hello everyone,

I was using the "convert to poitnts" GUI button to rasterize the faces of some solids and it was working great. However.... does anyone know how to get that working from the console?


I looked at the source code on GitHub and found the function that the GUI calls

Code: Select all

void CmdPointsConvert::activated(int iMsg)
within: https://github.com/FreeCAD/FreeCAD/blob ... ommand.cpp

But I don't know how to call it's contents from the python console

Any suggestions?

Thanks and have a nice day!
User avatar
naxq0
Posts: 23
Joined: Wed Apr 25, 2018 7:45 am

Re: Using 'convert to points' from the Points WB in the console

Postby naxq0 » Wed Apr 25, 2018 9:43 am

There might also be an alternative way to do it.

I have been looking at creating messes from shapes and tessellating the shape, and getting the points from the mesh. However, these methods seem to only get the points at the edges and leave out the normal cylinders and planes for example
User avatar
microelly2
Posts: 4414
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Using 'convert to points' from the Points WB in the console

Postby microelly2 » Wed Apr 25, 2018 10:55 am

Gui.Selection.addSelection(App.ActiveDocument.ActiveObject)
Gui.runCommand('Points_Convert')

There is still a dialog popup
User avatar
naxq0
Posts: 23
Joined: Wed Apr 25, 2018 7:45 am

Re: Using 'convert to points' from the Points WB in the console

Postby naxq0 » Wed Apr 25, 2018 12:36 pm

Hmm I see.

This works great on the python console in FreeCAD, and from my standalone script I can set it up so that your script works using:

Code: Select all

import FreeCADGui
FreeCADGui.showMainWindow()
import PointsGui
But then it is still necessary to input the interval into the pop-up manually and I would prefer to have it all run automatically, without the GUI. So I'm still looking for a workaround

I was thinking about just generating the points myself from the UV parameters of each face, but I would have to treat all face types differently since a uniform grid in the UV space would not lead to a uniform point distribution in 3D (for instance cones would have a lot more point density close to the apex than on the other side).

Another issue would be keeping the point spacing uniform on the boundaries between faces and from face to face, so I would prefer to reuse that "Points_Convert" code

It's funny that you answered, microelly, I'm a bit fan! I've been learning a lot from your website and your youtube videos :)
User avatar
microelly2
Posts: 4414
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Using 'convert to points' from the Points WB in the console

Postby microelly2 » Wed Apr 25, 2018 12:48 pm

naxq0 wrote:
Wed Apr 25, 2018 12:36 pm

But then it is still necessary to input the interval into the pop-up manually and I would prefer to have it all run automatically, without the GUI. So I'm still looking for a workaround

I was thinking about just generating the points myself from the UV parameters of each face, but I would have to treat all face types differently since a uniform grid in the UV space would not lead to a uniform point distribution in 3D (for instance cones would have a lot more point density close to the apex than on the other side).
The better way will be to start a feature request to have a configurable call without extra dialog.
This is not the big deal and requires less developer time than to write a discretizer which uses uv-grids.
User avatar
naxq0
Posts: 23
Joined: Wed Apr 25, 2018 7:45 am

Re: Using 'convert to points' from the Points WB in the console

Postby naxq0 » Wed Apr 25, 2018 1:08 pm

Ok thanks.

I might try to look into it myself and if I figure it out I'll issue a pull request.

In the meantime, where should I post the feature request? I've seen some people do it in the forum with "Feature request" in the title, but I imagine GitHub might be better
User avatar
microelly2
Posts: 4414
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Using 'convert to points' from the Points WB in the console

Postby microelly2 » Wed Apr 25, 2018 1:56 pm

I make a request in mantis issue #3446
User avatar
naxq0
Posts: 23
Joined: Wed Apr 25, 2018 7:45 am

Re: Using 'convert to points' from the Points WB in the console

Postby naxq0 » Wed Apr 25, 2018 2:34 pm

Ah I see. Ok, perfect thanks again!