[Addon] Mesh Fairing

I lost this cool thing. I will try.

The good stuff. Thanks

I just downloaded the latest 2.81 alpha build from https://builder.blender.org/download/.

Mesh fairing works without issue and shows up within the Ctrl+V menu.

Thanks for checking it, appreciated.

I’ve got frequent crashes on Windows when using Mesh Fairing on meshes with a mask in Sculpt Mode.

The add-on is visible in the Control + V menu, but when you call it from there, the options are invisible, unless you call it from the Vertex drop-down menu in the 3D view.

I fixed the Ctrl+V menu issue and committed changes to GitHub.

As for the crashing in Sculpt mode, I’m not sure what the exact issue is yet. Commenting out the following line in the addon’s operators.py file seems to avoid crashes at the expense of making the operator non-undoable :frowning: :

# Apply a stroke that has no effect other than pushing an undo step.
stroke = [{
    "name": "Null Stroke",
    "location": (0, 0, 0),
    "mouse" : (0, 0),
    "pressure": 0,
    "size": 0,
    "pen_flip" : False,
    "time": 0,
    "is_start": True
}]
#bpy.ops.sculpt.brush_stroke(stroke = stroke)  <-- Comment out this line.
1 Like

Hi @Umdee, I just wanted to let you know that I really love Mesh Fairing and use it more and more, both in Edit Mode and Sculpt Mode. Thanks for sharing this useful addon, and keep up the good work. :+1:

Thanks for the kind words!

I found some time to further investigate the intermittent crashes in Sculpt mode and pushed a couple commits. All is working for me in both Windows and Linux now. Please, let me know if you’re still having issues on your end.

1 Like

Thanks!

I haven’t encountered crashes in Sculpt Mode recently (installed the update right away), and frequently try all three methods (Position, Tangency and Curvature), so it’s looking good, but if I do experience a crash I will let you know.

I’m having a problem with the addon disappearing from the interface after I close and reopen Blender.
I installed SciPy using the instructions from @ultson (first installing anaconda, then putting the scipy folder and scipy-1.4.1 folder into C:\Program Files\Blender\2.80\python\lib\site-packages), and it works fine the first time I install it.

But when I close blender and reopen, the option “Fair Vertices” has disappeared from the interface.
When I go to the Preferences window, I can see that the addon is still installed and active with no errors. But then when I try to deactivate the addon and reactivate it (to see if the Fair Vertices option reappears) I receive this error:

It can only be solved by removing the addon. Then removing the SciPy folders, then closing Blender completely, then reinstalling and activating the addon. After which it works properly, even if you install SciPy, for only once before you close blender and reopen again, at which point it has disappeared again.

OBS: Anaconda provided the folders “scipy” and “scipy-1.4.1.dist-info”, both of which I put in the site-packages folder.
I already had “numpy” and “numpy-1.17.0-py3.7.egg-info” in my folder, but anaconda provided another “numpy” with some different archives and “numpy-1.18.1-py3.7.egg-info”.
I was not sure If I should update (replace) the “numpy” folder that was already there, and if I can keep both numpy 1.17 and 1.18 or if I should remove the older version if I updated it.

Can any of this be the cause of the problem?

Edit: I did a test, and If I install the addon, but don’t put the SciPy folders in the site-packages folder, the addon still remains active and visible for me to use it. So it only happens when SciPy has been put in the blender folder (at which point the addon recognizes that it is installed)

I got a note by e-Mail referring to your problem, because my nickname appears in your posting.

Though I’ve not much hope to be of some help, I see on a first glance a discrepancy between your Blender-2.80-Python and the traceback error originating from your script folder for Blender 2.82.

Did you look into that problem?

Have you set your Blender 2.82 to get the scipt files from 2.80 or vice versa?

@Evandro_Costa

When trying to reproduce the error, I got the same traceback about the not defined name linalg.

Mesh Fairing has a module (a py-file in the addon folder) linalg.py, that has to be imported into the file init.py.

Open the init.py file (the init surrounded by 4 underscores) with a text editor.

After line 35 insert a new line:

from . import linalg

so that it looks like

if 'bpy' not in locals():
    import bpy
    from . import operators
    from . import preferences
    from . import ui
    from . import linalg

Save the init.py file and restart Blender.

Give us a word, if it works for you too.

1 Like

Thanks for the help, unfortunally adding “from . import linalg” didn’t solve the issue, instead it gave even more error messages when trying to activate the addon, starting with something like “failed to load DLL module” and “failed to import _iterative” or something like that, then a bunch of other errors.

So I read that someone was having problems with scipy from Anaconda, but they got it working installing it directly through the command prompt, so I decided to try that. IT WORKED!

Instructions:
I removed both numpy and scipy folders from blender site-packages folders.
I then opened windows command prompt (cmd) as adm (not sure if necessary), then checked to see if I needed to install pip (probably not because I have python 3.7 installed) So I got the following message:

