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

How to get vertices of mesh edges

$
0
0

@gennaro wrote:

Hi everybody,

I need to know hot to get the vertices of a selected mesh edge. Although it seems an easy task I could not get them. I made an attempt but the indices of the selected edge and the mesh topology edge seem not to match…

CRhinoObjectIterator it(CRhinoObjectIterator::undeleted_objects, CRhinoObjectIterator::active_and_reference_objects);
	it.EnableVisibleFilter(TRUE);
	for (CRhinoObject* pObject = it.First(); pObject; pObject = it.Next()) {
		ON_SimpleArray<ON_COMPONENT_INDEX> subidxs;
		pObject->GetSelectedSubObjects(subidxs);
		for(int su = 0; su < subidxs.Count(); su++)
		if (subidxs[su].m_type == ON_COMPONENT_INDEX::meshtop_edge) {
			const ON_Mesh* mesh = ON_Mesh::Cast(pObject->Geometry());
			ON_SimpleArray<ON_2dex> edges;
			mesh->GetMeshEdges(edges);
			ON_3dPoint vert1 = mesh->m_V[edges[subidxs[su].m_index].i];
			ON_3dPoint vert2 = mesh->m_V[edges[subidxs[su].m_index].j];
			ON_Line line(vert1, vert2);
			CRhinoCurveObject* curve_object = context.m_doc.AddCurveObject(line);
			context.m_doc.Redraw();
		}
	}

Posts: 1

Participants: 1

Read full topic


Use of Layers.Modify?

$
0
0

@S_L wrote:

I’m wondering what the use of Layers.Modify is-- it doesn’t seem to be necessary in this case, for instance (changing a layer’s color in python):

import System.Drawing as sd
from scriptcontext import doc

def add_layer(name,color):
	myLayer = name
	layerInd = doc.Layers.Find(myLayer,False)
	if layerInd == -1:
		layerInd= doc.Layers.Add(myLayer,color)
	return layerInd

if __name__ == "__main__":
	layerInd = add_layer("TEST",sd.Color.Black)
	print layerInd
	layer = doc.Layers[layerInd]
	layer.Color = sd.Color.Lime
	#doc.Layers.Modify(layer,layer.LayerIndex,True)

If you uncomment the last line the code will run just fine, but I’d like to know in what cases Modify is desirable.

Posts: 1

Participants: 1

Read full topic

C++ How to delete the object have write in 3dm file?

$
0
0

@pythonuser wrote:

Hi;
I write a mesh into 3dm file by this core:

static bool write( const wchar_t* file_path, int version, ON_Mesh mesh )
{
	if(mesh.IsValid())
	{
		ON::Begin();
		FILE* archive_fp = ON::OpenFile( file_path, L"wb");
		ON_BinaryFile archive( ON::write3dm, archive_fp );
		ON_WriteOneObjectArchive( archive, version, mesh );
		ON::CloseFile(archive_fp);
		ON::End();
	}
    return 1;
}

After I read the file and get the mesh, how cant I delete the object data have write?

Posts: 1

Participants: 1

Read full topic

How can I import Tkinter in Python.Script?

$
0
0

@javiervg84 wrote:

I am trying to do this:

from tkinter import *

but I recieve this message:

Message: No module named tkinter

Traceback:
line 2, in , “C:\Users\jvarona\AppData\Local\Temp\TempScript.py”

Can anyone help me?

Thank you.

Posts: 1

Participants: 1

Read full topic

RS V6 regression: compiled scripts fail to run other scripts from Rhino.Command

$
0
0

@Jarek wrote:

Hi,

Switching recently our production to Rhino 6 I have encountered a major drawback compared to V5 (and earlier versions):

For some reason, compiled scripts would not run either scripts via -_RunScript() or compiled script commands, from Rhino.Command function. Please note there is no problem if the main calling script runs from ScriptEditor.

This is a big problem since a lot of our in-house tools and some of my publicly released plugins rely on this functionality working (including those literally used every 5 minutes that deal with view manipulations, used in-command of other, more complex tools.)

I realize the above may sound a bit confusing, so I have prepared simple examples to test (all should work fine in V5, not at all in V6):


Please install this compiled RhinoScript test plugin:
GetStringPassCommandTest.rhp (8.5 KB)

It has 2 very simple script commands:

  1. GetStringPassCommandTest : this one actually tests the above problem and would try to run other scripts/commands in its runtime
  2. TestCompiledScriptCommand : sample message box - an abstract script/command that doesn’t work (as all others non-Rhino commands)

Here are the actual scripts used to compile the above plugin:
GetStringPassCommandTest.rvb (813 Bytes)
TestCompiledScriptCommand.rvb (300 Bytes)

