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

Change gamma from python


BlockEdit directly to a nested instance

$
0
0

@spb wrote:

Is there a way to start BlockEdit directly to a nested instance via RhinoCommon?

Posts: 1

Participants: 1

Read full topic

rs.Command in class? [Solved]

$
0
0

@onrender wrote:

Hi, I am working on a simple script in python that will produce a slab and I got a strange result when I put the

rs.Command("_Dir SelID " + str(surface2)+ " _Enter Flip _Enter ") line

in the class.

The script could not reach the surface2 GUID but gives a partial multi rows message with errors:

First row is also strange: as sais “Wall thickness: _Dir”. Wall thickness occurs in the main object only when I give the input, but not in the class.

[7ce0e3e7-6b89-43ee-8cb6-f7cc3759e1d9]>] is actually surface2 that I want to process.

Wall thickness: _Dir
Select objects for direction display: SelID[<System.Guid
Unknown command: SelID[<System.Guid
Select objects for direction display: object
Unknown command: object
Select objects for direction display: at
Unknown command: at
Select objects for direction display: 0x000000000000005D
Unknown command: 0x000000000000005D
Select objects for direction display: [7ce0e3e7-6b89-43ee-8cb6-f7cc3759e1d9]>]_Enter
Unknown command: [7ce0e3e7-6b89-43ee-8cb6-f7cc3759e1d9]>]_Enter
Select objects for direction display: Flip
Select objects for direction display: _Enter

Posts: 4

Participants: 2

Read full topic

Debugging Eto Forms in separate project

$
0
0

@timkado wrote:

Hi - I am working on an EtoFroms UI for a Rhino plugin. I do the majority of debugging outside of Rhino to avoid the load times. I have a separate project set up that just displays the forms and references Rhino’s Eto and Eto Wpf dlls.
With SR19 I am getting the following error:
System.IO.FileNotFoundException: ‘Could not load file or assembly ‘Eto, Version=2.5.0.0, Culture=neutral, PublicKeyToken=552281e97c755530’ or one of its dependencies. The system cannot find the file specified.’
I am not quite sure what is causing this. Any help appreciated.

Posts: 1

Participants: 1

Read full topic

Developer Docs page broken

Run a command within a headless RhinoDoc

$
0
0

@pgs wrote:

By using Rhino inside CPython I have created a new headless RhinoDoc. Do anyone know how to execute a command within this RhinoDoc? For example something simple like ‘_-Line 0,0,0 10,0,0’?

Pål

Posts: 1

Participants: 1

Read full topic

How to speed up copying mesh faces in C++ API vs Python + Rhinocommon

$
0
0

@Terry_Chappell wrote:

@dale, @stevebaer,

I am trying to improve the performance of my Python script by moving the Python code below, which creates several meshes, into a C++ API DLL.

faces = meshGeo.Faces
# Make .NET List of all faces to use in AddFaces below.
facesL = List[MeshFace](nvert)
# Add all faces from unified mesh to .NET List for quick access using GetRange.
facesL.AddRange(faces)
lower_index = 0
# Make duplicate mesh without faces.
dmesh = meshGeo.DuplicateMesh()
dmesh.Faces.Clear()
last_index = upper_face_index[-1][0]
for upper_index, name in upper_face_index:
	# If not last mesh, duplicate the no-faces mesh.
	if upper_index != last_index: next_meshGeo = dmesh.DuplicateMesh()
	# Use dmesh when making the last mesh.
	else: next_meshGeo = dmesh
	# Copy over the faces used in this mesh.
	next_meshGeo.Faces.AddFaces(facesL.GetRange(lower_index, upper_index - lower_index))
	# Use upper_index for lower limit in next range.
	lower_index = upper_index
	# Compact the mesh to remove unused vertices, colors, textures and normals.
	next_meshGeo.Compact()
	# Add mesh to document.
	doc.Objects.AddMesh(next_meshGeo)

The corresponding C++ API code is:

