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

Export to STEP


How to setup ''specular'' in material with c++

$
0
0

@tll4568523 wrote:

hi everyone. In material there have three Custom Settings’ tool : specular、reflection and transparency I want to control specular use c++ code.(Red circle in picture which is named " Gl ")


I can use m_transparency& m_reflectivity in “opennurbs_material.h” to control it’s proportion and both work.Also I can change specular’s color but can’t control specular’s proportion with m_shine or SetShine(). It’s there have any code can do it ?
image

Posts: 1

Participants: 1

Read full topic

Rhino Wip Crash (edit: also Rhino 6)

$
0
0

@aitorleceta wrote:

Hi,
the next piece of code is systematically crashing my Rhino WIP

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
import Rhino.Geometry as rg
import System

for layer in Rhino.RhinoDoc.ActiveDoc.Layers:
    matIndex = layer.RenderMaterialIndex
    Rhino.RhinoDoc.ActiveDoc.RenderMaterials[matIndex] #this lookup seems to be the culprit

Rhino 7 SR0 2020-4-7 (Public Build, 7.0.20098.14255, Git hash:master @ 722815a2cc6d608c61fa901937505fe0bb80df0f)
License type: Commercial, build 2020-04-07
License details: Cloud Zoo
Expires on: 2020-05-22

Windows 10.0 SR0.0 or greater (Physical RAM: 32Gb)

Non-hybrid graphics.
Primary display and OpenGL: NVIDIA Quadro RTX 5000 (NVidia) Memory: 16GB, Driver date: 1-31-2020 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 442.23

OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On

Anti-alias mode: 4x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: Height

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 1-31-2020
Driver Version: 26.21.14.4223
Maximum Texture size: 32768 x 32768
Z-Buffer depth: 24 bits
Maximum Viewport size: 32768 x 32768
Total Video Memory: 16 GB

Rhino plugins that do not ship with Rhino
C:\Program Files\Chaos Group\V-Ray\V-Ray for Rhinoceros\V7\VRayForRhino.rhp “V-Ray for Rhino”

Rhino plugins that ship with Rhino
C:\Program Files\Rhino 7 WIP\Plug-ins\Commands.rhp “Commands” 7.0.20098.14255
C:\Program Files\Rhino 7 WIP\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 7 WIP\Plug-ins\RhinoRenderCycles.rhp “Rhino Render” 7.0.20098.14255
C:\Program Files\Rhino 7 WIP\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 7.0.20098.14255
C:\Program Files\Rhino 7 WIP\Plug-ins\rdk_ui.rhp “Renderer Development Kit UI”
C:\Program Files\Rhino 7 WIP\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 7 WIP\Plug-ins\IronPython\RhinoDLR_Python.rhp “IronPython” 7.0.20098.14255
C:\Program Files\Rhino 7 WIP\Plug-ins\RhinoCycles.rhp “RhinoCycles” 7.0.20098.14255
C:\Program Files\Rhino 7 WIP\Plug-ins\Grasshopper\GrasshopperPlugin.rhp “Grasshopper” 7.0.20098.14255
C:\Program Files\Rhino 7 WIP\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 7.0.20098.14255
C:\Program Files\Rhino 7 WIP\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Rhino 7 WIP\Plug-ins\Displacement.rhp “Displacement”

Posts: 3

Participants: 2

Read full topic

MeshNGon class on Mac OS

ConvertCurveToPolyline problem

$
0
0

@MatrixRatrix wrote:

Hello ,

I try convert elipse on policurve:
elipse.3dm (21.7 KB)

elipse = rs.GetObject(“get”);
converted = rs.ConvertCurveToPolyline(elipse, 0.1, 0.1, False, 0, 0.2 );

I need that the maximum length of the segments does not exceed 0.2, for some reason this is not happening, any idea?

Thanks

Posts: 1

Participants: 1

Read full topic

How does DrawMeshVertices() work?

$
0
0

@Peter_Salzman wrote:

Hi!
In the SDK there is a call

void DrawMeshVertices(const ON_Mesh&, const ON_Color& color);

So I tried to use it in my conduit, but nothing visible appeared on the screen. Is there anything more (e.g. vertex atributes) that I have to set up?

What I tried instead was something like this:

