Python script to uncurl or unfold geometry along a curve - python

I have been all over the internet trying to find the answer to this one and I've reached the end of my patience. What I am trying to achieve is pretty much what the standard bend deformer does but the only difference is I want it to unfold along a pre-defined curve. There are literally hundreds of tutorials about the bend deformer all doing the same thing, unfolding along a flat plane but none on how to do it along a curved surface. I have also tried paint effects with control curves to no avail and baking the bend deformer into the geometry then curving it afterwards. This last option didn't work as I no longer had the control I required. It seems from my search that probably the only way to do this would be through a Mel or Python script and I was wondering would anyone be able to help?

something like this?
Constrain -> Motion Patch -> Attach to Motion Patch + Flow Path Object

Lattice deformers themselves are skinnable, so you can run a skeleton or bend deformer through a lattice to maniuplate it's shape. This will also let you control the twist along the deformation. Animate the object you want to deform into the area of influence of the lattice to create the follow effect, while animating the deformation of the lattice itself at the same time to create the follow effect.
Or, you can just make the lattice follow the path using a spline IK control.

Related

What is a method to create an jigsaw puzzled sphere in Blender?

I'm just a newbie in Blender.
Going to create an jigsaw puzzled sphere model, like wikipedia one, or these plastic 3D puzzles you have probably saw.
For now, i have created Python script which creates arbitrary plain 2D puzzles with Bezier curves, which later can be easy be converted to a mesh
But how to wrap it around a sphere ?
PS. Just had an idea -
to unwrap cube on the puzzle plane, copy edges as negative as shown below
(there no copy of edges on the picture yet).
Then with affine transformations, transform each 2D cube face to respective 3D place, and then apply Object->Transform->To Sphere modifier.
What do you think ? Is there a better way to create puzzled sphere ?
Thanks for your attention !
EDIT: You know, there is a dodecahedron, which can be also assembled from pentagon faces
Transformed code to blender add-on
https://bitbucket.org/ios29A/blender_puzzle_generator, maybe it will help someone
Actually 30Kb of Python code, and cube faces are transformed by hands
Just finished it with affine transformations of cube faces.
See a heart from 7x7x7 cube, so here is plain->cube->sphere->lattice transform
I think this method makes it possible to create any 3D shape from squares, even not sphere ones.
Was going to print it in plastic before metal.
Here it is 3х3х3 and was made right before 14' February
It's much simpler than you may imagine.
Download the addon from the given link above (https://bitbucket.org/ios29A/blender_puzzle_generator).
Install it (refer to the documentation).
In Blender, create a cuboid puzzle (add-curve-puzzle. Choose cuboid in the shape option).
Convert the curve into a mesh (object-convert to-mesh...)
Select the cuboid and enter edit mode (tab)
Select all (A)
Mesh-transform-to sphere.
Move your mouse.

Is there a Python library to do constrained triangulations in 3D?

I have a function whose range is a non-convex, simply connected region in R3. When I sample the function I know if the resulting point is on the surface of the region or not. I'd like to triangulate those samples subject to the surface constrains, i.e., the resulting tetrahedra should not
"hide" surface points. The hull would not be convex, of course.
I searched around for a library. So far I found Triangle, but it only works in R2. I also found TetGen, which works in R3, but it requires to provide
the surface triangulation (which I don't have). Also, as far as I can see, these C/C++ libraries do not have Python bindings.
Any suggestions? Thanks!
You may take a look at CGAL it has python-bindings.
One side note: If you need the surface triangulation (which seems to be a 2D problem), you may take each face, project it to 2D, triangulate it, and back to your 3D face.
EDIT due to comment: CGAL does "only" 3D triangulation. 3D constrained triangulation requires Steiner points. Since not every input can be triangulated in 3D (Schönhardt polyhedron as the classical counter-example).
Maybe you can take a look at MeshPy it looks like it has what you are looking for: "MeshPy provides Python interfaces to three well-regarded mesh generators, Triangle by J. Shewchuk, TetGen by Hang Si, and gmsh by Christophe Geuzaine and Jean-Francois Remacle."

Spline in VTK looks distorted

I am using the vtk package for python 2.7 to create some 3-dimensional stuff that I want to export to an .stl. Part of the geometry are sine waves with adjustable amplitudes. Here is my problem: When I generate the splines from point data (basically a point in every max, min and turning point) it does not look uniform!
This is what the spline looks like:
You can see that the middle amplitude looks kinda okay, while the rest is clearly distorted towards the center
Basically I only want the middle part to look like a perfect sine, because I cut away the remainder anyway.
When I use another program (Autodesk Inventor) to create splines manually from the same point data it creates a uniform sine wave. Is there a way to fix this problem?
Sorry for not providing any code, but I will give you the steps I do:
add points to vtkPoints object
create vtkParametricSpline with vtkPoints as input
use vtkSplineFilter to get a finer resolution of the spline
use vtkTubeFilter to create volume
use vtkClipClosedSurface to cut away what is not needed
In the end, parameterizing the line with a cosine function was the only way to avoid the weird spline behaviour. I tried avoiding it before, because it seemed over-engineered, but it turned out to be the better way.
New algorithm:
cosine function -> vtkPoints-> vtkLineSource -> vtkTubeFilter

How can I create a Maya Nurbs curve to match a joint chain?

I have a joint chain that twists and turns -- all rotation axes are used. I'm trying to create a Nurbs curve from this that matches the path of the joints. Ideally I could specify the density of the CVs and the degree of the curve as well. Not having much luck with curve creation options.
Any help would be appreciated! I'm working mainly in Python.
The cheap solution is to loop through the bones, getting their positions, then create a degree-1 (linear) curve from them.
def joint_positions(j):
pos = [cmds.xform(j,q=True, t=True, ws=True)]
children = cmds.listRelatives(j, c=True) or []
for child in children:
pos.extend(joint_positions(child))
return pos
joints = joint_positions('joint1')
cmds.curve(d = 1, p=joints)
That gives you a curve with one knot at every joint. You can then use some combination of the fitBSpline command to resample it into a smoother form, and/or the rebuild command to sample it more regularly. You can experiment with those interactively using the UI to find good values for your application then bake them into a script when you know what you're looking for. There's not a single, perfect, mathematically pure answer in degrees higher than 1 so you're basically eyeballing what looks best for your application.

Placing vertices of graphs + wxpython

I have to draw graphs along with edges according to a file input by the user. I am using wxPython for the same.
Once the positions are clear I can easily create circles and edges between the nodes but
I have a problem that given a panel to draw on is there any way I can get to know optimum positions for the vertices to be if I know the number of vertices ?
By optimum I mean simply that its readable what has been drawn and written along with it.....
So say that I have to draw 3 vertices I just want that I am able to clearly get the coordinates of where to place the nodes and if I can make the system automated....
Please help ....
You want a Graph Drawing algorithm. There is ongoing research in this area, but a simple force-directed algorithm can give good results for small graphs. Look at this wikipedia article for the algorithm. You can also get some open source libraries that handle this problem, like NodeBox and Graphvis.
Also a good lib: igraph
It offers a nice collection of layout algorithms

Categories

Resources