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

UndoMultiple list

$
0
0

@HepChan wrote:

hi @dale,

How do I get the commands in the UndoMultiple list?

Command…GetMostRecentCommands() do not give the exact match.

I need to programmatically revert the model back to a certain state on a cancel command.

Posts: 1

Participants: 1

Read full topic


ONX_Model Write function fails with big files

$
0
0

@Elizabeta wrote:

Hi
I am using 64bit Windows 10 and have 8GB RAM.
I am using ONX_Model to write my plugin objects in 3dm file. The Write function returns false once the 3dm file reach ~2GB size. The error I am getting in the text log is this :

‘ONX_Model::Write archive.Write3dmObject(m_IDef_table[28866]) failed
ONX_Model::Write archive.EndWrite3dmObjectTable() failed’.

When I try to read the same incomplete 3dm file with ONX_Model::Read it fails. However if I open the 3dm file with Rhino it opens and gives me a message that some of the geometry is not readable, and upon choosing to skip the unreadable geometry the file is successfully opened in Rhino.

The question : is there limit on the size of 3dm archives that ONX_Model::Write can produce or that depends on the installed memory on the system.? Should I increase the memory in order to write files >2GB? And if there is such a limit why Rhino manages to open the 3dm file , while ONX_Model::Write fails.

Posts: 1

Participants: 1

Read full topic

Reordering Ngons in a mesh C#

$
0
0

@Petras_Vestartas wrote:

Is it possible to reorder ngons in mesh by id list?

For instance there are 3 ngons in a mesh

I would like to shuffle the order so that ngon order would change from 0 1 2 to 2 0 1

I started from this linq:
surfaceMesh.Ngons = flatten.Select(i => surfaceMesh.Ngons[i]).ToList();

but surfaceMesh.Ngons is not datastructure of list but meshNgonList

Posts: 3

Participants: 2

Read full topic

RunScript command syntax

$
0
0

@HepChan wrote:

Hi,

where can I find a help file for the syntax of the rhino commands for scripting…

For example:
for a certain command (say -Line) what needs to follow (start, end) to define the script

Posts: 2

Participants: 2

Read full topic

Add/Remove ClippingPlane to/from Viewport in RhinoCommon

$
0
0

@rajaa wrote:

I have a clipping_plane_guid (exists in the doc), and a viewport_guid.
I’d like to add the clippingplane to viewport (make is active) in RhinoCommon.
In C++, we have:
CRhinoClippingPlaneObject::AddClipViewport(viewport_id)
CRhinoClippingPlaneObject::RemoveClipViewport(viewport_id)

I see open request in YouTrack here…, so I’d like to add my vote to supporting the functionality in RhinoCommon

Posts: 1

Participants: 1

Read full topic

RhinoDoc.Objects.Replace(ObjRef, Hatch?)

$
0
0

@rajaa wrote:

How to replace a hatch object in the document with a new one?
RhinoDoc.Objects.Replace does not seem to support replacing Rhino.Geometry.Hatch.

Posts: 3

Participants: 2

Read full topic

.Net problem (Autocad)

$
0
0

@jramos.do.o wrote:

I Have Autocad 2009 and I work with .Net. After installing Rhino 6 my dlls (with netload) stops working, please help me to solve this problem.

Posts: 2

Participants: 2

Read full topic

Issue with ModifyGeometry()

$
0
0

@Matthieu_from_NAVINN wrote:

Hi,
I’m trying to add a textDot to a bloc with the command ModifyGeometry() but it does not work:

 Dim MyTextDot As New Rhino.Geometry.TextDot("MyText", MyLocation)
 geometry.Add(MyTextDot)
 attributes.Add(attr)
 doc.InstanceDefinitions.ModifyGeometry(MyBlockInstDef.Index, geometry, attributes)

What’s strange is that it’s working fine if I do the exact same thing with a point:

Dim MyGPoint As New Point(MyLocation)
geometry.Add(MyGPoint)
attributes.Add(attr)
doc.InstanceDefinitions.ModifyGeometry(MyBlockInstDef.Index, geometry, attributes)

Any Idea?
Best regards

Posts: 1

Participants: 1

Read full topic


Create Mesh problems

$
0
0

@UtsMicke wrote:

Hi!

has created a mesh with just 3 corners
has since created points for the corners
but the points and mesh points are not in the same places?

has the same error in RhinoScript and RhinoCommon SDK

Dim arrVertices(2)

arrVertices(0) = Array(143820.732965887, 6587994.59060971, 16.033914636719)
arrVertices(1) = Array(143800.260178762, 6587995.58525459, 14.977226030752)
arrVertices(2) = Array(143780.682129344, 6588017.91073487, 21.078640595528)

