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

Database interface

$
0
0

@footcandles wrote:

Hi,

Can you guys share some advice for coding this kind of GUI? I want to create some custom assembly types with various layers that each have different material properties and dimensions.

I haven’t made something like this before. I think maybe I need to use windows forms “datagridview” but I don’t know how I can customize it to create sub items and dropdown trees within the grid view.

Ideally I’d be able to drag and drop things around as well, import export, etc.

Here are some examples. Generally a more sophisticated and customization user data interface that allows hierarchy.

image

Posts: 1

Participants: 1

Read full topic


Critical `RhinoList.Sort` function

Exec directory error ( .dll & .rhp confilct )

$
0
0

@oguzhankoral wrote:

Hi everyone,

When I try to lookup SampleCs files in GitHub in my Visual Studio 2019 Mac, I am getting error on the line:
<Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />

Screen Shot 2020-03-13 at 15.35.52
How can I solve this issue?

Thanks in advance,
-Oğuzhan

Posts: 1

Participants: 1

Read full topic

Plane translation

$
0
0

@Petras_Vestartas wrote:

Hi,

I have simple question about plane translations, why does the transformation in a list does not do anything:

  private void RunScript(object x, object y, ref object A)
  {
    List<Plane> planes = new List<Plane>();
    planes.Add(Plane.WorldXY);
    planes.Add(Plane.WorldXY);
    planes[0].Translate(new Vector3d(0,0,10)); //No effect

    A = planes;
  }

And this will do the job:

 private void RunScript(object x, object y, ref object A)
  {
    List<Plane> planes = new List<Plane>();
    planes.Add(Plane.WorldXY);
    planes.Add(Plane.WorldXY);
    planes[0].Translate(new Vector3d(0,0,10));

    Plane planeCopy = new Plane(planes[0]);
    planeCopy.Translate(new Vector3d(0,0,10));
    planes[0] = planeCopy;
    
    A = planes;
  }

Posts: 1

Participants: 1

Read full topic

Rhino C++ Plugin : Materials not showing up after exploding blocks in C++ plugin

$
0
0

@binigya wrote:

Hi,
So I am exporting Rhino models into another format.
I’m obtaining meshes using RhinoMeshObjects. So, whenever I explode some blocks in the model, and export it via my plugin, some of the exploded meshes do not have any material applied on them.
So does exploding a block instance change its material property?
Currently, I am using this code to get the material index (The materials themselves are being exported fine though):

        int GetMaterialIndex(CRhinoDoc& doc, const CRhinoObjectMesh& object_mesh, int default_material_index)
    {
    	char* name = GetNameFromONwStr(object_mesh.m_parent_object->Name());
    	if (name != nullptr)
    	{
    		::RhinoApp().Print("\nGetting the material index for object %s", name);
    	}
    	int material_index = -1;
    	int layer_index = -1;

	switch (object_mesh.m_mesh_attributes.MaterialSource())
	{
	case ON::material_from_object:
		::RhinoApp().Print("\nMaterial is from - OBJECT");
		material_index = object_mesh.m_mesh_attributes.m_material_index;
		break;

	case ON::material_from_layer:
		::RhinoApp().Print("\nMaterial is from - LAYER");
		layer_index = object_mesh.m_mesh_attributes.m_layer_index;
		material_index = doc.m_layer_table[layer_index].m_material_index;
		::RhinoApp().Print("\nMaterial Index is %d", material_index);
		break;

	case ON::material_from_parent:
	{
		::RhinoApp().Print("\nMaterial is from - PARENT");
		const CRhinoInstanceObject* iref_object = object_mesh.m_iref_object;
		if (iref_object)
		{
			switch (iref_object->Attributes().MaterialSource())
			{
			case ON::material_from_object:
				material_index = iref_object->Attributes().m_material_index;
				break;

			case ON::material_from_layer:
				layer_index = iref_object->Attributes().m_layer_index;
				material_index = doc.m_layer_table[layer_index].m_material_index;
				break;
			}
		}
	}
	break;

	default:
		::RhinoApp().Print("\n****NO MATERIAL IS FOUND FOR THIS OBJECT !!!!****");
		break;

	}
	if (material_index == -1)
	{
		return default_material_index;
	}
	else
	{
		return material_index;
	}

}

Posts: 1

Participants: 1

Read full topic

C# : How to attribute a new layer to an existing object?

$
0
0

@em.rudelle wrote:

Hi,
I’m having troubles to move an object to a new layer in C#. After searching a while, I noticed the following behavior : If I assign a new LayerIndex value to a BrepObject.Attributes, this value is not stored. See the following code :