Things to try:

  1. Install the test plugin (in V5 and V6)
  2. run GetStringPassCommandTest
  3. from here, any native Rhino command should run “inside” this command prompt (try: _Box)
  4. pick “TestCompiledScriptCommand” command-line option - it will attempt to pass this string as command name to Rhino.Command inside the “GetStringPassCommandTest” plugin.
    In Rhino 5 message box will show (command runs, no problem), in V6 nothing happens.

Also:

  1. Try putting the source of “TestCompiledScriptCommand.rvb” on toolbar button inside -_RunScript (… )
  2. run GetStringPassCommandTest command, and try clicking the button while in prompt: in V5 all works OK (message box), in V6 I can only see “RunScript” passed to CommandLine, and nothing happens.

Finally:

  1. open the “GetStringPassCommandTest.rvb” in RhinoScript Editor, and run it
  2. the button should work OK inside the script prompt (V5 and V6), also, the compiled command “TestCompiledScriptCommand” should also work OK inside the script prompt (V5 and V6).

So - clearly in V6 there is an issue preventing compiled script commands running other scripted commands or _-RunScript()s in their runtime. I guess this is not the compiler problem since in V5 all works OK, but something broke in the way V6 handles this situation.

This is another show-stopper for the V6 production switch over here.
Hope someone can help to fix it! (@Pascal - any volunteers? :wink: )

Thank you,

–jarek

Posts: 1

Participants: 1

Read full topic

Point tolerance

$
0
0

@onrender wrote:

Hi there,

I am having an issue that I did not realize before that Rhino has a point tolerance. It concluded that points;

-5.26930645920454,6.6957560903893,0 and
-5.26930645920482,6.6957560903894,0

are not the same. The first coordinate came from a CurveCurveIntersection and the second came from the end point of the curve. Basically I try to compare the end of the curve (that made the instersection with the curve) and the intersection. Is it possible that I got this result?

Posts: 1

Participants: 1

Read full topic

Trouble migrating Custom Grips to Rhino 6 C++

$
0
0

@pagarcia wrote:

Hello,

After migrating my custom grips plug-in into Rhino 6, I find the following problems:

  1. When enabling grips, the owner object keeps being on the scene, which makes it difficult to select grips as there’s continuously interference with it when picking. In Rhino 5 there was no issue with this as the owner object somehow “disappeared” as a pick option when enabling grips.

  2. When moving grips, the owner object is never transformed (I think m_bNewLocation flag is always set to false).

  1. From time to time there’s a crash when moving a grip.

I have these very same 3 problems in @dale 's example SampleCustomGrips. Still, cannot find the real change from 5 to 6 that causes the issue. Any idea?

Many thanks,
Pablo

Posts: 1

Participants: 1

Read full topic

How can use rhinoscriptsyntax in a plugin?

$
0
0

@javiervg84 wrote:

Hi everybody,

I am trying to use rhinoscriptsyntax as (rhino.getobejct, rhino.addpoint , rhino.istext, etc) in a plugin develop in Visual Studio.

How can I do this?

Thank you

Posts: 1

Participants: 1

Read full topic


RhinoCommon Transofrm.Scale() bug

$
0
0

@henrydm wrote:

Hello there,

I found what I think is a bug in the SDK scaling some poly curves, the error happens only scaling using different factors per axis:

Transform.Scale(plane,2,1,1) generate disconnected curves

Scaling by SDK like Transform.Scale(plane,2,2,2) or scaling in design using Gumballs or Scale1D, Scale2D or Scale commands also works fine, although if you scale it using gumball and scale back to the original size, using the SDK Scale() method also works fine

Here a video showing the bug

Here the example project:
ScaleProblemExample.zip (294.0 KB)

Here the 3dm with a lot of curves that fail:
ScaleCurveError.3dm (128.2 KB)

Posts: 2

Participants: 2

Read full topic

Split mesh in c++

$
0
0

@pythonuser wrote:

Hi;


I want to split the mesh like the MeshSplit Tool in c++, but I try this core:
    CRhinoGetObject go;
	go.SetCommandPrompt( L"select first mesh" );
	go.SetGeometryFilter(CRhinoGetObject::mesh_object);
	go.EnablePreSelect(FALSE);
	go.EnableSubObjectSelect( FALSE );
	go.EnableGroupSelect(TRUE);
	go.GetObjects( 1, 0 );
	int i, object_count = go.ObjectCount();
	ON_SimpleArray<const ON_Mesh*> InMeshes0;
	for( i = 0; i < object_count; i++ )
	{
	  InMeshes0.Append(go.Object(i).Mesh());
	}
	
	CRhinoGetObject go1;
	go1.SetCommandPrompt( L"select other mesh" );
	go1.SetGeometryFilter(CRhinoGetObject::mesh_object);
	go1.EnablePreSelect(FALSE);
	go1.EnableSubObjectSelect( FALSE );
	go.EnablePreSelect(false);
	go1.EnableGroupSelect(TRUE);
	go1.GetObjects( 1, 0 );
	int object_count1 = go1.ObjectCount();
	ON_SimpleArray<const ON_Mesh*> InMeshes1;
	for( i = 0; i < object_count1; i++ )
	{
	  InMeshes1.Append(go1.Object(i).Mesh());
	}
	
	double intersection_tolerance = ON_SQRT_EPSILON * 10;
	double overlap_tolerance = ON_SQRT_EPSILON * 10;
	ON_SimpleArray<ON_Mesh*> OutMeshes;
	bool bSomethingHappened = false;

	bool rc = RhinoMeshBooleanSplit(InMeshes0,InMeshes1,intersection_tolerance,overlap_tolerance,&bSomethingHappened,OutMeshes);
	ON_Mesh out_mesh;
	for(i = 0; i < OutMeshes.Count(); i++ )
	{
		RhinoApp().ActiveDoc()->AddMeshObject(*OutMeshes[i]);
	}
	RhinoApp().ActiveView()->Redraw();
	return CRhinoCommand::success;

But the result is:


It just like the RhinoMeshBooleanIntersection, how can I do that ?

Posts: 1

Participants: 1

Read full topic

Sort points in optional coordinates

$
0
0

@Amir_Habibi wrote:

Hi I tried using the method Sort() for sorting a bunch of points but it first attempts to sort points in x direction , then in y and at last in z . my intention would be to sort them optionally (e.g. first z , then x , then y). Any tips ?

Posts: 4

Participants: 3

Read full topic

What happens to Custom Objects on Save?

$
0
0

@lando.schumpich wrote:

Hello i have another question regarding Custom Objects.

When a 3dm file containing custom objects gets saved, all of them get converted in some way (CustomBrepObject becomes BrepObject, CustomCurveObject becomes CurveObject etc.) Can someone explain how this process is happening and what can be changed about it?

For example in my current case i have UserData attached to my CustomObjects and while this userdata survives saving and reopening on “normal” objects, the custom object gets stripped of the userdata. I am following this example which works up to the point where custom objects come into play.

Maybe there is something to override or an event to subscribe to, so i can attach my userdata to those automatic replacement objects and get it saved in the doc.

Thanks for any help

Posts: 1

Participants: 1

Read full topic

V6 problem with setting cursor in prompt

$
0
0

@clement wrote:

Hi @dale,

i set my cursor in a Rhino.Input.Custom.GetTransform prompt like this:

self.SetCursor(System.Windows.Forms.Cursors.Arrow)

which works in V5, but in V6 i receive a type error:

TypeError: expected CursorStyle, got Cursor

I cannot find anything about CursorStyle. Is this a bug in V6 ?

_
c.

Posts: 1

Participants: 1

Read full topic

C++ pch and stadfx importing simple library to Rhino Plugin project

$
0
0

@Petras_Vestartas wrote:

Hi,

I have issue with precompiled headers “pch.h” and “stadfx”

In console application I have a simple library that calls pch.h math methods such as “min” , “max” and etc.
It builds and runs good.

When I open Rhino C++ plugin template and add this library (it is only 1 header and 1 source file) it complains about those min max methods used int pch.h.
I tried to change pch.h to stadfx.h since it is more or less the same thing. But not, because I get errors while building the project.

I attached the console application with source code of .h and .cpp files that runs correctly.
Could someone give a hint how to add this library to rhino plugin to solve occuring errors?

Project file:
https://1drv.ms/u/s!AnwaB50XU22ei-pjxTzRFr2Z1mzkZg

Posts: 4

Participants: 2

Read full topic

C# Brep.CreateOffsetBrep(...) return empty Array

$
0
0

@atelierholder wrote:

I allways get an empty Brep array if i try to:

Brep u = surface.CreateExtrusion(line, true);
Brep[] bigger_u = Brep.CreateOffsetBrep(u, 0.2, true, true, doc.ModelAbsoluteTolerance, out var test1, out var test2);

test1 and test2 are null.

The Brep u is an simple Object like a straight tube or a straight cylinder and if i use the OffsetSrf command inside Rhino the command success without problems.

As i understand the documation souldnt the command return always some kind of breps and/or brepfaces?

Posts: 1

Participants: 1

Read full topic


Methodgen help

$
0
0

@tommaso_casucci wrote:

Hi all,

I am trying to wrap a C++ library to be used in C# using Methodgen as described by Giulio here:


but I have some problems to have methodgen work.

Any chance to get a sample project to look at?

Thank you in advance,
T

Posts: 1

Participants: 1

Read full topic

Create preview images of geometry

$
0
0

@dsw wrote:

Hi

i want to create preview images of geometry which is not yet in the document.
For this i tried to use the code below but i do not see the brep i have drawn with DrawShadedBrep, only those who are in the document.
So is there a way do make preview images like this, but for geometry which was not yet added to the document?

			CRhinoView* view = RhinoApp().ActiveView();
			CRhinoDisplayPipeline* dp = view->ActiveViewport().DisplayPipeline();
			const CDisplayPipelineAttributes* pDA = CRhinoDisplayAttrsMgr::StdShadedAttrs();

			CRhinoDib dib;
			dib.CreateDib(200, 200, 24, true);

			CDisplayPipelineAttributes da(*pDA);
			da.m_bUseDocumentGrid = false;
			da.m_bDrawGrid = true;
			da.m_bDrawAxes = true;
			da.m_bDrawWorldAxes = true;
			da.m_bCastShadows = false;
			da.m_pIteratorOverride = NULL;

			dp->DrawShadedBrep(*brep);
			bool res = dp->DrawToDib(dib, 200, 200, &da);

			dib.WriteToFile(L"c:\\temp\\test.png");

Posts: 1

Participants: 1

Read full topic

Object change tracking and rebuild case

$
0
0

@D-W wrote:

How i can know when existing object will lose current id - i mean i have issue when after rebuild command i cannot track further object because it has changed id. Any remedy @dale ?

Posts: 2

Participants: 2

Read full topic

World axes visible in layout view

$
0
0

@ollie.sanders wrote:

Hi All,

I’m wanting to show the world axis in a detail view which is not active.

Not sure this is a developer issue but I’ve struggled to find a simple way of doing this and think that maybe its only achievable using a display conduit.

Thanks

Ollie

Posts: 1

Participants: 1

Read full topic

Hacktoberfest: Contribute to open source projects!

$
0
0

@fraguada wrote:

Dear developers and anyone who wants to contribute to open source,
It’s Hacktoberfest! Hacktoberfest is an event organized by Github, Digital Ocean, and Twilio each October to promote contribution to open source projects. It is a great time to find a project you are interested in and see how you can get involved. It is also a great time for people who haven’t contributed to an open source project to get started.
If you want some ideas, we have a lot of open source projects! Here are some that might be of interest:

  • OpenNURBS (C++, C) - OpenNURBS libraries allow anyone to read and write the 3DM file format without the need for Rhino.
  • rhinoscriptsyntax (Python) - library for Python scripting engine that runs on both the Windows and OSX Rhino as well as Grasshopper
  • GhPython (C#, Python) - A Grasshopper component for Rhino.Python
  • compute.rhino3d (C#) - REST geometry server based on RhinoCommon and headless Rhino
  • rhino.inside samples - Sample Projects for Rhino.Inside
  • RhinoVR (C++, C) - a Rhino 6 virtual reality sample plug-in
  • ThreeLib (C#) - .net Class Library for creating Three.js compatible objects
  • glTF-Rhino (C#) - Support for glTF 2.0 files in Rhino
  • ghgl (C#) - OpenGL shader support in Grasshopper
  • GhShaderNodes (F#, C#) - Grasshopper Shader Nodes
  • CCSycles (C, C++, others) - a C API for the renderer Cycles. CSycles: a C# wrapper around CCycles.
  • Rhino Mobile (C#) - Open source, cross-platform 3D library for mobile based on RhinoCommon and openNURBS
  • Eto (C#) - Cross platform GUI framework for desktop and mobile applications in .NET
  • compat (C#) - Checks compatibility between plugin.dll and api.dll.

We also have a number of open source projects by third-party developers (in no particular order or preference, just some I recall or discovered on food4rhino):

  • Speckle.Rhino (C#) - Rhino 5 & 6 + Grasshopper Speckle Clients
  • Grevit (C#) - Build your BIM Model in Grasshopper or SketchUp
  • Machina (C#) - A library for real-time robot control.
  • Dendro (C#, C++, C) - volumetric modeling for grasshopper built on top on openvdb
  • Conduit - enables designers to create custom data visualizations and heads up displays that update with your parametric models. NOTE: Since code is hosted on bitbucket, PRs do not count towards Hacktoberfest.
  • Plankton (C#) - A C# half-edge mesh data structure, and components for using this in Grasshopper/Rhino
  • HumanUI (C#) - Human UI is a new interface paradigm for Grasshopper. Create professional looking Grasshopper apps with custom user interfaces without writing any code. NOTE: Since code is hosted on bitbucket, PRs do not count towards Hacktoberfest.
  • MeshMachine (C#) - Remeshing component for Grasshopper using Plankton
  • Kangaroo 2 Goals (C#) - Example Goals for use with the Kangaroo2 solver

If you have an open source project you’d like to include in this list, please DM me with the details.

Posts: 3

Participants: 2

Read full topic

Viewing all 8553 articles
Browse latest View live