2
$\begingroup$

I'm totally new to blender - mostly work in Rhino, but am wanting to use it to render models that I build in rhino so am trying to install the "import 3dm" addon.

I had blender 2.80 installed. Tried installing the addon from the .zip file on my desktop (import_3dm-master) it shows a message in blue in the bottom right of the screen stating that it has installed that addon but it doesn't show in the addon menu under any of the categories.

I tried extracting the file and copying it directly into the addon folder. Still nothing. Tried installing the import_3dm-v0.0.2 version. This shows up in the menu but has an error (shown in screenshot below). I even installed blender 2.82a in the hopes that this would somehow solve the problem but no luck... Here is the error message I get:

enter image description here

Q: How to install this add-on properly?

$\endgroup$
  • 1
    $\begingroup$ Hi. Can you provide a link to the add-on? Would save some time searching for the right one... $\endgroup$ – brockmann Apr 30 at 10:29
  • 1
    $\begingroup$ Thanks, i edited it into the original post $\endgroup$ – ToniHughes Apr 30 at 12:35
  • $\begingroup$ You haven't installed the rhino3dm package. You really should not follow the instructions provided on the GitHub page though, because that's not how packages should be installed. $\endgroup$ – Robert Gützkow Apr 30 at 13:08
3
$\begingroup$

The 3dm importer depends on the rhino3dm package that has to be installed as well. In order to get the add-on working:

  1. Install rhino3dm.
  2. Install the 3dm importer add-on.

The first step can be accomplished by running the following script. Open Blender, switch to the Scripting workspace, copy and paste the script into the text editor and execute it. Make sure to check the output on the console for any error messages (Window > Toggle System Console). If everything works properly it should print the version of the installed package.

In case your Blender installation is located in C:\Program Files\ you will have to start Blender as administrator. Otherwise, it doesn't have the permission to install the package.

import bpy
import os
import ensurepip
import subprocess


try:
    import rhino3dm
except ImportError:
    # The import failed, therefore we check ensure that pip is available and attempt to install the package.
        
    # ensurepip.bootstrap() also calls pip, which adds the environment variable PIP_REQ_TRACKER. After 
    # ensurepip.bootstrap() finishes execution, the directory doesn't exist anymore. However, when subprocess 
    # is used to call pip, in order to install a package, the environment variables still contain 
    # PIP_REQ_TRACKER with the now nonexistent path. This is a problem since pip checks if PIP_REQ_TRACKER is 
    # set and if it is, attempts to use it as temp directory. This would result in an error because the 
    # directory couldn't be found. Therefore, PIP_REQ_TRACKER needs to be removed from os.environ.
    ensurepip.bootstrap()
    os.environ.pop("PIP_REQ_TRACKER", None)
        
    # Try to install the package. This may fail with subprocess.CalledProcessError
    subprocess.run([bpy.app.binary_path_python, "-m", "pip", "install", "rhino3dm"], check=True)
    
    import rhino3dm
    
    
print(rhino3dm.__version__)

Next download and install the most recent release of add-on. With the required dependency installed it should activate without any issues.

Important: In case you intend to use the code above in an add-on, it's common courtesy to not connect to the internet or install packages without the explicit consent of the user.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you - that was ultimately helpful but somewhat confusing. I think either because i have version 2.82 installed or because i have Anaconda installed, it kept coming up with an error related to the pip - i eventually figured out to remove the lines of code relating to it ("import ensurepip" and " ensurepip.bootstrap()) and it seemed to work albeit only after figuring out that i then needed to run Blender as an administrator... Only read your edit after figuring that part out as well... Anyways, thank you very much for the help! $\endgroup$ – ToniHughes Apr 30 at 15:29
  • $\begingroup$ @ToniHughes You're welcome. If this answer solved your problem, consider marking it as accepted by clicking on the checkmark next to it. $\endgroup$ – Robert Gützkow Apr 30 at 15:32
  • $\begingroup$ Tested on osx and it's working fine too (when running Blender as super user however). $\endgroup$ – brockmann May 11 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.