int iVertexCount = mesh.m_V.Count();
ON_3fPoint P;
for (int i = 0; i < iVertexCount; i++)
{
P = mesh.m_V[i];
pipeline.DrawPoint(P, 1, RPS_CIRCLE, color);
}

This works, but I would assume there maybe a more efficient way inside DrawMeshVertices(). The mesh uses ON_3fPoint for the vertex array, DrawPoint() uses ON_3DPoint

Posts: 1

Participants: 1

Read full topic

Function WithDisplacement problem

$
0
0

@jerry1 wrote:

Hello every one, I attempt to using the following function to extrude a mesh.

Public Function WithDisplacement (
displacement As MeshDisplacementInfo
) As Mesh

    Dim k As Rhino.Geometry.MeshDisplacementInfo
    k.ChannelNumber = 1
    k.BlackMove() = 3
    Dim sdd As Mesh
    sdd = msh(0).WithDisplacement(k)
    RhinoDoc.ActiveDoc.Objects.AddMesh(sdd)
    RhinoDoc.ActiveDoc.Views.Redraw()

    But the result show me that k is nothing? How to solve this problem? 
    thanks~~

Posts: 1

Participants: 1

Read full topic

Custom multiple plugin installer for Rhino for Mac

$
0
0

@seppeldue wrote:

Does anybody have a suggestion on how to write a custom installer for rhino for Mac? I have multiple plugins a want to install with one installation. For windows I used wix with the example files provided by @menno. Anything similar around for MacOs? Has anybody done that yet and can provide me with some example?
Thanks.

Posts: 2

Participants: 2

Read full topic


C# elif statement throwing error!

$
0
0

@su.lwpac wrote:

I am trying to create an elif statement to pass values to multiple outputs. But the component just throws errors.

I used this reference from Microsoft website for creating my statement

here is the Code snippet from C#

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;

/// <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(DataTree<Mesh> icModules, DataTree<string> icHomeID, ref object A, ref object B, ref object C, ref object D)
  {

    DataTree<Mesh> oneBrModules = new DataTree<Mesh>();
    DataTree<Mesh> inteLockBrModules = new DataTree<Mesh>();
    DataTree<Mesh> twoBrModules = new DataTree<Mesh>();
    DataTree<Mesh> threeBrModules = new DataTree<Mesh>();

    var inputPath = icModules.BranchCount;
    for (int i = 0; i < inputPath; i++)
    {
      GH_Path icPath = new GH_Path(i);
      for (int j = 0; j < icModules.Branch(i).Count; j++)
      {
        if (icHomeID.Branch(i)[j] == "A")
        {
          oneBrModules.Add(icModules.Branch(i)[j], icPath);
        }
        lif(icHomeID.Branch(i)[j] == "B")
        {
          interLockBrModules.Add(icModules.Branch(i)[j], icPath);
        }
        elif(icHomeID.Branch(i)[j] == "C")
        {
          twokBrModules.Add(icModules.Branch(i)[j], icPath);
        }
        else (icHomeID.Branch(i)[j] == "D")
        {
          threeBrModules.Add(icModules.Branch(i)[j], icPath);
        }
        endif
      }



    }
    A = oneBrModules;
    B = oneBrModules;
    C = oneBrModules;
    D = oneBrModules;



  }

  // <Custom additional code> 

  public Mesh SelectOneBR(Mesh modules, String homeID)
  {
    Mesh oneBRmodule = new Mesh();
    String homeName = "A";
    if (homeID == homeName)
    {
      oneBRmodule = modules;
      return oneBRmodule;
    }
    else
    {
      oneBRmodule = null;
    }
    return oneBRmodule;

  }
  public Mesh SelectInterLockBR(Mesh modules, String homeID)
  {
    Mesh interLockBRmodule = new Mesh();
    String homeName = "B";
    if (homeID == homeName)
    {
      interLockBRmodule = modules;
      return interLockBRmodule;
    }
    else
    {
      return null;
    }
  }
  public Mesh SelectTwokBR(Mesh modules, String homeID)
  {
    Mesh twoBRmodule = new Mesh();
    String homeName = "C";
    if (homeID == homeName)
    {
      twoBRmodule = modules;
      return twoBRmodule;
    }
    else
    {
      return null;
    }
  }
  public Mesh SelectthreeLockBR(Mesh modules, String homeID)
  {
    Mesh threeBRmodule = new Mesh();
    String homeName = "D";
    if (homeID == homeName)
    {
      threeBRmodule = modules;
      return threeBRmodule;
    }
    else
    {
      return null;
    }
  }

  // </Custom additional code> 
}

