algorithmic modeling for Rhino
Hi Michael,
You can write extension methods, is that the sort of thing you were looking for? What exactly are you trying to accomplish?
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David,
I have some functions and own libaries which I often use. I do not want to always attach them as assembly but simply have a kind of dummy .dll with exents the Rhinocommon.dll and the Rhino namespace.... somekind of playground which you can manipulate your way but is a standard part of rhinocommon.
Ah and what would be also very cool is a conduit which can be selected like a curve,brep etc. but does something totaly different (somethin you can modify) Till now I have a custom selector which is totally crap. I want to build a own contrained parametric sketcher for grasshopper. This is only some testing code.
I will send you something. As a idea....
private void RunScript(List<GeometryBase> x, object y, ref object A, ref object B)
{
Rhino.Geometry.GeometryBase geobase_result;
List<Rhino.Geometry.GeometryBase> geobase_ll = x;
Point3d point = new Point3d(12, 12, 12);
GetPointAtCursorPos(ref point, geobase_ll, out geobase_result);
A = point;
B = geobase_result;
}
Custom additional code::
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool GetCursorPos(out System.Drawing.Point pt);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool ScreenToClient(IntPtr hWnd, ref System.Drawing.Point pt);
public static bool GetPointAtCursorPos(ref Point3d point, List<Rhino.Geometry.GeometryBase> geobase_in, out GeometryBase geobase_out)
{
geobase_out = null;
bool rc = false;
Rhino.Display.RhinoView view = RhinoDoc.ActiveDoc.Views.ActiveView;
if (view != null)
{
System.Drawing.Point pt;
if (GetCursorPos(out pt) && ScreenToClient(view.Handle, ref pt))
{
Transform xform = Transform.Unset;
xform = view.ActiveViewport.GetTransform(Rhino.DocObjects.CoordinateSystem.Screen, Rhino.DocObjects.CoordinateSystem.World);
point = new Point3d(pt.X, pt.Y, 0.0);
point.Transform(xform);
//
Vector3d camera_vector = view.ActiveViewport.CameraDirection;
Rhino.Geometry.Ray3d my_ray = new Rhino.Geometry.Ray3d(point, camera_vector);
Line ray_line = new Line(my_ray.Position, my_ray.Direction * 2000000);
Curve ray_curve = ray_line.ToNurbsCurve();
int int_sel;
Point3d pt_crv = Point3d.Unset;
Point3d pt_obj = Point3d.Unset;
ray_curve.ClosestPoints(geobase_in, out pt_crv, out pt_obj, out int_sel);
if (theshold() > pt_crv.DistanceTo(pt_obj))
{
geobase_out = geobase_in[int_sel];
}
else {geobase_out = null;}
//
rc = true;
}
}
return rc;
}
public static double theshold()
{
Point3d[] rec_pt = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.GetNearRect();
double aspect = rec_pt[0].DistanceTo(rec_pt[2]);
return aspect / 100;
}
If you want to use types and methods defined in a specific assembly, you must reference that assembly at compiletime. You could do these things via reflection or dynamic, but it's going to be a major pain in the behind real soon compared to proper referenced assemblies.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
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