algorithmic modeling for Rhino
Tags:
Hi Sawsan,
do you need ONE component, that does all of this or are these all different components? This doesn't seem to be heavy stuff, you might do a c# script instead of going into vs and compiling this, unless you absolutely have to have compiled version.
Hi Florian,
Yes I want one component ://
thk youu :)
Ok, so for getting a polyline of some curve, you need to get the curves control points. In order to get them you have to get the nurbs curve from the curve:
NurbsCurve nc = crv.ToNurbsCurve();
List<Point3d> pnts = new List<Point3d>();
foreach(ControlPoint cp in nc.Points)
pnts.Add(cp.Location);
Polyline polyl = new Polyline(pnts);
What do you mean by select lines, polylines and arc curves. Select all those objecttypes in rhino?
Lock a layer:
Layer l = RhinoDocument.Layer[RhinoDocument.Layer.Find("Layer 01",false)];
l.IsLocked = true;
l.CommitChanges();
To convert a polyline to curves / lines:
Curve crv = (Curve) polyl.ToNurbsCurve();
Line[] lines = polyl.GetSegments();
Didn't test the code...just pseudocode...but it should give you a hint.
Cheers FF
hi Florian
"select lines, polylines and arc curves" I mean select all those objecttypes in rhino ?
how I can do that ?
thank you
Hi sawsan,
You can write your own type filters like so:
private void RunScript(bool r, ref object A)
{
RhinoDocument.Objects.UnselectAll();
//Define a search type function
Func<Rhino.DocObjects.RhinoObject, Guid> typeFilter = SearchTypes;
Guid[] guids = RhinoDocument.Objects.GetObjectList(typeof(Rhino.DocObjects.CurveObject)).Select(typeFilter).ToArray();
//Remove empty Guids
guids = guids.Where(g => g != Guid.Empty).ToArray();
RhinoDocument.Objects.Select(guids);
A = guids;
}
// <Custom additional code>
//The type search function
private Guid SearchTypes(Rhino.DocObjects.RhinoObject input){
if(input.GetType() != typeof(Rhino.DocObjects.CurveObject))
return Guid.Empty; //abort + return empty
Type[] types = new Type[3]{
typeof(PolylineCurve),
typeof(ArcCurve),
typeof(NurbsCurve)
};
foreach(Type t in types){
if(input.DuplicateGeometry().GetType() == t){
return input.Id;
}
}
return Guid.Empty; //return empty;
}
Seee the attached definition for this example.
hi Florian
I ask if I can move content from one layer to another existing? how?
thank you
something like this?
Rhino.DocObjects.RhinoObject[] rhobjs = doc.Objects.FindByLayer(oldLayerName);
if (rhobjs == null || rhobjs.Length span class="highlight-number">1)
return;
foreach(Rhino.DocObjects.RhinoObject obj in rhobjs){
obj.Attributes.LayerIndex = newLayerIndex
obj.CommitChanges();
}
thank you Florian but
I want to move the content layer created by default in another that I created.
So oldLayerName is the layer name which is by default in rhino.
:)
Rhino.DocObjects.RhinoObject[] rhobjs = doc.Objects.FindByLayer(doc.Layers.CurrentLayer);
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
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by