_doc.Objects.Find(<A GUID>).Attributes.LayerIndex = <AN INTEGER, 21 for example>;
RhinoApp.WriteLine("Object on layer n°" + _doc.Objects.Find(<THE SAME GUID>).Attributes.LayerIndex.ToString());

So we set the LayerIndex to a fix value. But when asking back for it, the LayerIndex didn’t change. I precise that the layer with the tested index exists because the following code works for creating a brep on a specified layer :

_doc.Objects.AddBrep(myBrep, new ObjectAttributes() { LayerIndex = <AN INTEGER, 21 for example> };)

Any idea ?

Posts: 3

Participants: 2

Read full topic

List.Reverse() Does not work

$
0
0

@su.lwpac wrote:

Hi All,
I am trying to create a list and reverse the order of the list. but somehow the command returns error saying “1. Error (CS0029): Cannot implicitly convert type ‘void’ to ‘object’ (line 84)”.

Here is the Screenshot of the window:

Also here is the snippet of the Code:

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;

///


/// This class will be instantiated on demand by the Script component.
///

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

#region Members
///

Gets the current Rhino document.
private readonly RhinoDoc RhinoDocument;
/// Gets the Grasshopper document that owns this script.
private readonly GH_Document GrasshopperDocument;
/// Gets the Grasshopper script component that owns this script.
private readonly IGH_Component Component;
///
/// 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.
///

private readonly int Iteration;
#endregion

///


/// 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.
///

private void RunScript(double moduleDepth, int floorCount, List setbackFloors, List setbackValues, ref object A)
{

List<double> setbackLists = new List<double>();
List<double> rsetbackLists = new List<double>();

//Create Loop to Extract the FloorCounts
/*
for (int i = 0; i < setbackFloors.Count; i++)
{
for (int j = 0; j < setbackFloors[i]; j++)
{
double value = setbackValues[i];

setbackLists.Add(value);

}
}
*/

for (int i = 0; i < setbackValues.Count; i++)
{
  double newSetback = moduleDepth - setbackValues[i];
  Print(newSetback.ToString());
  setbackLists.Add(newSetback);
}

//rsetbackLists = setbackLists.Reverse();

A = setbackLists.Reverse(0, setbackLists.Count - 1);

}

Any idea why that is happening?

Posts: 3

Participants: 2

Read full topic

EXCEL to rhino


RenderLoadEnvironmentFromFile command not work in Rhino6

$
0
0

@Alen_Russ wrote:

Hello,

Does the commad “_RenderLoadEnvironmentFromFile” not work in rhino6 and wip?

and same as “_RenderSafeFrameOptions” command.

Posts: 1

Participants: 1

Read full topic

Obtaining knot values of control points

$
0
0

@kahasim wrote:

Dear Sir / Madame,

I’m new to Rhinoceros and interested in finite element analysis.

I need to obtain the knot values of the control points in my surface. Is there a way to get the knot values of a specific control point?, Is there a code which could give my selected control point’s corresponding knot values in u and v directions are, respectively as xi=1/3 , eta= 1/5

For example;

knotvector=rs.SurfaceKnots(surface) returns the knot values of the selected surface.

Could I write knotvalue=rs.ControlPointKnots(surface) to obtain the knotvalues of the control points in the surface ?

Best Regards,
Ahmet

Posts: 1

Participants: 1

Read full topic

TryFitCircleTTT Bug

$
0
0

@miquel_valverde wrote:

Hi,
I’ve been struggling to know what is causing TryFitCircleTTT to generate a Circle on top of the previous one I created.

I attatch the example scene and the command for you to test.

(It seems to happen only when I have aligned curves in some axis, for example, if I move up (z) the Second Curve 0.001 units, It will work as expected, and it creates a Circle next to the other).

TryFitCircle_Bug_ExampleScene.3dm (220.9 KB)

       public class TestTryFitCircleTTT : Command
{
    public override string EnglishName => "TestTryFitCircleTTT";

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        Curve curve1;
        Curve curve2;
        Curve curve3;

        var getCurve = new GetObject { GeometryAttributeFilter = GeometryAttributeFilter.OpenCurve | GeometryAttributeFilter.ClosedCurve };
        getCurve.SetCommandPrompt("Select 2 curves");
        var getCurvesResult = getCurve.GetMultiple(3,3);
        if (getCurvesResult != Rhino.Input.GetResult.Object)
            return Result.Cancel;
        getCurve.Objects()[0].Curve().TryGetCircle(out Circle circle);
        curve1 = getCurve.Objects()[0].Curve();
        curve2 =  getCurve.Objects()[1].Curve();
        curve3 =  getCurve.Objects()[2].Curve();