Dim arrFaceVertices(0)

arrFaceVertices(0) = Array(0, 1, 2)
Rhino.AddMesh arrVertices, arrFaceVertices

Rhino.AddPoint arrVertices(0)
Rhino.AddPoint arrVertices(1)
Rhino.AddPoint arrVertices(2)

Thank you all,

Michael.

Posts: 2

Participants: 2

Read full topic

How to Create a Growth Map of a Forest Using Mesh Surfaces

$
0
0

@Terry_Chappell wrote:

I have a mesh in Rhino created by importing a .obj which represents the 3D model of a forest generated with a drone. It has 887,510 triangular polygons. The z-axis represents the elevation. I want to take this 3D model and subtract its Z, over the entire x-y surface, from that of a 3D model of the forest at a later time. The idea is to create a new 3D model that shows the growth in elevation of the forest. By subtracting the 2 models, the common-mode elevation changes due to terrain is eliminated and only the differential-mode elevation change due to forest growth is illustrated. Ideally this new 3D model would be color coded by z (elevation) in order to enable rapid identification of high and low growth regions.

Any suggestions? Maybe one of the Plug Ins already does this? So far I have managed to clean up the 3D mesh by draping a surface over it to eliminate surfaces hidden below higher surfaces. So now I have a single surface for the model and I can generate this for the two mesh models of the forest. But I am not sure what to do for the next step. Should I just use the grid created by the Drape command and go grid-by-grid to subtract the z of the two surfaces in each grid cell? This would give me a point cloud with the Z at each point showing the growth this is of interest. But I do not read that Drape works over a point cloud. I need to look at this next, perhaps?

I have done a bit of work with creating complex, closed polysurfaces for CNC applications use RhinoPython scripts with GUI interfaces. But I know essentially nothing about manipulating mesh objects on their own. I do like writing Python scripts but I need some help in picking the right functions.

A portion of the mesh looks like this:


The flat-looking area is ground while the surrounding taller shapes are trees.

Any help will be greatly appreciated. This is an opportunity for you to help support forest management.

Regards,
Terry.

Posts: 1

Participants: 1

Read full topic

RhinoRevolve 360 revolution for polyline

$
0
0

@gennaro wrote:

Hi,

I am trying to create a command for curve revolution with RhinoRevolve.
This is the part relative to the 360revolution:

const ON_Curve * crv = ON_Curve::Cast(obj->Geometry());
if(crv) {
	ON_Line axis(ON_3dPoint(0,0,1),ON_3dPoint(0,0,0));
	ON_Interval interval(0,2*ON_PI);
	ON_Curve * crvd = crv->Duplicate();
	const ON_Surface * crvRev = RhinoRevolve(crvd,axis, interval);
	if(crvRev)
	         context.m_doc.AddSurfaceObject(*crvRev);
}

It seems to work fine for interpolated curves but it fails for some polycurves (and it even lags few seconds),

whereas Rhino is capable to do it in the correct way.

I wonder if I am using the right function.

Posts: 1

Participants: 1

Read full topic

Using the NodeInCode namespace

$
0
0

@piac wrote:

As some noticed some time ago, we have been working on NodeInCode functionality.

The goal was to make this functionality more understandable: with warnings that could give useful suggestions, stable: also when used with multi-threading, and more robust to cases where third-party libraries would not cooperate.

While at it, we decided to allow every .Net language, to access this functionality. Some of you noticed a while back, when we were actively changing this most weeks: Rhino.NodeInCode namespace?

Now it’s time to explain how NodeInCode works.

1. Finding a loaded Grasshopper component.

All components that are loaded (with a minimal set of exceptions^) can be found. You just need to know their full name. If the component names comes from a library, then the library names is pre-pended, with an underscore _ as separator. The exact spelling of the library depends from the AssemblyName of the GHA. If you are having issues finding what it exactly is, you can just query all dynamic names like this:

A = Rhino.NodeInCode.Components.NodeInCodeFunctions.GetDynamicMemberNames();
node-in-code-dynamic-names.gh (13.9 KB)

2. Evaluating a component

Any component that can be found can then be evaluated.

node-in-code.gh (7.8 KB)

The same is also possible outside of Grasshopper, for example,

node-in-code.py (539 Bytes)

The only catch is that, at present, there is no way to switch components that have special settings to any alternative. For example,

no-conversion

3. .Net delegates (“function pointers”)

Some developers are used to directly evaluating a method without going through an “Evaluate” function. Especially when writing functional code in .Net, it might be beneficial to get directly a delegate.

This is also supported, in a few different flavors. The flavor mostly deal with how warnings are issues, thereby making it simpler to develop and then possibly switch to a more warning-tolerant system^^. The ComponentFunctionInfo has Delegate, DelegateNoWarnings, DelegateTree and DelegateTreeNoWarnings properties, returning the appropriate type of result.

Delegates are returned in the form of a Func<object,object,...> generic instance. Because of this, the number of inputs needs to match exactly the amount of inputs of the component. This is in contrast with the Evaluate() method, where Optional inputs at the bottom of a component can just be omitted.

node-in-code-delegates.gh (11.9 KB)

Notes

^ at present you cannot find: scripting components themselves, GHPY compiled components, params and third-party add-ons components that have names consisting of only non-ASCII characters.

^^ please note that DynamicInvoke() will wrap exceptions within TargetInvocationExceptions. You can retrieve the inner exception with the InnerException property. You can get Grasshopper to visualize the exception by writing:

try
{
  B = ((Delegate) y).DynamicInvoke(new object[]{"1,1,0", "2,3,0", "-2,3,0"}, "World XY", "1.1,2,0", null);
}
catch (TargetInvocationException tex)
{
  throw tex.InnerException;
}

Posts: 1

Participants: 1

Read full topic

Howto create interactive arrows for parameter changes

$
0
0

@dsw wrote:

I’m searching for an example code to create arrows like from the gumball which can be moved and and where i can react on the changes during or after the movement.

For example like in rhinogold where you can drag and move a circle to change the position and the diameter (e.g. in the video https://www.youtube.com/watch?v=ISX3dRaZpnI starting at 3:20)
I also made a screenshot and marked the arrows and points which i want to create by my own.
Untitled

Posts: 1

Participants: 1

Read full topic

Selection Bug in GetObjects

$
0
0

@karld wrote:

Hi Rhino Team,

I keep running in problems selecting/deselecting objects in picking mode.
If there is any object pre-selected, it can not be altered in picking mode again without closing and re-opening picking mode. The problem appears both in Rhino 5 and Rhino 6, with the difference being Rhino 5 using “Version 1” and Rhino 6 using "Version 4"
“Version 4” is the best solution I could find till now, but it still is inconvenient not being able to see the pre-selected objects.
I’ve tried the four following codes snippets but none of them works as it should. (Only changes two parameters)

#########
Version 1
Original code
#########

 while (true)
            {
                go.GetMultiple(1, 0);
                if (go.CommandResult() != Rhino.Commands.Result.Success)
                {
                    return null;
                }

                var canBreak = true;
                if (go.ObjectsWerePreselected)
                {
                    go.EnablePreSelect(false, false);
                    go.EnableClearObjectsOnEntry(false);
                    go.DeselectAllBeforePostSelect = false;

                    canBreak = false;
                }


                if (!multiple && go.ObjectCount > 1)
                {
                    go.SetCommandPrompt("Please make sure you select one item: " + message);

                    canBreak = false;
                }

                if (canBreak)
                {
                    break;
                }
            }

Pre-selected objects cannot be selected/deselected at all

#########
Version 2
#########

while (true)
            {
                go.GetMultiple(1, 0);
                if (go.CommandResult() != Rhino.Commands.Result.Success)
                {
                    return null;
                }

                var canBreak = true;
                if (go.ObjectsWerePreselected)
                {
                    go.EnablePreSelect(false, false);
                    go.EnableClearObjectsOnEntry(false);
                    go.DeselectAllBeforePostSelect = true;


                    canBreak = false;
                }


                if (!multiple && go.ObjectCount > 1)
                {
                    go.SetCommandPrompt("Please make sure you select one item: " + message);

                    canBreak = false;
                }

                if (canBreak)
                {
                    break;
                }
            }

Pre-selection can not be selected/deselected. Only after deselecting all and selecting all again single surfaces can be selected again.

#########
Version 3
#########

while (true)
            {
                go.GetMultiple(1, 0);
                if (go.CommandResult() != Rhino.Commands.Result.Success)
                {
                    return null;
                }

                var canBreak = true;
                if (go.ObjectsWerePreselected)
                {
                    go.EnablePreSelect(false, false);
                    go.EnableClearObjectsOnEntry(true);
                    go.DeselectAllBeforePostSelect = false;

                    canBreak = false;
                }


                if (!multiple && go.ObjectCount > 1)
                {
                    go.SetCommandPrompt("Please make sure you select one item: " + message);

                    canBreak = false;
                }

                if (canBreak)
                {
                    break;
                }
            }

Pre-selected object can not be deselected at all in current picking mode. Deselection tool works as selection tool on deselected objects

#########
Version 4
#########

while (true)
            {
                go.GetMultiple(1, 0);
                if (go.CommandResult() != Rhino.Commands.Result.Success)
                {
                    return null;
                }

                var canBreak = true;
                if (go.ObjectsWerePreselected)
                {
                    go.EnablePreSelect(false, false);
                    go.EnableClearObjectsOnEntry(true);
                    go.DeselectAllBeforePostSelect = true;


                    canBreak = false;
                }


                if (!multiple && go.ObjectCount > 1)
                {
                    go.SetCommandPrompt("Please make sure you select one item: " + message);

                    canBreak = false;
                }

                if (canBreak)
                {
                    break;
                }
            }

Pre-selected objects can be selected/deselected, but every pre-selected object becomes deselected once picking mode is entered

Posts: 1

Participants: 1

Read full topic

Rotation matrix

$
0
0

@Petras_Vestartas wrote:

Hi,

I would like to learn/understand transformation matrices.

Therefore I would like to ask how to construct rotation matrix if I have an object and its axis and target axis. As image below.

What I would like to do is:

Declare rotation matrix:

Transform t;

and then assign each value individually:

t.M00 = ...;
t.M01 = ...;

But I do not know the math behind rotation matrix

Posts: 1

Participants: 1

Read full topic


Recompiling for R6 required?

Rhinocommon function to get duplicate curves

$
0
0

@Xavier_Ayme wrote:

Hello,

I need to select all ‘duplicate’ curves the same way as ‘SelDup’ command does. According to this thread and this Report, it looks like this function is not yet available. So, I basically tried to replicate the function (curves only) by comparing some relevant curve parameters like PointAtStart, Domain and some random points on both curves.

Problem I face is that this algorithm is way slower than SelDup command. When the number of curves exceeds 10 000, it takes more than a minute to solve whereas ‘SelDup’ takes less than a second.

Would you have any hint on how SelDup Command works to be that fast?

Thanks for your help!

Posts: 1

Participants: 1

Read full topic

To cancel save

$
0
0

@HepChan wrote:

I have commands to start edit and stop edit.

After the start edit is clicked, the model is modified.

If the user clicks the save button, I would like to cancel the save as it is in the middle of edit mode.

how do I cancel the save?
or is there any other way to avoid the saving of the file which is at an unacceptable state?

Posts: 4

Participants: 2

Read full topic

CRhinoObjRef creation

$
0
0

@gennaro wrote:

Hi everybody,
I am currently using CRhinoObjRef to store information of objects, subobjects and grips.
My problem is that I still do not have clear how to build correctly a CRhinoObjRef instance.

I have noticed that, for example, when I create a CRhinoObjRef from of an extrusion object it behaves in a different way than a CRhinoObjRef created from the copy of such object.
For instance, the CRhinoObjRef created from the original returns a brep when I use the Brep() method.
The CRhinoObjRef created from the copy of the object do not return anything.
Here a short example:

CRhinoGetObject go;
go.SetCommandPrompt( L"Select comp" );
go.SetGeometryFilter(CRhinoGetObject::surface_object);
go.GetObjects( 1, 1 );
if( go.CommandResult() != CRhinoCommand::success )
	return go.CommandResult();

CRhinoObjRef& objref1 = go.Object(0);
CRhinoObject * objDup = objref1.Object()->Duplicate();
CRhinoObjRef newObj (objDup);

RhinoApp().Print( L"objref1:: (brep? %d) - (type ? %d) \n", 0!=objref1.Brep(), objref1.m_component_index.m_type);
RhinoApp().Print( L"objDup:: (brep? %d) - (type ? %d) \n", 0!=newObj.Brep(), newObj.m_component_index.m_type);

that returns (when I select a face)

objref1:: (brep? 1) - (type ? 3)
objDup:: (brep? 0) - (type ? 0)

It means, I guess, that CRhinoObjRef has to be built in a proper way ( can one thing be the proxy? )
Thanks in advance!

Posts: 1

Participants: 1

Read full topic

Rhino UserData API VS Rhino UserString API

$
0
0

@cughudson wrote:

Is there different between Rhino UserData API and Rhino UserString API?
The two of the API is use to add User Custom data to the Rhino Geometry, Is there different about that?

Posts: 5

Participants: 2

Read full topic

Viewing all 8683 articles
Browse latest View live


Latest Images