1
$\begingroup$

I am running Blender 2.76b on a 64bit Windows 10 machine, with Python 3.4.2 installed (Blender also is running the same version of Python). I recently downloaded a python package called triangle (which is used to generate a triangular mesh for given a set of points). This function required me to download Visual C++ 2010 for windows which I did and was working fine outside Blender. But when I included that in a Python code which I am running as a Blender script, Blender is crashing. I tried troubleshooting this, it basically is crashing when it is calling a function called core.triang() in the triangle package, and this I'm guessing is inside core.pyd which I can't access. Can someone help with solving this problem? Thanks!

Edit 1: Here is a representative code:

import triangle
import triangle.plot
from numpy import *

A = {}

A['vertices'] = array(((0,0), (1,0), (1, 1), (0, 1)))

B = triangle.triangulate(A, 'qa0.5')
$\endgroup$
  • $\begingroup$ If you can provide a representative sample of the code, that might help. Also, what does "crashing" mean? Is your script producing an error? Is python throwing an exception? Is Blender hard-crashing? What errors are produced? Help us help you ;-) $\endgroup$ – Matt May 26 '16 at 14:26
  • 1
    $\begingroup$ By crashing I meant hard crashing. Blender closes without throwing any warnings or errors. $\endgroup$ – Sum-Al May 26 '16 at 14:34
  • 1
    $\begingroup$ Wouldn't recommend using from numpy import * . $\endgroup$ – batFINGER Jan 6 '18 at 13:27
1
$\begingroup$

I think you're calling triangulate() incorrectly.

From the Manual:

triangle.triangulate(tri, opts='') Perform triangulation on the input data 'tri'. 'tri' must be a dictionary that contains the following keys:

  • vertices - 2-D array that stores the xy position of each vertex

  • segments - optional 2-D array that stores segments. Segments are edges whose presence in the triangulation is enforced (although each segment may be subdivided into smaller edges). Each segment is specified by listing the indices of its two endpoints.

  • holes - optional 2-D array that stores holes. Holes are specified by identifying a point inside each hole. After the triangulation is formed, Triangle creates holes by eating triangles, spreading out from each hole point until its progress is blocked by PSLG segments; you must be careful to enclose each hole in segments, or your whole triangulation might be eaten away. If the two triangles abutting a segment are eaten, the segment itself is also eaten. Do not place a hole directly on a segment; if you do, Triangle will choose one side of the segment arbitrarily.

  • regions - optional 2-D array that stores region attributes and areas.

It looks like triangulate cannot take a simple array, it has to be a dictionary.

Take this example from the Manual:

A = dict(vertices=array(((0,0), (1,0), (1, 1), (0, 1))))
B = triangle.triangulate(A)
triangle.plot.compare(plt, A, B)
plt.show()
$\endgroup$
  • $\begingroup$ Tried with this example as well. It is still crashing Blender. The same code worked in normal python 3.4.2 outside Blender. It also worked within Blender in OS X. It is giving a problem on Windows. Do you think it might be something to do with Visual C++ or .pyd file? $\endgroup$ – Sum-Al May 26 '16 at 15:59
  • 1
    $\begingroup$ It's possible. Run Blender from a command-line, and you'll be able to see Blender's output after it crashes. That might give you more information. $\endgroup$ – Matt May 26 '16 at 16:10
  • 1
    $\begingroup$ Error: EXCEPTION_ACCESS_VIOLATION $\endgroup$ – Sum-Al May 26 '16 at 16:25
  • $\begingroup$ Interesting.... $\endgroup$ – Matt May 26 '16 at 16:29
0
$\begingroup$

Blender uses a custom-compiled Python. As a result, precompiled Python modules that target the default build of Python may be incompatible.

$\endgroup$

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.