        double param1 = 3.1415926535897913;
        double param2 = 14.091276059207669;
        double param3 = 14.09127605920767;

        Circle outCircle = Circle.TryFitCircleTTT(curve1, curve2, curve3, param1, param2, param3);

        doc.Objects.AddCircle(outCircle);
        doc.Views.Redraw();

        return Result.Success;
    }
}

Posts: 4

Participants: 2

Read full topic

Language in batch not working without administrator rights

$
0
0

@ag1 wrote:

Hello, i try to let Rhino start with a little .bat file. The file only contains the following :
“C:\Program Files\Rhino 6\System\Rhino.exe” /nosplash /language=1031
When i run it in the administrator account, everything works just fine.
As soon as i log into another account without admin rights, the .bat only starts rhino in english.
This is kind of bad, since the english version has other parameters in the command line and some follow up scripts are not working anymore.

I hope you can help me.

Posts: 1

Participants: 1

Read full topic

Valid earthpoint?

$
0
0

@mgraham wrote:

I put this test in my code:
ON_EarthAnchorPoint earthPoint = doc.Properties().EarthAnchorPoint();
if (earthPoint.EarthCoordinateSystem() != ON::EarthCoordinateSystem::Unset)
{
ON_3dVector northVec = earthPoint.ModelNorth();
double lat = earthPoint.Latitude();
// and other code like this
}

but it always evaluates as earthPoint.EarthCoordinateSystem() == ON::EarthCoordinateSystem::Unset even when I have set an EarthAnchorPoint in Rhino.

If I simply retrieve the values, I do get back the values I set, but I don’t want garbage values if the EarthAnchorPoint has not been set. Is there another way to tell if my values are valid?

Posts: 2

Participants: 2

Read full topic

Rhino API Possibilities

Reducing the string Length of a Guuid

$
0
0

@BiljanaN wrote:

Hallo

I currently use ON_UuidToString to get string from ON_UUID.
But now I need to covert to base64string. If there is a way to get that from ON_UUID??

Posts: 2

Participants: 2

Read full topic


Eto NumericUpDownWithUnitParsing controls value change behaviour

$
0
0

@marton.parlagh wrote:

I would like to make my Eto controls work similarly to standard Rhino controls.

Which means:
user changes the value and accepts it by pressing enter or by pressing escape he/she can cancel the change.
I use the NumericUpDownWithUnitParsing controls. Can I achieve something similar?

There is an update mode for the control which can be changed, for example
NumericUpDownWithUnitParsingUpdateMode.OnEnterOrLoseFocus

but it is not the same, doesn’t react for enter or esc. I have tried to add this extra manually, but I can not force commit or cancel the change.

Also the right side arrows for these steppers are only steppers. Is there an easy way to make these similar to Rhino controls where the user can drag these and change the values more interactively?

Thank you,
Márton

Posts: 4

Participants: 2

Read full topic

(De-) Serialize between Rhino3dmIO and RhinoCommon problem

$
0
0

@atair wrote:

Lets say i create a PolylineCurve in Visual Studio and Rhino3dmIO and pack it in a binary stream, send it to Rhino and want to deserialize it back to a PolylineCurve. This does not work as they are from different a assembly (Rhino3dmIO and RhinoCommon respectively)

What would be the best way to go about that? It should work with all kinds of geometry…
thanks!

difference as string here:

Posts: 5

Participants: 3

Read full topic

Eto: Control Element Resizing?

$
0
0

@ed.p.may wrote:

Hi,

I have a sample Eto I’m working on and having trouble understanding how to control element resizing? A super simplified version of the code (python) I have currently is:

import Eto
import Rhino

class Dialog_Example(Eto.Forms.Dialog):
    
    def OnButton01Click(self, sender, e):
        print('Button 01')
    
    def OnButton02Click(elf, sender, e):
        print('Button 02')
    
    def __init__(self):
        self.Title = "My Sample Window"
        self.Resizable = True
        self.Padding = Eto.Drawing.Padding(5) # Seems not to affect anything?
        
        # Create some Controls for the Dialog
        self.m_txtBox = Eto.Forms.TextBox( Text = 'Example')
        self.m_txtBox.Width = 300
        
        self.m_Button01 = Eto.Forms.Button(Text = 'Button 01')
        self.m_Button01.Click += self.OnButton01Click
        self.m_Button01.Size = Eto.Drawing.Size(100,25)
        
        self.m_Button02 = Eto.Forms.Button(Text = 'Button 02')
        self.m_Button02.Click += self.OnButton02Click
        self.m_Button02.Size = Eto.Drawing.Size(100,25)
        
        # Layout
        layout = Eto.Forms.DynamicLayout()
        
        # Group: Main Group
        self.groupbox_Main = Eto.Forms.GroupBox(Text = 'My First Group')
        layout_Group_01 = Eto.Forms.DynamicLayout()
        layout_Group_01.AddRow(self.m_txtBox, self.m_Button01, self.m_Button02)
        self.groupbox_Main.Content = layout_Group_01
        layout.Add(self.groupbox_Main)
        
        # Set the dialog window Content
        self.Content = layout