So I decided to update pip with the following command:

py -m pip install --upgrade pip

(using “python” instead of “py” did nothing, so I followed the suggestion of “py” instead of “python” and it worked)


After upgrading pip, I installed scipy which also installed numpy I believe, using the following command:

py -m pip install scipy

I’m not sure If I should do something about that Warning message, but I ignored it for now.

Then I found the numpy and scipy folders inside

“C:\Users\myuser\AppData\Roaming\Python\Python37\site-packages”

and copied them to

C:\Program Files\Blender Foundation\Blender 2.82\2.82\python\lib\site-packages

Then I managed to activate the addon inside Blender Preferences without it giving any error messages, and it still appears active and working (the button “Fair Vertices” is still there after I close Blender and reopen).
So these are the steps if anyone is having problems on windows.

You are right, Arkhangel, the solution in my post doesn’t work.

I’ve further experimented with my installation of Anaconda/Mesh Fairing.

The result is:
If scipy is copied from Anaconda to Blender Python, but Anaconda is not installed, you get the long Traceback error referring to missing dlls, if trying to activate Mesh Fairing.
Trying a second time to activate Mesh Fairing without restarting Blender, throws a Traceback error about the unknown module “linalg”, leading to my delusion. In reality I had in between, while looking for a solution, Anaconda reinstalled.
And that was the real solution.

It’s not necessary to uninstall Mesh Fairing.

The trick with Anaconda works, but it has conditions.

Anaconda must be in the PATH. If you are tough, you can do it manually.

For a beginning from scratch it requires:

1st - The import of the module linalg as I said in my post above indeed is irrelevant.

2nd - Anaconda 3 (in my case Anaconda3-2020.02-Windows-x86_64 including scipy 1.4.1, but an older Version with scipy 1.3.2 works too) is to be installed.

Link: https://repo.anaconda.com/archive/Anaconda3-2020.02-Windows-x86_64.exe

It does not work, only to copy scipy, and then uninstall Anaconda. Anaconda must be installed and in the PATH (see next point).

3rd - Whilst the installation of Anaconda is running in its first phase, it prompts a dialog where checkboxes are to check(!).
The upper one “Add Anaconda3 to my PATH environment variable” MUST be activated.

Don’t bother about the then appearing big red warning.

The lower one, I believe to remember, already is activated - leave like that.

After Anaconda is installed:

open c:\Users\yourUsername\anaconda3\Lib\site-packages\

copy the 2 folders scipy and scipy-1.4.1.dist-info
to c:\Program Files\Blender-2.82\2.82\python\lib\site-packages\
or to the respective folder in the directory where your Blender program is installed.

4th - Run Blender

5th - Activate Mesh Fairy and it should run

Sculpt Mode > Sculpt Menu > Fair Vertices should be active by now,
Edit Mode > Vertex Menu > Fair Vertices should become active after selecting a Vertex in the active object

Have fun!

I’ve forgotten to mention:
This is also a solution for computers not connected to the internet.

1 Like

You are correct, I mentioned that I followed your steps, but forgot to explicitly mention in my original post that I indeed had uninstalled Anaconda after copying the scipy folders to the blender folder.

In the end it was for the best that I had those errors which forced me to look for the other (harder but cleaner) solution with the command prompt, which only added some 42mb of files to my system, instead of the ~400mb of Anaconda, which I won’t use.

Thanks for the feedback!
Regards

Edit: When you said “This is also a solution for computers not connected to the internet.” do you mean that my installation using pip won’t work offline?

Yes, your method to install scipy in Blender works only when being online.

And yes, anaconda is a big ship. When installed, it weighs nearly 6GB.

That had me thinking about another solution.
After reading some time at stackoverflow’s I made some trials and many errors and came up with a method wich works for me, and that is nearly similar to yours.

But since today I’m short of time, I will come back to it tomorrow.

1 Like

Hello Evandro,

I know, you already have your Mesh Fairing up and running with both NumPy and SciPy, but for all users, who are interested in how to install SciPy offline, without having to sacrifice so much space like 6 GB Anaconda3 is sitting on, I’ll tell how I did it on my computer.

For all readers:
I’m not familiar with the terminology of the Python language, thus ensure yourself about it on the internet.

As Blender now is shipping with NumPy already included, there ist no need to install it anew.
This post only is about SciPy.

The short version about the installion:

DOWNLOAD Python3.7 and
SciPy as a wheel-package

INSTALL Python3.7 with the PATH environment variable enabled

START a Windows PowerShell or a command line

CD to your Python3.7 installation and there to the Scripts folder
e.g.
cd C:\Users\yourUsername\AppData\Local\Programs\Python\Python37\Scripts>

