Weaverbird from Python


#1

Hi Giulio @piac

I’d like to use Weaverbird directly from Python. Is there an example how to use it?
Or a documentation with functions, arguments etc.?


(Giulio Piacentino) #2

Hi @Jess

thanks for the question here :slight_smile:

If you are aiming for a simple interaction, you can use the method shown on the GH forum. It has access to all components:

http://www.grasshopper3d.com/forum/topics/weavebird-in-python:
You can use ghpythonlib.components.

import ghpythonlib.components as ghc
ghc.WeaverBird. #... will show Wb commands

There are also other methods, but this is the simplest one. Does it help?

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


(Giulio Piacentino) #4

You can install it by running the installer. Then you will need to add the Weaverbird installation folder to the V6 Grasshopper settings, using the _GrasshopperDeveloperSettings command. You should add “C:\Program Files\Weaverbird” there. ghpythonlib should also work in V5, provided the latest GhPython is installed.

If you still have problems in V5, check that you do not have a lot of other add-ons (I know one that makes loading other add-ons impossible in V5).

I hope this helps,

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


#5

Hi Giulio,

Thanks that helps. I’ll try to make a simple Python example with some WB functions and post it here.

Jess


#6

Fine, here a simple example with Weaverbird via Python:

import Rhino
import ghpythonlib.components as ghc
import scriptcontext as sc

def wbTest():
    plane = Rhino.Geometry.Plane.WorldXY
    width = 5.0
    sides = 3
    top = Rhino.Geometry.Point3d(0,0,10)
    mesh = ghc.WeaverBird.WeaverbirdsMeshPrism(plane,width,sides,top)
    sc.doc.Objects.AddMesh(mesh)
    cc = ghc.WeaverBird.WeaverbirdsCatmull_ClarkSubdivision(mesh,2)
    rc = sc.doc.Objects.AddMesh(cc)
    sc.doc.Views.Redraw()
    
if __name__ == "__main__":
    wbTest()

enjoy :wink:


CreateRefinedLoopMesh, CreateRefinedCatmullClarkMesh bugs
#7

I remember looking into accessing the Weaverbird core .dll a while back (similar to how we’ve been implementing Kangaroo2, Plankton etc), would this be one such approach?

:wink:


(Giulio Piacentino) #8

Yes, exactly, but they are not so straighforward, because they were not written with Python in mind (nor third-parties in mind).