Also the Script: Elif Test.gh (32.8 KB)

Why is this happening?

Posts: 2

Participants: 2

Read full topic

Eto panel is not rendered/refreshed correctly in ObjectPropertiesPage

$
0
0

@mingo1214 wrote:

Hi All,

I have created a customized ObjectPropertiesPage and its PageControl will be updated (via overriding UpdatePage()) when selected object changes.

Here is a problem it is kind of randomly occurring: it seems the panel is not rendered/refreshed correctly sometime. It will show up correctly until the cursor moves above or re-select the rhino object.

2020-04-15-20-27-07

Do you have solutions to fix this?

Thanks in advance,
Mingbo

cc @dale

Posts: 3

Participants: 2

Read full topic

Length parameter from Curve parameter space

Tabbed dock bar on the side (C++)

$
0
0

@Pablo_Garcia-Amorena wrote:

Hi,

We have a skin where we remove most of the Rhino UI and then create an instance of CRhinoTabbedDockBarDialog. We do it like in @dale’s SampleTabbedDockBar.

The problem is that the first time we call this window it’s floating on the screen:

We need to have it docked on the side from the beginning, like this:

How to achieve this? Maybe there’s a way through CRhinoUiDockBar, how exactly?

Pablo

Posts: 1

Participants: 1

Read full topic

Adding Probability to the Game of Life

$
0
0

@siul wrote:

So I am working on adding probability to crate meshes that are either alive or dead. Using code from Game of Life I would like to establish rule sets that change the likelihood of a mesh coming back to life or dying.

Below is a piece of code where I would like to add an 80% chance to the ruleset but can’t manage to right the conditional.

 def applyGOL(self):
        #create temporary dictionary to save new values in
        newValues = {}
        #loop through x and y values
        for i in range(self.intX):
            for j in range(self.intY):
                #call function to find the sum of the neighbors
                sum = self.sumNeighbors(i, j)
                #run conditionals to change value 
                #INCLUDING PROBABILITY TO THE CODE
                #if a cell is alive(1)
                if self.valMTX[(i,j)] == 1:
                    #if the cell has less than 2 neighbors it has an 80% chance it dies(0)
                    if sum < 2: 
                        newValues[(i,j)] = 0
                    #if the cell has more than 3 neighbors it dies(0)
                    elif sum > 3:
                        newValues[(i,j)] = 0
                    #otherwise the cell stays alive(1)
                    else:
                        newValues[(i,j)] = 1
                #if the cell is dead(0) 
                else:
                    #it will come to life(1) if it has exactly 3 live neighbors
                    if sum == 3:
                        newValues[(i,j)] = 1

Posts: 1

Participants: 1

Read full topic

Linking error with CRhinoApp::OnEscapeKeyDown(void)

$
0
0

@pyati wrote:

Hi,

I’m trying to use simple function OnEscapeKeyDown() in my C++ plugin for Rhino6 and I’m getting unresolved external symbol error on it. Here’s the line of code which produces it:
if (RhinoApp().OnEscapeKeyDown()) return nothing;

The line is within myClass::RunCommand(…){…} and myClass is derived from CRhinoScriptCommand.

At the same time, I see that another function works fine (no compiler/linker errors):
RhinoApp().RunScript(context.m_doc.RuntimeSerialNumber(),…)

Both functions are defined in rhinoSdkApp.h in CRhinoApp class and both are public.

I’m using Visual Studio toolset v141 and Rhino C++ SDK v.6.23.20055.13111

Can anyone give me advice on this? Is there some dll missing in this SDK as some other functions also produce linking errors?

Thanks in advance!

  • Andrey

Posts: 7

Participants: 2

Read full topic

Get `CRhinoCommand::result` if using `CRhinoApp::RunScript`

$
0
0

@pyati wrote:

Hi,

I have a question about CRhinoApp::RunScript. It returns bool, but there not clear what it is (there’s no description in the comments to the function).

What I actually need is to run another C++ plugin with some parameters specified and somehow figure out if plugin execution failed or not. If it fails, RunCommand of that plugin returns CRhinoCommand::failure but I don’t know if I can somehow catch it with CRhinoApp::RunScript.