DLLEXPORT void make_meshes(uint32_t doc_serial_number, uint32_t mesh_serial_number, uint32_t nmi, int32_t* upper_face_indices, uint32_t* mesh_serial_numbers) {
	// Get doc from RuntimeSerialNumber passed as uint_32_t.
	CRhinoDoc* pDoc = CRhinoDoc::FromRuntimeSerialNumber(doc_serial_number);
	const CRhinoObject* obj = pDoc->LookupObjectByRuntimeSerialNumber(mesh_serial_number);
	const ON_Mesh* mesh = ON_Mesh::Cast(obj->Geometry());
	// Make new meshes.
	int lower_index = 0;
	// Duplicate mesh.
	ON_Mesh dmesh(*mesh);
	// Remove all faces.
	dmesh.DeleteComponent(ON_COMPONENT_INDEX(ON_COMPONENT_INDEX::mesh_face, 14));
	// Get index of last face.
	int32_t last_index = upper_face_indices[nmi-1];
	for (int i = 0; i < nmi; ++i) {
		// Get upper face index for this mesh.
		int upper_index = upper_face_indices[i];
		// Find number of faces in this mesh.
		int num = upper_index - lower_index;
		// If not last mesh, duplicate the no-faces mesh.
		if (upper_index != last_index) {
			// Duplicate no-faces mesh.
			ON_Mesh new_mesh(dmesh);
			// Set capacity of new mesh.  Without this, face copying is 30% slower.
			new_mesh.m_F.SetCapacity(num);
			// Copy over faces used in this mesh.
			for (int j = 0; j < num; ++j) {
				new_mesh.m_F[j] = mesh->m_F[lower_index + j];
			}
			new_mesh.Compact();
			// Add new mesh to Rhino document.
			CRhinoMeshObject* meshObject = pDoc->AddMeshObject(new_mesh);
			mesh_serial_numbers[i] = meshObject ? meshObject->RuntimeSerialNumber() : 0;
			// Use upper_index for lower limit in next range.
			lower_index = upper_index;
		}

The slow C++ part is where the old faces are copied into the new_mesh:

for (int j = 0; j < num; ++j) { new_mesh.m_F[j] = mesh->m_F[lower_index + j]; }

In Python this is done using the higher performance .NET List instead of a Python list:

next_meshGeo.Faces.AddFaces(facesL.GetRange(lower_index,upper_index-lower_index))

The Python+.NET+Rhinocommon code is 50% faster. Is there a way to do this faster in the C++ API?

I have moved several blocks of Python code that talk to Rhino into a C++ API DLL and seen significant speed up. But not in this case. Is it simply that a .NET List is faster than a C++ API ON_SimpleArray for copy operations? Or is the Rhinocommon meshGeo.Faces.AddFaces(IEnumerable) procedure faster than looping thru: new_mesh.m_F[i] = mesh->m_F[lower_index+j];. Since only a subset of the faces are being copied, I do not see a way to use the possibly more efficient C++ option of:
new_mesh.m_F.Append(num, mesh->m_F.Array()) to perform the copy.

Regards,
Terry.

Posts: 2

Participants: 2

Read full topic

Rhino3D creators

$
0
0

@reuben.alfred wrote:

Rhino3D creators have got almost everything I have looked into, from a developer’s perspective, right!!

A clean framework, good documentation, and samples!

Samples should only have the minimum number of lines required to illustrate a concept. The R3D samples are just that!

Well done guys and a big thank you! :wink:

Posts: 2

Participants: 2

Read full topic


The method AddRhinoObject with param CustomCurveObject is missing

Hiding R3D UI Elements

Automatic Seam positioning

$
0
0

@miquel_valverde wrote:

Hello,

When I perform a Sweep1 operation, rhino lets you specify seam positions of the two profiles: Natural or Automatic.
I’m wondering how does the Automatic Seam position actually work internally.

Thanks if someone can provide information on this.

Miquel

Posts: 1

Participants: 1

Read full topic

Delete Group Items of ComboBox in Rhino

$
0
0

@bram.kohlen wrote:

Hello,

I am working on a plug in for Rhino. So far I have, among other things, created a RhinoOptionsControl and put a combo box (CRhinoUiOptionsListCtrlGroupComboBox) in it. I have added some items to it and all seems to work well. Now I need to dynamically add and delete items to the combo box, however I have found no way yet to remove items from it. Is there any way to do this?
So far I have tried deleting items using classes of the CComboBox parent class which does not work and rebuilding the entire GUI when something changes which is quite slow.
Is there any way to do this? Thank you in advance.

Posts: 1

Participants: 1

Read full topic

Parsing XML in GH Python Script Editor?

$
0
0

@robe5177 wrote:

Tried to implement this in R5: https://docs.python.org/2/library/xml.etree.elementtree.html

to read and process http://www.canals.ny.gov/xml/liftbridges.xml

Code would be:
import xml.etree.ElementTree as ET
tree = ET.parse(‘country_data.xml’)
root = tree.getroot()

error: 1. Solution exception:expected str, got DataTree[object]

then tried:

from xml.etree import ElementTree # part of python distribution
from elementtree import SimpleXMLTreeBuilder # part of your codebase
ElementTree.XMLTreeBuilder = SimpleXMLTreeBuilder.TreeBuilder

with this error:

  1. Solution exception:No module named elementtree

gHowl has an xml parser to obtain the info, challenge is breaking it up into usable formats.

Referred to this example: https://discourse.mcneel.com/t/access-xml-data/1346/10

Wrote ths with y being the xml file path:
filename = y
xmldoc = System.Xml.XmlDocument()
xmldoc.Load(filename)
items = xmldoc.SelectNodes(“liftbridges/mile/”)
for item in items:
print item.InnerText

Not sure on best way to access it…

Posts: 2

Participants: 2

Read full topic

Eto: pass mouse wheel event from GridView to parent Scrollable

$
0
0

@Jon wrote:

Hello Eto experts,

I have a GridView nested in a Scrollable control. By default, when the GridView contains the cursor, it handles mouse-wheel events. That is, it blocks its parent container from scrolling. Is there a way to prevent this? I want the parent to scroll with the mouse wheel, never the grid.

Thanks,

Jon

Posts: 1

Participants: 1

Read full topic

Panel generator bug

$
0
0

@daniel.depoe wrote:

Hello,

Please see C# command, created as part of the Programming Architecture C# plugin course I’m following.

The command is meant to prompt the user to select 4 points, then 20 panels are distributed at random angles, marked with text dots, and a parent (and 2 sublayers) are meant to be generated. I’ve done my best to go through the videos again, but I cant’ find the problem. I had the command working fine, but now it’s only generating the parent layer “L” and is exiting the command.

Any help would be appreciated.

Thanks,

Dan

Posts: 4

Participants: 2

Read full topic


Automatic Seam positioning

$
0
0

@miquel_valverde wrote:

Hello,

When I perform a Sweep1 operation, rhino lets you specify seam positions of the two profiles: Natural or Automatic.
I’m wondering how does the Automatic Seam position actually work internally.

Thanks if someone can provide information on this.

Miquel

Posts: 2

Participants: 2

Read full topic

Is RhinoCommon still Open Source?

Add geometry to list

$
0
0

@j.deboer wrote:

Hi All,

For a project, I want to add grasshopper rectangles after each click on the button in my user interface (Blue circle). Now, with a loop I can add multiple rectangles to a list in a while loop, until the user puts it to stop by typing “N” (in green).

However, this program only shows all rectangles after the loop has stopped. Is there also a way to create a rectangle at each click on the button, and after the python component add this new rectangle to a list of already created ones?

Hope to hear from you, thanks for your help!

JS

Code:

sc.doc = ghdoc

corridors = []
stop = False
while stop == False:
    
    plane = rs.WorldXYPlane()
    Rhino.RhinoApp.ReleaseMouseCapture()
    x1 = rs.GetPoint("Select first point of corridor")
    print(x1) # Tip: print(...)
    x2 = rs.GetPoint("Select second point of corridor")
    print(x2)
    Rhino.RhinoApp.ReleaseMouseCapture()
    rs.Redraw()
    corridors.append(rs.AddRectangle(plane,x1,x2))
    
    more_corridors = rs.GetString("more corridors? (if yes type 'Y', if no type 'N')") 
    if more_corridors == 'Y' or more_corridors == 'y':
        continue
    else:
        stop = True

Posts: 1

Participants: 1

Read full topic

Programmatically created material doesn't show up

$
0
0

@aske wrote:

The example https://developer.rhino3d.com/samples/rhinocommon/add-material/ shows how to programmatically create materials. It works, as-is, however if you omit assigning the material to the sphere, it doesn’t work (on Mac, haven’t tried Windows). The material never shows up in the materials list. The material is added to the table, so I would expect it to stay there until it’s removed/deleted. Did I miss something in how materials work in Rhino?

partial class Examples
{
  public static Rhino.Commands.Result AddMaterial(Rhino.RhinoDoc doc)
  {
    // materials are stored in the document's material table
    int index = doc.Materials.Add();
    Rhino.DocObjects.Material mat = doc.Materials[index];
    mat.DiffuseColor = System.Drawing.Color.Chocolate;
    mat.SpecularColor = System.Drawing.Color.CadetBlue;
    mat.CommitChanges();

    // set up object attributes to say they use a specific material
    // Rhino.Geometry.Sphere sp = new Rhino.Geometry.Sphere(Rhino.Geometry.Plane.WorldXY, 5);
    // Rhino.DocObjects.ObjectAttributes attr = new Rhino.DocObjects.ObjectAttributes();
    // attr.MaterialIndex = index;
    // attr.MaterialSource = Rhino.DocObjects.ObjectMaterialSource.MaterialFromObject;
    // doc.Objects.AddSphere(sp, attr);

    // add a sphere without the material attributes set
    // sp.Center = new Rhino.Geometry.Point3d(10, 10, 0);
    // doc.Objects.AddSphere(sp);

    doc.Views.Redraw();
    return Rhino.Commands.Result.Success;
  }
}

Posts: 1

Participants: 1

Read full topic

Replace Gumball

$
0
0

@reuben.alfred wrote:

Is it possible to override the gumball with an alternative one or at least to align the rotation arcs with their respective axes?

Posts: 1

Participants: 1

Read full topic

Viewing all 8524 articles
Browse latest View live