Grasshopper

algorithmic modeling for Rhino

hello david
I need to develop a component with C # who did this to me:
1 - Transformation of the starting geometry: 
---- Converts curves to polylines
---- Selects lines, polylines, arc curves
---- Disable layer
---- Converts polylines into lines / curves straight
---- Selects lines, polylines, arc curves
I need your help to start -_-
thank youu !
sawsan

Views: 1453

Replies to This Discussion

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

Thank you Florian :)

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.

Attachments:

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);

thank yo

Hi Florian 

how can I empty my component inputs (make empty).?

I use clear but it does not work :(

can you help me thank you :)

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