WRITE the command: easy_install-3.7 your-path\your-downloaded.whl
e.g.
PS C:\Users\yourUsername\AppData\Local\Programs\Python\Python37\Scripts> easy_install-3.7 w:\downloads\scipy-1.4.1-cp37-cp37m-win_amd64.whl

OPEN c:\Users\yourUsername\AppData\Local\Programs\Python\Python37\Lib\site-packages\

COPY the folder scipy-1.4.1-py3.7-win-amd64.egg to your Blender installation
e. g.
c:\Program Files\Blender-2.82\2.82\python\lib\site-packages\

OPEN the folder scipy-1.4.1-py3.7-win-amd64.egg

MOVE the folder scipy to the folder site-packages

And here comes the much more detailed version:

Blender-2.82-Python is founded upon Python version 3.7, so it makes sense to download and install this version for your computer. It includes “PIP”, a tool, which helps you to install additional Python packages like SciPy later on.

You get Python3.7 at
https://www.python.org/ftp/python/3.7.7/python-3.7.7-amd64.exe

Then you have to download SciPy as a “wheel”-package. This would be a file with the extension *.whl.
For Windows 10 x64 the package is

scipy-1.4.1-cp37-cp37m-win_amd64.whl

You get it at

https://github.com/scipy/scipy/releases/download/v1.4.1/scipy-1.4.1-cp37-cp37m-win_amd64.whl

Now to the installation of Python3.7:

I had both installation files downloaded onto my internet computer and transferred them via USB-Stick to my offline main computer.

When attempting to start the installation directly from the USB-Stick, Python complained about something missing and would not resume the installation process. So I had to copy the installation file to a local drive and start anew. Then it worked without error.

When starting the installation, the first prompted dialog offers to install Python to the default directory or to customize the installation and (important) a checkbox to add Pyton3.7 to the PATH (an environment variable).
CHECK THIS BOX!!!

If the option “Install launcher for all users (recommended)” is active, consider, that, if you check this box and later on want to add packages like SciPy, you have to do it with administrator rights.

Even if you accept the default path, chose “Customize installation”.

The next dialog is “Optional Features”.
Here you can uncheck all boxes to save space on the drive, with the exception of “pip”, which is mandatory. So, the box “pip” must be checked.

Next is “Advanced Options”
Checking the box “Install for all users” means working as administrator later on.

I recommend checking the boxes “Associate files…” and “Create shortcuts…”.
But in any case you MUST check the box “Add Python to environment variables”.
The default install location I left as it was recommended.

Now let the installation run by pressing “Install”.

After the installation of Python, SciPy stands next in line.

My download of Scipy (name = scipy-1.4.1-cp37-cp37m-win_amd64.whl) is saved in the folder “downloads” on my USB-Stick, which on my Windows 10 is mounted as Drive W:, so the path to the file is:

w:\downloads\scipy-1.4.1-cp37-cp37m-win_amd64.whl

Now open a Command line or Windows PowerShell (Right Click on the Start Icon) and cd to the Scripts folder in Pyton3.7

This looks like (PS means PowerShell):

PS C:\Users\yourUsername> cd c:\Users\yourUsername\AppData\Local\Programs\Python\Python37\Scripts\

In this folder 5 *.exe files are lying around - take the “easy_install-3.7.exe” for your installation command - I think, easy_install.exe would work too, but don’t experiment at this point.

This looks like:

PS C:\Users\yourUsername\AppData\Local\Programs\Python\Python37\Scripts> easy_install-3.7 w:\downloads\scipy-1.4.1-cp37-cp37m-win_amd64.whl

This is what Python/pip is throwing up:

Windows PowerShell
Copyright © Microsoft Corporation. All rights reserved.

#1st attempt - failure
PS C:\Users\yourUsername> pip install w:\downloads\scipy-1.4.1-cp37-cp37m-win_amd64.whl
scipy-1.4.1-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.

#2nd attempt - failure
PS C:\Users\yourUsername> cd c:\Users\xxx\AppData\Local\Programs\Python\Python37
PS C:\Users\yourUsername\AppData\Local\Programs\Python\Python37> pip install w:\downloads\scipy-1.4.1-cp37-cp37m-win_amd64.whl
scipy-1.4.1-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.

3rd attempt - failure
PS C:\Users\xxx\AppData\Local\Programs\Python\Python37> cd c:\Users\xxx\AppData\Local\Programs\Python\Python37\Scripts
PS C:\Users\xxx\AppData\Local\Programs\Python\Python37\Scripts> pip install w:\downloads\scipy-1.4.1-cp37-cp37m-win_amd64.whl
scipy-1.4.1-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.

#Up to here it is trial and error, then I got my epiphany:

