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

CustomObject Memory Undo Stack [C#]

$
0
0

@mpcarlos87 wrote:

Hi all,

Using Rhinocommon I'm having memory problems with the undo stack using custom objects. When adding a CustomMeshObject to the Document with some other class instances inside (meshes, parameters, whatever you need inside the custom object) the ram usage is being affected but it doesn't affect to the limit for the undo stack. I mean, the undo stack is not doing the purge when the memory usage is higher than the limit.

To test this I created a CustomMeshObject with a mesh Sphere(Size = 10x10) that has inside
another sphere mesh (Size = 1000x1000) that uses a lot of memory. If you drag the object about 10 times, the document purge event is not being called despite the memory usage goes above 1000MB(according to windows) and 1200MB(according to Rhino). My memory limit at options is 256MB. Seems that Rhino does not take into consideration to the undo stack this elements inside the custom objects. I tried to use the UserData and UserDictionary inside the Geometry of the custom objects but the result is almost the same.

Do you know a workaround for this? I attach the test project with a command "UndoPurgeDataCommand" which adds a sphere and you can check the memory usage dragging it (how it is being increased) and the purge for the undo stack is not being called. Also you have an UserData class in case you want to test with it too.

It's happening under Rhino 5 and the Rhino WIP latest version.

UndoPurge.zip (54.4 KB)

Regards,

Posts: 1

Participants: 1

Read full topic


Load external model

$
0
0

@Amit_Nambiar wrote:

I'm trying to create a plugin which needs to place an external 3dm (a smooth tetrahedron mesh) file at specific locations.
What's the best way to read this geometry from a file and place it at specified locations with attributes like layer, color etc via RhinoCommons?
I can't allow the plugin to open a pop-up window asking user for a file location.
Thank you.

Posts: 3

Participants: 2

Read full topic

ApplyPlanarMapping to a mesh

$
0
0

@sghosh wrote:

Hello,

Would it be possible for someone to point me as to how to have access to the uv space after applying planar mapping method to a 3d mesh. Is it also possible to access the map such that I can compute the 3d points on the mesh given arbitrary u-v values in uv space.

Thank you
Sunayana

Posts: 2

Participants: 2

Read full topic

Accessing mapping channels via RhinoCommon

$
0
0

@pkinnane wrote:

Hi - as per the title - can this be done pls? And when accessing the UV from a Mesh.TextureCoordinates, how can the UV's for mapping channels 2 onwards be obtained pls?

Thanks

Paul

Posts: 2

Participants: 2

Read full topic

How to create Grips

$
0
0

@onrender wrote:

Hello,

Grips are getting interesting I have found documentation how to transform them in a script as well as lots of other things about how to set up Grips for plugins especially Custom Shape Grips but the finaly how to create and attach custom shape grips to an object in Rhino without scripting or programming?

Can someone explain the concept (pseudo) how to create a parametric cube including Grips functionality?

Is there any training course in class about how to create plugins for rhino? I am very interested in.

Posts: 2

Participants: 2

Read full topic

RedPline Equivalent

$
0
0

@Dmitriy wrote:

Hi @DavidRutten

In GH there is a component named Reduce (RedPLine).
Is it based on some RC method or extra written?
I am looking for similar behaviour but to use in code.

Thanks,
Dmitriy

Posts: 3

Participants: 2

Read full topic

Issues w/ undo and duplicated geometry

$
0
0

@Alberto wrote:

Hi All,
I am developing a plugin that is monitoring changes in objects and generating automatically geometry starting from this monitored object. There I have an issue with undo/redo, if I move a curve and then undo the move my geometry is duplicated. Is there something I am doing wrong with this?

Alberto

Posts: 3

Participants: 2

Read full topic

Converting Rhino model to ETO Imageview

$
0
0

@Jack_Perry wrote:

Hi, I would like to be able to grab the rendered model in Rhino and place it in an ImageView() ETO form.

I am using Python to create the ETO form.

So for example, this:

Could be placed into one of these boxes:

Is this possible? What sort of tools do I need to do this?

Thanks so much for help.

Posts: 2

Participants: 2

Read full topic


C#: associating a Command to a PlugIn

$
0
0

@PohNee wrote:

I have a Class Library project with some custom Rhino.Commands.Command classes.
And I have a RhinoCommon Plug-In project in the same solution.

How can I associate these Commands to the Plug-In that is under a different assembly?
Is it possible?

Thank you.

Posts: 2

Participants: 2

Read full topic

Get Object by id

Rhino Plugin + Eto Searching for example

$
0
0

@Petras_Vestartas wrote:

Hi,

I would like to ask if there is an example file or github reference how to use Eto in Visual Studio (C#) for Rhino plugin?

I basically want to open a "form" , do some operations via sliders and drop-down menus and then press "ok" to execute.

Just to be sure, when writing a rhino plugin on Visual Studio on Windows using Eto, will plugin work both on Windows and Mac?

Kind Regards,
Petras

Posts: 1

Participants: 1

Read full topic

CreateInterpolatedCurve

$
0
0

@gianfranco74 wrote:

Hi all. Rhino5 last release . If i would like to select in the active document one curve, then delete it and rebuild what should i have to do?
var gx = new Rhino.Input.Custom.GetObject();
gx.SetCommandPrompt("Select one curve");
gx.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
gx.GetMultiple(1, 1);
if (gx.CommandResult() != Rhino.Commands.Result.Success..
for (int i = 0; i < gx.ObjectCount; i++)
{
//retrieving nurb
var curve_objref = ...
var curve_id = ....
var curve_rhobj =.....
var nurb = curve_rhobj.Geometry as Rhino.Geometry.NurbsCurve;
// 1)question: is the following control necessary?
if(nurb ==null)
{
var curve = curve_rhobj.Geometry as Rhino.Geometry.Curve;
nurb = curve.ToNurbsCurve();
}
//deleting id
Rhino.RhinoDoc.ActiveDoc.Objects.Delete(curve_id, true);
//2) question :how to build it again as it was before????
}

( Obviously i would like to build it by reconstructing it with interpolated curve or control point curve not with a simple doc.Objects.AddCurve(nurb) )

Posts: 1

Participants: 1

Read full topic

Colorize toolbar

$
0
0

@jordy1989 wrote:

Hi all,

Is it possible to change the color of a button, or change the bitmap via .NET/Rhinocommon?

Thank you.

Posts: 2

Participants: 2

Read full topic

Copy Paste Objects with User Datas

$
0
0

@Markus_Erhardt wrote:

Hi,
I applied a user data to an object. And want that the user data is copied at the same time for the newly object.
I catch the duplicate Events. But for different reason I would like to be sure It ti the Copy paste shortcut the user have pressed, I am exactly in the same situation as in this thread. The User Data doesn t go into the " protected override void OnDuplicate(Rhino.DocObjects.Custom.UserData source) -Write(....) " function. Is there someone who can give a good sample ?

Posts: 2

Participants: 2

Read full topic

Rhino plugin in C# when wrapping C++ class

$
0
0

@Petras_Vestartas wrote:

Hi,

I am trying to wrap C++ class in order to call it in C#.

I have a question is it only possible to wrap classes but not function only?
I attached my Visual Studio project here too:
https://mega.nz/#!M54kwIZY!546zd9fIUg9DxCAWOniVOiyEQQJFS24ylGIBDrKIUkc

What I did I downloaded sample file from here:

Tested it and tried to run another C++ simple function to understand the workflow. Everything works fine. Tested in Rhino.
Now I am trying to pass not a function but the whole class. Is it possible to do so?

What I did:
1. I created C++ class (.h and .cpp ) in sample file. Works.
2. I initialized C++ class in sample file. Works.
3. Then I tried to initialize class functions from C++ class and it causes errors see screenshot attached. Error

What I am trying to do is to call the same functions as I did using C++ console application:

int main()
{
	MyGraph g1(5);
	g1.addEdge(0, 1);
	g1.addEdge(0, 2);
	g1.addEdge(1, 2);
	g1.addEdge(1, 3);
	g1.addEdge(2, 3);
	g1.addEdge(3, 4);
	g1.greedyColoring();
	return 0;
}

Posts: 2

Participants: 2

Read full topic


Pointer (array of int) from C++ to C#

$
0
0

@Petras_Vestartas wrote:

Hi,

I am learning Rhino plugin development when wrapping C++ classes to pass data to C#.

I have question about pointers.

In C++ I have a class that has a getter of "int* values", which is just array of integers.
I class works and I can return integer one by one from class, but do not know how to pass whole array.
But every array in C++ is a pointer. So how to return values associated with a pointer (array of integers) to C#?

I tried this when passing C++ function to C#, but ok pointers do not exist in C# and I wonder if int* is correct:

SAMPLELIBRARY_C_FUNCTION int* colors(int x) {
	MyGraph g(x);
	g.addEdge(0, 1);
	g.addEdge(0, 2);
	g.addEdge(1, 2);
	g.addEdge(1, 3);
	g.addEdge(2, 3);
	g.addEdge(3, 4);
	g.greedyColoring();
	return g.getValues();
}

What is a correct way to pass int* colors function in C# in UnsafeNativeMethods.cs to get integer array?
For now I tried:

[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
internal static extern int[] colors(int x);

and then I print array values:
int[] values = UnsafeNativeMethods.colors(5);
for(int i = 0; i < values.Length; i++)
Rhino.RhinoApp.WriteLine(values[i].ToString());

But try catch block gives me an exception in Rhino:
Cannot marshal 'return value': Invalid managed/unmanaged type combination.

Posts: 6

Participants: 2

Read full topic

RhinoOffsetCurve input not clear

$
0
0

@sghosh wrote:

Hello,

I am using the Rhino .NET currently and for the RhinoOffsetCurve method, I am required to give the following input:

  • input Curve
  • offset distance
  • direction point
  • normal
  • corner style
  • tolerance

output : list of curves.

The input curve in my case is always closed, I just wanted to clarify
- how far does the direction point need to be outside the curve (Since I am expanding the curve)
- Does the normal denote the normal to the plane on which the curve lies?

With my current choice of direction point I do not get complete offset curves as can be seen in the example below:

Could any one suggest a good way to compute the direction point.

best
Sunayana

Posts: 1

Participants: 1

Read full topic

Get user datas on delete items

$
0
0

@Markus_Erhardt wrote:

Hi,
I am looking for the user Datas when we delete an Item.
To be more precise I have a list of list of differerent object who all recive "ObjectDatas"
List<List> myList;

ObjectDatas can be a UserData too. So it is useful because when reading the UserData from the selected object I now at which row in the List of List I have to look to find him.

I cannot give too much information on this thing and why. The only thing is that when deleting the objects, in the Events generated I need to get the User Data of this object-> but Rhino always said null reference ? Why?
example :

   private void RhinoDoc_DeleteRhinoObject(object sender, Rhino.DocObjects.RhinoObjectEventArgs e)
        {

            ObjRef obj_ref = new ObjRef(e.ObjectId);   -----------> This works
           var ud = obj_ref.Geometry().UserData.Find(typeof(ObjectDatas)) as ObjectDatas; //something give a NullReferenceException  Why ?????

Posts: 1

Participants: 1

Read full topic

Access vRay frames list in rhinoscript/python

$
0
0

@Paolo_Acampora wrote:

Hello everybody, I am new to Rhino and to this board, but you guys have already helped a lot with my scripts in the latest days :slight_smile:

I am using python to write a render submission tool for Rhino-vRay, so I need to harvest the most settings I can. The big issue seems to be the frame range: I can get the parameter if I use

frames = clr.Reference[System.Object]()
VRay.GetSettingsParameterString("/SettingsOutput", "frames", "list", frames)

but all the frame numbers are merged together: frames from 1 to 5 becomes 12345

I cannot find any information that would help me to untangle this digits, and it's even worse when I try to set the value (the render manager will have to change the framerange)

Anyone knows of a way to get a clean list from the vray properties? A possible workaround would be using the SaveVisopt() function and export an xml file, get my informations from there, load a new xml file with LoadVisopt() when it's time to render.

Thanks a lot!
Paolo

Posts: 3

Participants: 2

Read full topic

ON_3fPoint::DistanceTo

$
0
0

@kvrantzaliev wrote:

Hello team, I know this might be a small thing and yes, I can implement it myself, but would be nice to have
ON_3fPoint::SquaredDistanceTo. In many case in the code you might need to compare only the distances and lengths, while not worried about the actual value. For example
if ( v[0].DistanceTo(v[2]) <= v[1].DistanceTo(v[3]) )
In this case sqrt() will be called twice, while it is not needed.

I know this sounds small thing, but when you do high performance evaluation, this may help a little bit. It is 5 minutes of coding and having such function doesn't hurt

Regards
Kostadin

Posts: 2

Participants: 2

Read full topic

Viewing all 8553 articles
Browse latest View live