I would use CRhinoApp::ExecuteCommand but I believe I don’t have access to setting the parameters for the static object of that plugin class. Or is there a way to set parameters (how would I get the static object which is declared in the plugin main cpp)? I was looking to the description of CRhinoApp::ExecuteCommand

Thanks!

  • Andrey

Posts: 1

Participants: 1

Read full topic


Bug on default button Eto.MessageBox under macOS

$
0
0

@em.rudelle wrote:

Well everything is in the title. I’ve noticed that the following code :

DialogResult lookAnim = MessageBox.Show(this,   "Some text [...]", "Title", MessageBoxButtons.YesNo, MessageBoxType.Question, MessageBoxDefaultButton.No);

… creates a dialog with default button ‘No’ on Windows, but ‘Yes’ on macOS.
I guess there is a mistake somewhere.

@curtisw, I’m tagging you right now on the subject, because it looked on previous posts that you are very much in charge with this. Sorry if not

Posts: 2

Participants: 2

Read full topic

Panels are showing up when selecting / unselecting an object under macOS

$
0
0

@em.rudelle wrote:

Hi,

I have noticed a difference in behaviors between windows and macOS version of Rhino when selecting/unselecting objects in a document.

On windows, the process is rather fast.
On macOS it is much slower because Rhino open and prompt either Object properties or Display panel.

My purpose is to make possible to see an animation of a model being constructed (see the two gif under).


process-macOS

As you can see, there is a way to hide the panels under macOS, but I achieved this only manually. I tried to do the following :

Panels.ClosePanel(PanelIds.ObjectProperties);
Panels.ClosePanel(PanelIds.Display);

And reopen at the end of the process. But selecting the element will re-open the panels every time. Though it is only doing it on Rhino for mac.

The code i use for selecting objects is : doc.Objects.Select()

Posts: 3

Participants: 2

Read full topic

RhinoPyton Get GUID from Object

$
0
0

@tobias.stoltmann wrote:

Hi,
I guess this might be kind of stupid question, but I was not able to solve it.
I am creating Breps with Rhino Common in Python.
So far that works.
When I try to get them back into the rhinoscriptsyntax I am having trouble to get the GUIDs back.

This is what I got: <Rhino.Geometry.Brep object at 0x0000000000002FA2 [Rhino.Geometry.Brep]>
Any help or hints to the right documents are highly appreciated.

Thanks
T.

Posts: 3

Participants: 2

Read full topic

Angle2 Problem

$
0
0

@MatrixRatrix wrote:

Hello ,

I came across this problem, I am using Angle2 to check the angle between two lines,the two blue lines are on the same plane, the same direction and the same angle, but for whatever reason the command Angle2 does not return 0.0, as well as the black lines, is something missing?

Angle problem.3dm (28.8 KB)

import rhinoscriptsyntax as rs

line = rs.GetObject(“line”);
line2 = rs.GetObject(“line2”);

point1 = rs.CurveStartPoint(line);
point2 = rs.CurveEndPoint(line);

point3 = rs.CurveStartPoint(line2);
point4 = rs.CurveEndPoint(line2);

angle = rs.Angle2( (point1, point2), (point3, point4))
print angle[0]

What is the problem??

Posts: 3

Participants: 2

Read full topic

Angle between two lines

$
0
0

@MatrixRatrix wrote:

I have need the angle between two lines (negative or positive depends of frist line) and
I use this code to get:

import rhinoscriptsyntax as rs
line1 = rs.GetObject(“LINE1”)
line2 = rs.GetObject(“LINE2”)
line1Start = rs.CurveStartPoint(line1);
line1End = rs.CurveEndPoint(line1);
line2Start = rs.CurveStartPoint(line2);
line2End = rs.CurveEndPoint(line2)
ang1=rs.Angle(line1Start,line1End)
ang2=rs.Angle(line2Start,line2End)
print ang2[0]-ang1[0]

So, rs,angle only return until 0º/180º and -180º /0º, the problem is I have a angle Ex: 170 and other
-170, the return is -340 or 340 , and supose return -20 or 20 depend the frist line:

I try convert this on full 360º but this brings another problem, the 0º position can also be 360º, this generates calculation error.

Any idea

Posts: 4

Participants: 2

Read full topic

Viewing all 8565 articles
Browse latest View live