PS C:\Users\yourUsername\AppData\Local\Programs\Python\Python37\Scripts> easy_install-3.7 w:\downloads\scipy-1.4.1-cp37-cp37m-win_amd64.whl
Processing scipy-1.4.1-cp37-cp37m-win_amd64.whl
Installing scipy-1.4.1-cp37-cp37m-win_amd64.whl to c:\users\xxx\appdata\local\programs\python\python37\lib\site-packages
writing requirements to c:\users\xxx\appdata\local\programs\python\python37\lib\site-packages\scipy-1.4.1-py3.7-win-amd64.egg\EGG-INFO\requires.txt
Adding scipy 1.4.1 to easy-install.pth file

Installed c:\users\xxx\appdata\local\programs\python\python37\lib\site-packages\scipy-1.4.1-py3.7-win-amd64.egg

#Then Python/pip tries to go online to look for NumPy and fails, because the computer is offline.

Processing dependencies for scipy==1.4.1
Searching for numpy>=1.13.3
Reading https://pypi.org/simple/numpy/
Download error on https://pypi.org/simple/numpy/: timed out – Some packages may not be found!
Couldn’t find index page for ‘numpy’ (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
Download error on https://pypi.org/simple/: timed out – Some packages may not be found!
No local packages or working download links found for numpy>=1.13.3
error: Could not find suitable distribution for Requirement.parse(‘numpy>=1.13.3’)
PS C:\Users\xxx\AppData\Local\Programs\Python\Python37\Scripts>

After closing Windows PowerShell I went to c:\Users\yourUsername\AppData\Local\Programs\Python\Python37\Lib\site-packages
and found the installation of scipy in a folder named “scipy-1.4.1-py3.7-win-amd64.egg”.

This folder I copied to my Blender-2.82 installation into the folder
c:\Program Files\Blender-2.82\2.82\python\lib\site-packages\

But the folder “scipy” is hidden within the folder “scipy-1.4.1-py3.7-win-amd64.egg” where “Mesh Fairing” can’t find it.

That leaves as a last step: Moving the folder “scipy” from the folder “scipy-1.4.1-py3.7-win-amd64.egg” into the folder “site-packages” and that’s all.

Now start Blender, look in the preferences of Mesh Fairing, and there you see, that NumPy and SciPy are already installed.

I tested here with installation with my computer offline and it worked fine. No anaconda installed.

OBS: I do have python 3.7 installed, which is what allowed me to install scipy though pip, as I mentioned above. As I showed, it also installed an updated version of numpy, which I also put in the Blender site-packages folder just to be safe.
I think if you have python 3.7, numpy and scipy, it will work offline no problem (as it’s working here), and the process I showed above using pip is pretty simple.
Two commands (one if your pip is up-to-date) and one copy-paste and you are done.

But it’s interesting that you found another way of installing it… I had no idea PowerShell existed (I’m not a programmer) and have no idea why use it instead of regular cmd.

I’ve always gone about installing SciPy from the Mesh Fairing addon’s panel in the preferences window, as described in the installation instructions. It works for me on Windows 10 and Linux.

Maybe try that approach with a fresh Blender install.

1 Like

I only installed using the convoluted steps above because in my case the button in the Preferences windows always failed and couldn’t install scipy. I’m also on windows 10 (but didn’t try in a fresh install of Blender), anyways now it’s working and the steps are there if someone else have the same problem :slight_smile:

We do it for fun, right?

Yes, both your methods work fine, Umdee and Evandro, but only if you are online.

But my step by step posting above was about installing SciPy OFFLINE.

And no, Evandro, your method doesn’t work offline, at least if I use it.
Above, in your second post, showing the copies of your command prompt (cmd.exe), after your command
py -m pip install --upgrade pip
your python3.7 was going online and connected with the server “https://files.pythonhosted.org” and downloaded from this server the upgrade package for pip.

Logically Python must looking online wether there is an upgrade available.

After your command
“py-m pip install scipy”
it collected likewise online the packages for NumPy.
You see the line in your Command Prompt “Downloading numpy-1.18.2-cp37-cp37m-win_amd64.whl”?
SciPy was cached, whatever that may means. Perhaps your installed distribution of Python3.7 had it onboard, but not installed.
But while installing SciPy and NumPy you undoubtedly were online.

When I offline tried the command “py -m pip install scipy”
I got the answer “collecting scipy…” etc., like in your Command Prompt and three more lines which were repeated endlessly, because pip tried to connect with the internet server so that I had to kill the program.

Switch off your router, uninstall Python3.7 (I did, for researches sake) and then without Lan and without WLan try again to install first Python, then SciPy, and then you will see, that the command “py -m pip install” does not work.

I’m using for command lines the windows PowerShell because in the far past in the line of configuring my computer, Windows had me persuaded to change the Command Prompt against the PowerShell, and now the Command Prompt has disappeared from the Start Menu, but I will look for it, to get it back.

1 Like