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

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
naxq0
Posts: 51
Joined: Wed Apr 25, 2018 7:45 am

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

Post by naxq0 »

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: 51
Joined: Wed Apr 25, 2018 7:45 am

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

Post by naxq0 »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

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

Post by microelly2 »

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

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

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

Post by naxq0 »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

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

Post by microelly2 »

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: 51
Joined: Wed Apr 25, 2018 7:45 am

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

Post by naxq0 »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

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

Post by microelly2 »

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

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

Post by naxq0 »

Ah I see. Ok, perfect thanks again!
Nicoloc
Posts: 5
Joined: Tue Apr 12, 2022 2:46 pm

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

Post by Nicoloc »

microelly2 wrote: Wed Apr 25, 2018 1:56 pm I make a request in mantis issue #3446
Hi everybody! This post is now 4 years old, but I think there's not been any development. Any plan to do it in the foreseeable future? Is there a way to contribute? There's also a linked issue on Github https://github.com/FreeCAD/FreeCAD/issu ... 1095181621

Best,

Nicolò
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

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

Post by chrisb »

The author has - at least currently - left the project. It would need someone willing to continue.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply