Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all 8565 articles
Browse latest View live

V ray and rhino 6 c# example


RhinoGet.GetMultipleObjects doesn't trigger DataGridView update

$
0
0

@Will_Wang wrote:

Continuing the discussion from WindowsForms vs Eto.Forms:

Can any C# winforms guru shed some light on this? I have a button and it triggers a RhinoGet.GetMultipleObjects call. Afterwards a DataGridView is supposed to show the meta data of selected rhino objects. The problem is that the datagridview doesn’t refresh post-call, until I interact with another winforms UI element that access that datagridview.

Posts: 2

Participants: 1

Read full topic

Open Rhino Options in an specific page

$
0
0

@lucabrasi wrote:

Hi,

Is there a way to open the Rhino Options dialog, on a specific page? I’m trying with my 2Shapes page, but I can not do it even in other Rhino pages like File,…

I was trying to run the command: ! _-Options , but is for scriptable, and I want to show the dialog.

Any idea?

Thanks,

Posts: 1

Participants: 1

Read full topic

Deploying Plugin Toolbars for Rhino for Mac

$
0
0

@seppeldue wrote:

Hello,
what is the recommended way to deploy a custom toolbar along with plugins for MacOS?
Is there something like a .rui file?
I tried to save and restore from the .plist file. But that messed up my rhino and it seems to include to much information…

Posts: 3

Participants: 2

Read full topic

Set Greville Points(c++)

Get all Objects in C++?

$
0
0

@ogne941 wrote:

I’m trying to create a plugin in c++ for rhino, and part of my goal is to find out if any objects intersect the selected, and if so, which ones. I’m rather new to coding in general, but so far have created an array of ID’s of the selected objects, if they are not hidden or locked, but am stuck on getting all objects, which I figure has to be possible since there is the _selAll command in Rhino, any advice for how to do this?

Posts: 1

Participants: 1

Read full topic

Accesing Render Material color from GH

$
0
0

@aitorleceta wrote:

Hi, i’am trying to access to render materials difuse color from GH but I cant figure out how to do this. My render material aren’t expected to be assigned to any document object at the moment of accesing to their diffuse color. I want to associate my GH geometry to a render material, so this material will be used later when user decide to bake the GH geometry to the document. So far I can:

names = []
matId = []
colors = []
for mat in Rhino.RhinoDoc.ActiveDoc.RenderMaterials:
    names.append( mat.Name)
    materials.append(str(mat.Id))
    #dont know how to acces to render material color!!

Posts: 1

Participants: 1

Read full topic

Curve with 3 points constraint

$
0
0

@patrick_n wrote:

Hi,

I need to create a curve degree 3 with at least 6 control points.

To explain better I need to create the situation done in the SolidWorks Sketch I attached.

I know the position of start and end points (P0 and P5).

The highest point of the curve must pass through the point P and I know the position.

The variable inputs are:

  • P1 x,y
  • P2 x
  • P4 x,y

I need to define the correct values for P2 y and P3 x,y in order to keep the highest point of the curve on the point P.

SolidWorks can do this automatically.

I assume the best solution is P2 y = P3 y.

Is it possible to achieve a curve starting from this construction in Rhino or Grasshopper?

Best

Patrick

Posts: 8

Participants: 4

Read full topic


Retrieving the Style of a running command

$
0
0

@luciano.micchini wrote:

Hello
How can I obtain the Style (i.e. hidden, transparent, ScriptRunner etc) of a running command?
I got the stack of the running commands by mean of the method:
Rhino.Commands.Command.GetCommandStack() which returns an array of command Guids, but I can’t figure out how to use them to retrieve the Style.
I would be grateful if somebody could help me.
Thank a lot.

Posts: 2

Participants: 2

Read full topic

Rhino custom command not show in command menu

$
0
0

@testjalam wrote:

I am using rhino 6 for developing custom command in rhino. I am following videos but at the end i cannot found custome Name commad in rhino command.please help me to understand what I am missing.

Posts: 2

Participants: 2

Read full topic

InstanceDefinition Object is not valid

$
0
0

@Dmitriy wrote:

Hi,
Came across interesting behavior and would like to understand about this behavior:

When I ran through InstanceDefinition objects in RC, I am checking if InstanceDefinition is valid or not.
I have few block definitions where property IsValid gives me False.
However, when opening BlockManager - all blocks including “bad” blocks are there. So far I can only see that preview window doesn’t show anything for “bad” blocks.

Can somebody tell me what is checked behind IsValid property for InstanceDefintion objects?

All blocks I use are embedded blocks.

Thanks,
Dmitriy

Posts: 1

Participants: 1

Read full topic

Display Conduit Geometry Goes Dotted when Control Points Turned On

$
0
0

@bradlcampbell wrote:

I have a RhinoCommon plugin in c# that draws some persistent curves. The plugin is built for both Rhino 5 and Rhino 6 (using shared projects in VS which is kind of interesting but unrelated). In Rhino 5 only, when I turn on the control points for any surface, the solid lines I have drawn (using a display conduit) turn dotted and are very hard to see. Rhino 6 does not do this.

Any thought on what might be causing this and how to fix it?

Thanks,
Brad

Posts: 1

Participants: 1

Read full topic

Not Working!Pick points from Conduit- select Grasshopper Preview points

$
0
0

@su.lwpac wrote:

I found the reference here for the Pick Points from conduit.
https://wiki.mcneel.com/developer/rhinocommonsamples/pickobject

And I built the Code on similar statements:

using System;
using System.Collections;
using System.Collections.Generic;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;

using Rhino.Input.Custom;
using Rhino.Commands;
using Rhino.Display;
using System.Drawing;
using System.Windows.Forms;


/// <summary>
/// This class will be instantiated on demand by the Script component.
/// </summary>
public class Script_Instance : GH_ScriptInstance
{
#region Utility functions
  /// <summary>Print a String to the [Out] Parameter of the Script component.</summary>
  /// <param name="text">String to print.</param>
  private void Print(string text) { /* Implementation hidden. */ }
  /// <summary>Print a formatted String to the [Out] Parameter of the Script component.</summary>
  /// <param name="format">String format.</param>
  /// <param name="args">Formatting parameters.</param>
  private void Print(string format, params object[] args) { /* Implementation hidden. */ }
  /// <summary>Print useful information about an object instance to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj) { /* Implementation hidden. */ }
  /// <summary>Print the signatures of all the overloads of a specific method to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj, string method_name) { /* Implementation hidden. */ }
#endregion

#region Members
  /// <summary>Gets the current Rhino document.</summary>
  private readonly RhinoDoc RhinoDocument;
  /// <summary>Gets the Grasshopper document that owns this script.</summary>
  private readonly GH_Document GrasshopperDocument;
  /// <summary>Gets the Grasshopper script component that owns this script.</summary>
  private readonly IGH_Component Component;
  /// <summary>
  /// Gets the current iteration count. The first call to RunScript() is associated with Iteration==0.
  /// Any subsequent call within the same solution will increment the Iteration count.
  /// </summary>
  private readonly int Iteration;
#endregion

  /// <summary>
  /// This procedure contains the user code. Input parameters are provided as regular arguments,
  /// Output parameters as ref arguments. You don't have to assign output parameters,
  /// they will have a default value.
  /// </summary>
  private void RunScript(List<Point3d> pts, bool on, ref object A)
  {

    if (on)
    {
      var pickPoints = PickPoints(pts);
      A = pickPoints;
    }
    else
    {
      return;
    }


  }

  // <Custom additional code> 
  //Class defintion for ConduitPoint
  public class ConduitPoint
  {
    public ConduitPoint(Point3d point)
    {
      Color = System.Drawing.Color.AliceBlue;
      Point = point;
    }
    public System.Drawing.Color Color { get; set; }
    public Point3d Point { get; set; }
  }
  

  //Class Definition to Getpoints from the Conduit
  public class GetConduitPoint: GetPoint
  {
    private List<ConduitPoint> _conduitPoints;

    public GetConduitPoint(List<ConduitPoint> conduitPoints)
    {
      _conduitPoints = conduitPoints;
    }   
    


    //Function to access the mouseDown Event
    protected override void OnMouseDown(GetPointMouseEventArgs e)
    {
      base.OnMouseDown(e);
      var picker = new PickContext();
      picker.View = e.Viewport.ParentView;

      picker.PickStyle = PickStyle.PointPick;

      var xform = e.Viewport.GetPickTransform(e.WindowPoint);
      picker.SetPickTransform(xform);

      foreach (var cp in _conduitPoints)
      {
        double depth;
        double distance;
        if (picker.PickFrustumTest(cp.Point, out depth, out distance))
          cp.Color = System.Drawing.Color.Red;
        else
          cp.Color = System.Drawing.Color.White;
      }
    }
  }
  class PointsConduit : Rhino.Display.DisplayConduit
  {
    private List<ConduitPoint> _conduitPoints;

    public PointsConduit(List<ConduitPoint> conduitPoints)
    {
      _conduitPoints = conduitPoints;
    }

    protected override void DrawForeground(Rhino.Display.DrawEventArgs e)
    {
      if (_conduitPoints != null)
        foreach (var cp in _conduitPoints)
          e.Display.DrawPoint(cp.Point, PointStyle.X, 5, Color.Green);
    }
  }

  //Function to generate Points to access
  private List<Point3d> PickPoints(List<Point3d> cPoints)
  {
    List<Point3d> pickPoints = new List<Point3d>();
    List<ConduitPoint> conduitPoints = new List<ConduitPoint>();
    var conduit = new PointsConduit(conduitPoints);
    conduit.Enabled = true;


    var gcp = new GetConduitPoint(conduitPoints);
    gcp.SetCursor(Rhino.UI.CursorStyle.ArrowCopy);
    while (true)
    {
      gcp.SetCommandPrompt("select conduit point. (<ESC> to exit)");
      gcp.AcceptNothing(true);
      gcp.Get(true);
      doc.Views.Redraw();
      if (gcp.CommandResult() != Rhino.Commands.Result.Success)
      {
        pickPoints.Add(gcp.Point());
        return pickPoints;
      }
    }
  }
  // </Custom additional code> 
}

It does not pick the points, rather it just places a point at the position of cursor. I am sure I am missing something in here.
Any Guidance?

Script is also attached here
Test_PickPreviewPoints.gh (11.0 KB)

Posts: 1

Participants: 1

Read full topic

Opening a Wpf form from Rhino Common C# Plugin

$
0
0

@nevin.mathew wrote:

HI ,

How can we open a wpf form as popupform in Rhinocommon plugin c#.

We are using the windows usercontrol for the main dock panel for the plugin
when users click on the button in the user dock panel, object of winform is created and show method will display the form.
We are opening the form like below this is for displaying some details

PopupForm popUp = new PopupForm ();
popUp.Show();

This works fine, but we need to put some ui rich elements.
if we created instance of the wpfForm (popup.xaml) , there are no methods like show();

I can see examples for wpf as dock panels here https://github.com/mcneel/rhino-developer-samples/tree/6/rhinocommon/cs/SampleCsWpf

but what I need to popup a form like a messagebox or dialog box.

can anybody give some insights on this.
thanks,

Posts: 2

Participants: 2

Read full topic

How to Resolve Empty Spaces in C#


Render Material events

$
0
0

@aitorleceta wrote:

HI all,
to which event should I suscribe to handle “additions” and “deletions” to RenderMaterial table (materials not applied to document objects) and also, which event for handling RenderMaterial modifications (color changes, name changes…) ? I cant figure this out… Tried with RenderMaterialTableEvent, with MaterialTabeEvent and with RenderContent events (ContentAdded ) but no luck…

thanks

Posts: 9

Participants: 3

Read full topic

Point-On-BRep selection

$
0
0

@Daniel_Beckmann wrote:

Hi Everyone -
Trying to write a plugin (C#) which performs analysis on a point on a surface selected by the user. I’d like to use all possible surface types - surface (untrimmed=surface, trimmed=brep), polysurface (brep with multiple faces), extrusion (converted to brep with multiple faces), and so on (coming later since they’re so different: mesh (mesh faces), groups, blocks, etc…). Anyways starting with surface and brep.

Here’s where I start: (with a little editing, hopefully nothing is missing)

                 ObjRef initSrf = null;
                 doc.Objects.UnselectAll();
                 GetObject selectObjs = new GetObject();
                 selectObjs.SetCommandPrompt("Select Surface");
             ObjectType geoFilter = ObjectType.Surface | 
                 //ObjectType.PolysrfFilter |
                 ObjectType.Mesh |
                 ObjectType.Brep |
                 ObjectType.Extrusion |
                 ObjectType.SubD;
                 selectObjs.GeometryFilter = geoFilter;
                 selectObjs.Get();
                 if (selectObjs.CommandResult() != Result.Success) return selectObjs.CommandResult();
                 RhinoApp.WriteLine("G " + selectObjs.Object(0).Object().ToString());
                 initSrf = selectObjs.Object(0);
             GetPoint bouncePoint = new GetPoint();
             bouncePoint.SetCommandPrompt("Pick the point on the surface");
             switch (initSrf.Object().ObjectType)
             {
                 case ObjectType.Brep:
                 case ObjectType.Surface:
                     RhinoApp.WriteLine("# of faces: {0}",initSrf.Brep().Faces.Count);
                     bouncePoint.Constrain(initSrf.Brep(), -1, -1, false);
                     break;
                 case ObjectType.Extrusion:
                     Extrusion extru = initSrf.Object().Geometry as Extrusion;
                     newbrep = extru.ToBrep();
                     RhinoApp.WriteLine("# of extrusion faces: {0}", newbrep.Faces.Count);
                     bouncePoint.Constrain(newbrep, -1, -1, false);
                     break;
             }
             bouncePoint.Get();
             if (bouncePoint.CommandResult() != Result.Success) return bouncePoint.CommandResult();
             Point3d srfPoint = bouncePoint.Point();
             double[] firstPoint = new double[2];
             Vector3d firstNormal = new Vector3d();
             switch (initSrf.Object().ObjectType)
             {
                 case ObjectType.Brep:
                     BrepFace face = bouncePoint.PointOnBrep(out firstPoint[0], out firstPoint[1]);
 
                     if (face == null)
                     {
                         RhinoApp.WriteLine("face is null?");
                     }
                     RhinoApp.WriteLine("U = {0}, V = {1}", firstPoint[0], firstPoint[1]);
                     RhinoApp.WriteLine("brep face " + face.ToString());
                     firstNormal = face.NormalAt(firstPoint[0], firstPoint[1]);
                     if (face.OrientationIsReversed) firstNormal.Reverse();
                     firstRotate = Transform.Rotation(Math.PI, firstNormal, srfPoint);
                     doc.Objects.Transform(firstRay, firstRotate, false);
                     doc.Views.Redraw();
                     break;
                 case ObjectType.Mesh:
                     Dialogs.ShowMessage("Mesh not working yet", "no mesh");
                     return Result.Failure;
             }
 
             return Result.Success;
         }
     }

The problem seems to be that bouncePoint.PointOnBrep(out u, out v); always returns null. I get the u and v parameters of the surface I just don’t know which brep face’s parameters are being returned.

I can start the switch another way, which is successful for a single, untrimmed (i.e. pure) surface (which is still shown as a brep, not a surface in the RhinoApp.WriteLine ("G " + selectObjs.Object(0).Object().ToString()); output):

            switch (initSrf.Object().ObjectType)
            {
                case ObjectType.Brep:
                    BrepFace face = initSrf.Face();
                    bouncePoint.PointOnBrep(out firstPoint[0], out firstPoint[1]);

I might be able to boil this down to one item: under what condition does GetPoint.PointOnBrep return the BrepFace? (searching for “PointOnBrep” has precious few returns, maybe no-one is using it?)

If there’s other, better ways to work with polysurface component pieces (and later, meshes), I’m open to suggestions. Thanks.

Posts: 2

Participants: 2

Read full topic

Transparent dialog form background?

$
0
0

@Eugen wrote:

Hello!
Is it possible in Python and ETO to have a dialog form with a transparent background and no title bar?
I’m planning to write a quadrant menu system for Rhino, 3ds Max-style (I once did for Softimage, using .net forms).
If not, maybe it is in some other supported language, C#, C++?
Thanks!
Best regards
Eugen

Posts: 3

Participants: 2

Read full topic

Is there a way to undo Rhino's suppression of all command line output

$
0
0

@mathias.fuchs wrote:

Hi everyone!
When developing a plugin (in whatever language) it sometimes happens that one uses a library which outputs diagnostic messages on the output … for instance, there might be a C++ library that contains lines such as fprintf(stdout, “Hello from me”) or some std::cout << “hello” << std::endl etc.
It seems Rhino suppresses all these messages. Starting Rhino from the command line runs Rhino but results in silence so Rhino forbids their mouth very decisively.
Is there a way to re-enable the command line output?
I can’t easily re-direct these debug messages to a file because they happen inside some large third-party code that I can’t unearth so easily.
This is a big impediment to a good debugging experience.
Thanks!

Posts: 2

Participants: 1

Read full topic

Edge Surface method in C#

$
0
0

@mahanmotamedi1991 wrote:

Hello everyone,

Does the EdgeSurface method exist in Rhino/Grasshopper library in C#? I went through Rhino.Geometry.Surface and Rhino.Geometry.NurbsSurafce and I could not find any method that can make a surface from given edges.

Best,

Mahan

Posts: 3

Participants: 2

Read full topic

Viewing all 8565 articles
Browse latest View live