algorithmic modeling for Rhino
Hello, I have just a simple question.
I want to create a planar surface from a closed curve and I found out that I should use Brep.CreatePlanarBreps(curve). But I am not clear how to write the code in C#.
private void RunScript(Curve x, ref object A)
{
Brep a= new Brep.CreatePlanarBreps(x);
A = a;
}
But the error is Brep.CreatePlanarBreps() is a method but is used like a type. Also, can someone explain the method and type?
Tags:
This Method returns an Array.
In order to understand the reasons input a closed polyline (or curve) that intersects with itself > what happens?
Brep[] arrayOfBreps = Brep.CreatePlanarBreps(Crv); (were Crv is a List or an individual Curve)
Brep oneOfThem = arrayOfBreps[someIndex]; (where someIndex < arrayOfBreps.Length)
Or: List<Brep> listOfBreps = Brep.CreatePlanarBreps(Crv).ToList();
Or ... if you are sure that we are talking for ONE planar output (but better safe than sorry):
try{ someBrep = Brep.CreatePlanarBreps(Crv)[0];} (declare someBrep as public and/or private)
catch{Print("Adios Amigos");}
BTW: the orthodox way is:
DataTree <Brep> breps = new DataTree<Brep>();
for (int i = 0; i< crvList.Count;i++){
Curve c = crvList[i];
string log;
if(c.IsValidWithLog(out log) && c.IsPlanar() && c.IsClosed){
try{
Brep arrayB= Brep.CreatePlanarBreps(c);
breps.AddRange(arrayB, new GH_Path(i));
}
catch{ Print("Some issue with Method at: {0},i);}
}
else Print("Not Valid or non planar or not closed at: {0} [log: {1}]", i, log);
}
For instance:
Thank you so much! That really helps me to understand it!
BTW: "split" the if clause that checks the IsClosed. IsPlanar and IsValidWithLog into 3 different clauses > that way you'll be informed explicitly what's wrong. Ttry the IsClosable thingy as well.
Why? well ... always TAKE FOR GRANTED that something is wrong with regard your input(s): rule N1 in programming.
BTW: Try/Catch is a rather crude approach for handling exceptions ... but who cares?
As an exercise: experiment on curves that intersect (see SDK) with others and/or are contained (see SDK) inside other curves (but that actually [general case] requires a primitive kind of cluster analysis).
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by