# Call the Dialog Window
dialog = Dialog_Example()
rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)

So that works fine, and gives me as I’d expect:

but when I resize it, only the last button ‘stretches’ to fill horizontally and all three elements stretch to fill vertically:

If I wanted to allow the overall window to be resized, but tell the elements inside to stay constant size (no stretch) is there a way to do that?

Alternately, if I wanted to tell it to keep only the buttons constant size, but allow the text-box to stretch, is there a technique to do that in a case like this?

Any input is much appreciated!

thanks,
@ed.p.may

Posts: 1

Participants: 1

Read full topic

Dialog position storing

$
0
0

@dsw wrote:

Hi,

during an update of my plugin i got the feedback that the positions of the panels are reset. So i was wondering where and how the positions are stored and found something alarming.
All the positions are stored in a file “window_positions-Scheme__Default.xml” but the key for every dialog consists of the UUID of the plugin, the internal dialog resource ID and the caption.

So in my case due to merging of code and also during rework i changed my internal resource ID and on some dialogs (floating dialogs, no panels) i change the caption too.

My question: is there a way i can give the under-laying SDK somehow another unique key which will be used to store the dialog settings?

Thanks

Posts: 1

Participants: 1

Read full topic

System.AccessViolationException when reading doc.RenderMaterials[]

$
0
0

@seppeldue wrote:

Hi,

i get a ‘System.AccessViolationException’ when i run the plugin, accessing doc.RenderMaterials[0] for the SECOND time. First time works.
Also when running the plugin once with multibe objects selected, no problem.
There is not much documentation on RenderMaterials …
Hope someone can help. Thanks.

       if (objRm == null)
                {
                    
                    obj.RenderMaterial = doc.RenderMaterials[0];
                    obj.CommitChanges();
                    obj.Attributes.MaterialIndex = findsRM;
                    obj.CommitChanges();
                }

full code:

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject();
        go.SetCommandPrompt("Select objects to apply 18ct red gold");
        go.GroupSelect = true;
        go.SubObjectSelect = false;
        go.EnableClearObjectsOnEntry(false);
        go.EnableUnselectObjectsOnExit(false);
        go.DeselectAllBeforePostSelect = false;
        go.GetMultiple(1, 0);

        int findsRM = doc.Materials.Find("18ct red gold", true);

        for (int i = 0; i < go.ObjectCount; i++)
        {
            
            Rhino.DocObjects.ObjRef objref = go.Object(i);
            Rhino.DocObjects.RhinoObject obj = objref.Object();

            if (findsRM == -1)
            {
                Rhino.DocObjects.Material rg18ct = new Rhino.DocObjects.Material();
                rg18ct.Reflectivity = 1;
                rg18ct.ReflectionColor = System.Drawing.Color.FromArgb(255, 187, 132);
                string rg18ctName = "18ct red gold";
                rg18ct.Name = rg18ctName;
                rg18ct.CommitChanges();
                var idrg18 = doc.Materials.Add(rg18ct);

                var rmrg18 = Rhino.Render.RenderMaterial.CreateBasicMaterial(doc.Materials[idrg18]);
                doc.RenderMaterials.Add(rmrg18);
                obj.RenderMaterial = rmrg18;
                obj.CommitChanges();
            }
            else
            {
                var objRm = obj.RenderMaterial;

                if (objRm == null)
                {
                    
                    obj.RenderMaterial = doc.RenderMaterials[0];
                    obj.CommitChanges();
                    obj.Attributes.MaterialIndex = findsRM;
                    obj.CommitChanges();
                }
                else
                {
                    obj.Attributes.MaterialIndex = findsRM;
                    obj.CommitChanges();
                }
            }
        }
        doc.Views.Redraw();
        return Result.Success;
    }
}

Posts: 1

Participants: 1

Read full topic

Viewing all 8573 articles
Browse latest View live