Grasshopper

algorithmic modeling for Rhino

I have a single surface and a few dozen curves that I want to use to split the surface. I know that there is a srfSplit component in Grasshopper but it is achingly slow(takes around 8 min and sometimes fails). However, I know that if I am in Rhino and take the same surface and same set of curves the split command will work and it will take about 10 seconds. My idea was to write a small script in Python and see if that would be as fast as doing it in Rhino. The problem is that the only split command in python is rs.splitBrep and it takes one brep as the object to split and one BREP(NOT curve or curves) as the splitting object.

Can anyone help with the appropriate python command or any other suggestion. The main issue is to speed up the splitting process.

Thanks.

Views: 7505

Replies to This Discussion

Hi Jon

  • could you send a sample of the error/problem you are experiencing with the Grasshopper srfSplit?

The functionality is based on BrepFace.Split(), but I doubt you will be able to speed the process by writing a script that calls it directly because most of the time is spent inside the function itself. One thing you could do is try decreasing the tolerance.

An example is attached.
I hope this helps,

- Giulio
________________
giulio@mcneel.com

Attachments:

Giulio,

Thanks for taking a look - sorry for the slow reply but I was out of the office. I highlighted a part of the grasshopper definition in BLUE. It is here where the definition is slowing down. As you can see I mirrored the srfSplit with the python definition that you gave to me. It unfortunately still taking a long time. What I don't understand is why if I bake the 3 sets of curves from the offset components (the ones to the left that are feeding into the srfSplit), go into Rhino and use the Split command it takes 5 seconds but if I do it from grasshopper it takes 7 minutes.

on a related note the code snippet that you provided:

Rhino.Geometry.BrepFace.Split(face,
[rs.coercecurve(crv) for crv in crvs],
0.1)

when I go to http://www.rhino3d.com/5/rhinocommon/ and look up this method I do not see a parameter for face, just curves and tolerance.

thanks for all of your help appreciated as always.

Attachments:

Hi Jon,

yes, I notice the slow processing of this, too. I'll ask if a better method exists (maybe Steve knows). About the code -- this is normal: in Python you can call instance methods with the object as first argument (self).

Thanks,

- Giulio
______________
giulio@mcneel.com

Thanks Giulio for looking into to this further. I would really be interested in why the process is SO much slower in Grasshopper than in Rhino and if there is a way to speed it up its really limiting the usefulness of this grasshopper definition. Regarding the code - that is what I thought I forgot that you don't have to use the word "self"

thanks again!

I'va added a wish to the list.

Yes, in Python:

Rhino.Geometry.BrepFace.Split(a, b, c)

is the same as

a.Split(b, c)

if a is an instance of Rhino.Geometry.BrepFace.

Thanks,

- Giulio
________________
giulio@mcneel.com

Thanks Giulio.

I am trying to come up with a work around. This works as a python script in Rhino

import rhinoscriptsyntax as rs

crvs = rs.ObjectsByType(4)
srf = rs.ObjectsByType(8)

cmd = "_Split " + "_SelID " + srf[0].ToString() + " _Enter "

for crv in crvs:
cmd = cmd + " _SelID "+ crv.ToString()
cmd = cmd + " _Enter "
rs.Command(cmd)

But when I port it to a python component in Grasshopper it doesn't work. I am assuming it is because the "curves" are not in the rhino document. But I am not sure how to proceed. Any Ideas.

import rhinoscriptsyntax as rs

def SplitSurfaceWithCurves(srf, crvs):
cmd = "_Split " + "_SelID " + srf.ToString() + " _Enter "
#print(srf.ToString())
upBound = len(crvs)

for i in range(0,upBound):

cmd = cmd + " _SelID "+ crvs[i].ToString()
cmd = cmd + " _Enter "
#print(cmd)
splitted = rs.Command(cmd)
print(splitted)
#return[splitted]

splits = SplitSurfaceWithCurves(srf, crvs)

Hi Jon, this would be really workaround... indeed kind of a nasty one. Can you wait for this to be inside RhinoCommon or will you do anything to have the code above working before then?

- Giulio
____________
giulio@mcneel.com

I will just wait till the code gets into rhinocommon. For now what I did is break the grasshopper code in two. One part creates all the lines. I then bake them and use them in Rhino to split the surface. I then use the second half of the grasshopper to operate on all of the split surfaces.

Ideally, I wouldn't have to bake things and could keep it all in Grasshopper but until the code gets into Rhinocommon its just not doable.

Thanks for all of your help.

-jk

Sometimes it doesn't work if there more than one space in between the commands. I have tried printing the entire command before running it and I found that sometimes I had double spaces. I made it work by making sure that there were only single spaces.

Hi Giulio and Jon.

Any news about this piece of coding being in RhinoCommon yet?

Cheers Rasmus

hello, any development on this? best, d

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