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

How to get the scene hierarchy of all the objects?

$
0
0

@alexian007 wrote:

Hi all!
So, I am using the c++ Rhino API, and am making a plugin for Rhino so that the rhino model (3dm) can be converted into another format. For that, I need the hierarchy of the scene, all the parent-child relations and the object details. How do I get that? I have been through the docs but have not found any suitable methods for doing so. Please do let me know what should I do or if there’s something on the docs that I missed. Thank you!

Posts: 1

Participants: 1

Read full topic


Use aws-sdk c++ for s3 file upload

$
0
0

@ramadan wrote:

Hello, So i have two questions.

  1. Is it possible to use aws-sdk for c++ plugin development, because i am trying to use to upload some file into s3, but i get Access violation ... every time…
  2. I am getting same error with http-requests too, so did any of use ever did API requests with Rhino, if yes how is that done, and is this a threading error or something…
    PS: If these are possible, please led me to some sample or something, cause i cannot find anything similar…
    Thanks in advance

Posts: 3

Participants: 2

Read full topic

Drawing a line in an angle (C#)

$
0
0

@shehanwilfred wrote:

Hi Guys,
I am trying to draw a line in an angle (perpendicular to the line it’s starting from). Below is an example of what I am trying to achieve. In the below example the left line is drawn off the dotted line, it is perpendicular to the dotted line.

In my c# code I have the following

doc.Objects.AddLine(new Line(topInterL, new Point3d(topInterL.X - (90 - topAngle), topInterL.Y + perimeterOffset, 0)));

topInterL - it holds the point of intersection between the folded line and the line am trying to draw.
topAngle - The angle of the folded line

Hope you can understand what I have already done, I am just getting the ‘X’ value of the intersection point and then reducing it by the calculated angle. However, this approach is not working for me.
What I am doing wrong here?

Regards,
Wil

Posts: 1

Participants: 1

Read full topic

How to get detailed information about the objects on the scene?

$
0
0

@binigya wrote:

Hello!

So, I am trying to get detailed information about all the objects on the scene. Everything from its transforms, to its vertices, UV coordinates, normals, materials with PBR properties and all that.

I have gone through the docs and the forum, and right now, I have code that is similar to this documentation about getting layer objects. So what I have now is:

CRhinoCommand::result CCommandGetObjectInfo::RunCommand(const CRhinoCommandContext& context)
{
	int selected_count = 0;
	const ON_Geometry* objGeo;
	const ON_Mesh* objMesh;
	ON_BoundingBox objBBox;
	int dimension = 0;
	double area = 0;
	double vol = 0;
	ON_UUID uuid;
	int objDisplayOrder = 0;
	const wchar_t* layer_name = L"Default";
	const int layer_index = context.m_doc.m_layer_table.FindLayerFromFullPathName(layer_name, ON_UNSET_INT_INDEX);
	if (layer_index != ON_UNSET_INT_INDEX)
	{
		const CRhinoLayer& layer = context.m_doc.m_layer_table[layer_index];
		if (!layer.IsDeleted())
		{
			ON_SimpleArray objects;
			const int object_count = context.m_doc.LookupObject(layer, objects);
			if (object_count > 0)
			{
				for (int i = 0; i < object_count; i++)
				{
					const CRhinoObject* obj = objects[i];
					if (nullptr != obj && obj->IsSelectable())
					{
						objGeo = obj->Geometry();
						objDisplayOrder = obj->Attributes().m_display_order;
						uuid = obj->Attributes().m_uuid;
						obj->Attributes().m_color;
						ON_wString uuidStr;
						ON_UuidToString(uuid, uuidStr);
						objBBox = objGeo->BoundingBox();
						area = objBBox.Area();
						vol = objBBox.Volume();
						dimension = objGeo->Dimension();
						obj->Select(true);
						selected_count++;
						RhinoApp().Print(L"The object no. %d with Unique identifier %s is a %d dimension object and the area and vol of its bounding box are %lf and %lf. The display order of it is %d\n",  selected_count, uuidStr, dimension, area, vol, objDisplayOrder);
					}
				}
			}
		}
	}

	if (selected_count > 0)
		context.m_doc.Redraw();

	RhinoApp().Print(L"Selected layer's total objects are = %d\n", selected_count);


	return CRhinoCommand::success;
}

So, now I would like to get the details of the object, as I mentioned earlier. How exactly do I do that? I have gone through the docs, but it seems confusing to me right now. Please let me know if I missed some documentation or API classes that can help me. Thank you!

Posts: 1

Participants: 1

Read full topic

How do I get the scene reference in Rhino?

$
0
0

@binigya wrote:

Hi, I need to get the scene definition for a 3DM file, that contains the data about the objects, meshes and other information of the current open file. How do I do so?

Posts: 1

Participants: 1

Read full topic

Beginner rhino C++ Plugin question - What is a Document in Rhino?

$
0
0

@alexian007 wrote:

Hi, So I am exploring C++ by getting started in Rhino Plugin development. I have successfully configured visual studio and have made a basic “hello-world” plugin in Rhino. What I would like to know is what is the context variable all about and what is a Rhino Document, how do I get access to it? Can I use it to get information about the objects, materials, etc?

Posts: 1

Participants: 1

Read full topic

ByObject Materials proliferation - I still don't get this

$
0
0

@Jarek wrote:

Hi RMA,

This has been discussed before with some explanations of how things work with ByObject materials in Rhino (@JohnC - I think you were looking into it). But I still don’t understand some of it and running into problems of materials bloating in the file and a performance hit.

Basically, when an object (let’s say - a box) - with ByObject material gets copied several times, based on UI, when I change it’s material, all copies material change accordingly - so in my mind, intuitively, they all should use the same material - no new materials were created in the file, and MaterialEditor shows only one material.
When I delete these copies and Purge materials, the message reads “Purged [n] unused legacy materials”.
What actually gets purged?

The real usability problem with this I am encountering is with a script/plugin, where during script runtime many copies of objects with ByObject material are created and deleted; in the script they are being either used as preview objects, or are a result of custom in-script undo action. All in all, many times after the script finishes, Purge reports 1000s or tens of thousands legacy materials purged. Often Purge halts for good few seconds on this. This is problematic, since the tools I am working on are supposed to be used often, with many objects that potentially have ByObject material, and with this the pile-up of unused materials will create a huge numbers, until the next purge, causing potential very very long system freeze.

I was trying to experiment and test a way around this in the script, by making a temp layer with the material copied from the object, changing the object’s materials to ByLayer, moving it to that layer and removing its original material; then all the copies/mesh extractions etc. would be done with ByLayer material, and once all is cleaned up, the temp layer would be deleted and object back to ByObject material with original material assigned. Unfortunately it does not do anything and Rhino would still create tons of materials, even with the ByLayer material in-script switch.

Here is a test file (simple box with ByObject Custom material): MaterialProliferation_Test.3dm (72.9 KB)
And the test script doing what I described above: MaterialProliferation_Test.rvb (1.8 KB)

Please note that if I run this a few times in a row, the Purge takes longer each time, and the material indices go way way up each time.

Is there anything that can be done to prevent this bloating? Perhaps RhinoScript methods don’t deal well with the new Rhino RDK materials? Would using RDK methods help with limiting this material proliferation?
I am not sure if this is all by design or it is some memory/code leak that could be avoided altogether?
(@andy - perhaps you can offer some advice?)

Thank you,

–jarek

Posts: 1

Participants: 1

Read full topic

Curve interval

$
0
0

@XNurbs wrote:

Dale,

When calling “ON_Interval rnCurveInterval = prnCurve->Domain();”, we want to make sure “rnCurveInterval.m_t[1] > rnCurveInterval.m_t[0]”. Would switching the two values work? (The curve may be periodic, so switching the two values may not get the right interval.)

Posts: 1

Participants: 1

Read full topic


Trimming a NURBS surface in C++

$
0
0

@XNurbs wrote:

Dale,

We have a boundary loop in parameter space. How to trim a NURBS surface using these UV curves in parameter space? Do you have a C++ example (we have no need to make a brep)? Many thanks.

Posts: 1

Participants: 1

Read full topic

The Debug configuration

$
0
0

@XNurbs wrote:

Dale,

After creating a project with Rhinoceros 6 Plug-in template, we notice that the Debug configuration has a “NDEBUG” setting. Could we change “NDEBUG” to “_DEBUG” for the Debug configuration? (or this would cause some problems for Rhino plugin?) Many thanks.

Posts: 1

Participants: 1

Read full topic

[RhinoCommon] Options pages with child pages - dialog gets stuck

$
0
0

@menno wrote:

We have some options pages that have child pages, and I notice that once a child page is selected, navigation gets stuck and no other pages can be selected. A minimal reproduction of this error is found here (adapted from the Samples from GitHub). The SampleCsOptionsParentPage is registered in the OnLoad method of the plugin.

@dale
How do I properly register a child options page? In Rhino-5 the method below works.

internal class SampleCsOptionsParentPage : OptionsDialogPage
{
  private UserControl m_control;

  public SampleCsOptionsParentPage()
    : base("Sample-Parent")
  {
    Children.Add(new SampleCsOptionsChildPage());
  }

  public override object PageControl
  {
    get { return m_control ?? (m_control = new UserControl()); }
  }

  public override bool OnApply()
  {
    RhinoApp.WriteLine("SampleCsOptionsParentPage.OnApply");
    return true;
  }

  public override void OnCancel()
  {
    RhinoApp.WriteLine("SampleCsOptionsParentPage.OnCancel");
  }
}

internal class SampleCsOptionsChildPage : StackedDialogPage
{
  private SampleCsOptionsUserControl m_control;

  public SampleCsOptionsChildPage()
    : base("Sample-Child")
  {
  }

  public override object PageControl
  {
    get { return m_control ?? (m_control = new SampleCsOptionsUserControl()); }
  }

  public override bool OnApply()
  {
    RhinoApp.WriteLine("SampleCsOptionsChildPage.OnApply");
    return true;
  }

  public override void OnCancel()
  {
    RhinoApp.WriteLine("SampleCsOptionsChildPage.OnCancel");
  }
}

Posts: 1

Participants: 1

Read full topic

CreatePlanarBreps replacement

$
0
0

@runxel wrote:

The docs state that the Brep.CreatePlanarBreps Method is now obsolete (Rhino 6.10).
What’s the replacement for this?

Posts: 1

Participants: 1

Read full topic

Identify Sides of an exploded object

$
0
0

@shehanwilfred wrote:

Hi,

I am coding up a plugin in C# to add perpendicular lines to all the edge of a selected shape (assuming shape is a 4 sided). I could not find anything to identify the edges of a select shape, so my approach is, exploding the selected shape and getting the objects for individual side and converting the objects to lines so that I can easily find the edges for the sides.

Now my problem is I cannot identify which object belongs to which side after exploding, so I am unable to proceed from here.

Example shape which I am working with

What would be the best way to identify which object belongs to which side or is my approach wrong?

Thanks

Posts: 2

Participants: 2

Read full topic

nurbsCurve: different behaviour between Rhino.NET and RhinoCommon

$
0
0

@lscandella wrote:

Hello Forum,

I’m porting my old code from Rhino.NET to RhinoCommon and I found an issue on nurbsCurve. My Rhino version is 5 SR8 by now.

Given the points:

p0(0,0,0)
p1(1,1,0)
p2(2,0,0)
p(1.5, 0.3, 0)

I need to draw the nurbs starting at p0 with tangent p0 -> p1, ending at p2 with tangent p2 -> p1 and passing through p.

I did my homework and I came up with this solution: a rational nurbs curve with degree and order = 3, 4 knots and 3 control points

The knots vector must be:

[0,0,1,1]

the control points must be:

[0,0,0]
[0.612372435695795,0.612372435695795,0]
[2,0,0]

and the weights vector must be:

[1, 0.612372435695795, 1]

My RhinoCommon implementation is:

NurbsCurve nc0 = new NurbsCurve(3, true, 3, 3);
nc0.Knots[0] = 0;
nc0.Knots[1] = 0;
nc0.Knots[2] = 1;
nc0.Knots[3] = 1;
bool p0OK = nc0.Points.SetPoint(0, 0, 0, 0, 1);
bool p1OK = nc0.Points.SetPoint(1, 0.612372435695795, 0.612372435695795, 0, 0.612372435695795);
bool p2OK = nc0.Points.SetPoint(2, 2, 0, 0, 1);

and my Rhino.NET implementation is:

OnNurbsCurve nc1 = new OnNurbsCurve(3, true, 3, 3);
nc1.SetKnot(0, 0);
nc1.SetKnot(1, 0);
nc1.SetKnot(2, 1);
nc1.SetKnot(3, 1);
On4dPoint p04d2 = new On4dPoint(0, 0, 0, 1);
On4dPoint p14d2 = new On4dPoint(0.612372435695795, 0.612372435695795, 0, 0.612372435695795);
On4dPoint p24d2 = new On4dPoint(2, 0, 0, 1);
bool p0OK2 = nc1.SetCV(0, p04d2);
bool p1OK2 = nc1.SetCV(1, p14d2);
bool p2OK2 = nc1.SetCV(2, p24d2);
bool w0OK2 = nc1.SetWeight(0, 1.0);
bool w2OK2 = nc1.SetWeight(2, 1.0);

The problem is that they don’t match. In the picture you can see the construction triangle, the Rhino.NET based green nurbs and the RhinoCommon based red nurbs.

The green curve properly passes through p and has the correct tangents, while the red one not only doesn’t pass through p but also has wrong right tangent.

Bizarre is also the fact that if I look at the properties of both curves from Rhino I get “elliptic arc”. Isn’t an ellispse a conic and then a second degree curve?

Thanks. L

Posts: 1

Participants: 1

Read full topic

Learn How to create rhino plugins

$
0
0

@portugaldesignlab wrote:

Hello to all is there any places that i can learn how to create and develop in visual Studio plugins for rhino.
Is there any workshops or videos in the internet that I can see

Posts: 3

Participants: 3

Read full topic


Can we use the concept of 3D meyer to Rhino Scripting

Display Conduit redraw

$
0
0

@mwittich wrote:

Hi,
I try to get my head around display conduits. For testing I wrote some simple code in a c# node, that displays 3d text. The problem is, that the display never gets redrawn. Every time i trigger the code new text is added, but it never disappears.
Thanks for any answer.
Best M.

MyConduit myConduit = new MyConduit();
Rhino.RhinoDoc doc = Rhino.RhinoDoc.ActiveDoc;

    if(run){
      for(int i = 0;i < plns.BranchCount;i++){
        GH_Path p = plns.Paths[i];
        for(int j = 0;j < plns.Branch(i).Count;j++){
          if(plns[p, j] == null)continue;

          Rhino.Display.Text3d txt = new Rhino.Display.Text3d("test", plns[p, j], s);
          txt.VerticalAlignment = Rhino.DocObjects.TextVerticalAlignment.Middle;
          txt.HorizontalAlignment = Rhino.DocObjects.TextHorizontalAlignment.Center;
          txt.FontFace = "Arial";
          myConduit.Add(txt);

        }
      }
      myConduit.Enabled = true;
      doc.Views.Redraw();
    }
    else{
      myConduit.Enabled = false;
      myConduit = null;
      doc.Views.Redraw();
    }

class MyConduit : Rhino.Display.DisplayConduit
  {
    private List<Rhino.Display.Text3d> lsText;
    public MyConduit(){
      this.lsText = new List<Rhino.Display.Text3d>();
    }
    public void Add(Rhino.Display.Text3d txt){
      this.lsText.Add(txt);
    }
    public void Clear(){
      this.lsText.Clear();
    }
    protected override void CalculateBoundingBox(Rhino.Display.CalculateBoundingBoxEventArgs e)
    {
      base.CalculateBoundingBox(e);
      foreach(Rhino.Display.Text3d txt in this.lsText){
        e.IncludeBoundingBox(txt.BoundingBox);
      }
    }
    protected override void DrawForeground(Rhino.Display.DrawEventArgs e)
    {
      foreach(Rhino.Display.Text3d txt in this.lsText){
        e.Display.Draw3dText(txt, System.Drawing.Color.Green);
      }
    }
  }

Posts: 1

Participants: 1

Read full topic

RhinoObject deleted event

$
0
0

@ksobon wrote:

Is there a way to subscribe to RhinoObject deleted event? I noticed this method in the API:

https://apidocs.co/apps/rhinocommon/6/M_Rhino_DocObjects_RhinoObject_OnDeleteFromDocument.htm

Obviously its private and protected, but is there a different way that is publicly available? I don’t see anything on the ObjectTable. Can someone point me in the right direction?

Cheers!

-K

Ps. Digging a little deeper, I noticed the RhinoDoc event DeleteRhinoObject. Is that the event that is recommended to be used here?
Ps2. That seems to be doing the job.

Posts: 2

Participants: 2

Read full topic

Nested blocks - any pitfalls?

$
0
0

@Taavi_Looke wrote:

Hi!

I’m thinking about setting up a workflow that uses nested blocks and will manipulate them algorithmically (change the content of the blocks, replace blocks with other blocks). Probably the “nestedness” would go up to 10 levels deep. Technically it should not be very complicated, I’ll just have to keep track of a bunch of InstanceObject and InstanceDefinition objects.

However, are there any pitfalls with using nested block that might be non-obvious?

I’m asking this because in many other CAD softwares there are issues with nesting blocks and especially manipulating them algorithmically.

Regards,
Taavi

Posts: 7

Participants: 4

Read full topic

Problems with booleans and creating closed meshes using Rhinocommon

$
0
0

@aitorleceta wrote:

I’am struggling for days with some apparently simple boolean substractions.

i’am using brep.CreateBooleanSubstraction() under rhinocommon using ironpython in grasshopper.

the operation is being a substraction to a sphere of some closed solid, created revolving a curve.

9 or 10 substraction are being applied recursively to each sphere. Each time one brep vs brep. Tolerance used for the method is 1.

Finally a closed mesh object needs to be obtained. I’am using mesh.CreateFromBrep(brep,meshParam)

The process is working fine in 95% percent of the time. But in some cases, strange things happens.

When everything goes ok, the result looks like this:

but there are some cases that some little mosters appears, and rhino is considering them as “valid objects”

the resulting mesh appears like this:

Sometime the brep is closed, and apparently the geometry is visually ok and passed rhino check, but the resulting mesh using mesh.CreateFromBrep(brep,meshParam) with meshParam.JaggedSeam = False and meshParam.ClosedObjectPostProcess = True, gives as result an open mesh.

If I bake the brep and then manually convert to meshes, then all brep are converted to closed Meshes, except those brep that appear like the monster above.
Unfortunately, manual conversion is not a option. I could alternatively add brep objects to the document, use _Mesh command to convert them as long as this is the only secure manner to obtain closed meshes, and finally continue the operation in rhinocommon. But still the moster-like breps are misserably failling when converted to meshes, as shown in the image above.

All this is not making any sense to me. My nerves are almost done. Is this a bug? am I missing something?

Any help would be appreciated.

thanks

Posts: 4

Participants: 2

Read full topic

Viewing all 8524 articles
Browse latest View live