Grasshopper

algorithmic modeling for Rhino

Ladybug component such as solar radiation analysis will subdivide the surface into smaller patches based on grid size specified.

May I ask how this is achieved using Python script, specifically the Rhinoscript commands used?

Thanks!

Views: 1401

Replies are closed for this discussion.

Replies to This Discussion

Dear buggers, advice is greatly appreciated! Thanks!

Hi Grasshope,

While I didn't write that component myself. You need the RhinoCommon Mesh.CreateFromBrep method 

search for it in the RhinoCommon - http://4.rhino3d.com/5/rhinocommon/

http://4.rhino3d.com/5/rhinocommon/

Hi Grasshoppe,

Anton is right. You just need to set a number of meshing parameters based on the gridSize.

Here is the sample code that you can find in Honeybee_Generate Test Points:

https://github.com/mostaphaRoudsari/Honeybee/blob/master/src/Honeyb...

Mostapha

Thank you Anton and Mostapha!

I did a brute force "copy and paste" test of the following code, and it didn't work with the warning of unable to determine the length of the brep objects.

I'm sure I get it wrong in this way, and I hope you can point out how to correct the errors.

import Rhino as rc
import Grasshopper.Kernel as gh
from itertools import chain
import System.Threading.Tasks as tasks
import rhinoscriptsyntax as rs

mesh = []

def createMesh(brep, gridSize):
    ## mesh breps
    def makeMeshFromSrf(i, inputBrep):
        try:
            mesh[i] = rc.Geometry.Mesh.CreateFromBrep(inputBrep, meshParam)[0]
            inputBrep.Dispose()
        except:
            print 'Error in converting Brep to Mesh...'
            pass

    # prepare bulk list for each surface
    mesh = [None] * len(brep)

    # set-up mesh parameters for each surface based on surface size
    meshParam = rc.Geometry.MeshingParameters.Default
    meshParam.MaximumEdgeLength = gridSize
    meshParam.MinimumEdgeLength = gridSize
    meshParam.GridAspectRatio = 1

    for i in range(len(mesh)): makeMeshFromSrf(i, brep[i])
    
    return mesh

createMesh(brep, 0.1)

Attachments:

Grasshope,

Make sure you have input parameter "brep" set to 'List Access' and Type Hint 'Brep' (see screen capture below). I've also added a "gridSize" input parameter so you can control the number of mesh faces.

Hope this helps.

/SPM

File attached.

Attachments:

Thank very much, Stephen!

I found that unexploded Brep object will not be properly processed by the code: only the first surface within the Brep object will be converted to a mesh.

Can you kindly advise the rhinoscript to explode a Brep surface?

Thank you!

Attachments:

The easiest solution is to use the [Deconstruct Brep] component and plug in the output faces into Python. You would have to do this for the [Honeybee_Generate Test Points] component as well.

Concerning your second question below, that has to do with the way we call the function. In the Honeybee component, you will notice that Mostapha creates a new list from 'createMesh' and passes that through another function as an argument. So the organization is a bit different from what you're doing.

Hope this helps.

/SPM

Hi Grasshope

Is this what you are looking for? Check out the component Brep to Mesh

Cheers,

Anton

Attachments:

Hi Stephen, 

I also wonder why in your GH file the brep node must be set as "List Access" to take a group of Breps, whereas in Mostapha's Honeybee_Generate Test Points component, the _testSurface node set as "Item Access" can take a group of Brep as input using the same Python code...

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service