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

Rhino Compute without Rhino3dmio native dll

$
0
0

@adsysingle wrote:

I don’t know if this is the right place to ask, but I’ve been exploring using Rhino Compute with Unity. I have it working great on desktop, but I’d like to build it to WebGL.
This presents the obvious issue of the need to include Rhino3dmio native dlls. From reading their description, it seems to indicate that the purpose of this dll is for reading and writing 3dm files. Which I don’t want to do. I want to be able to call the geometry methods on the Rhino Compute server and get results to do things with in Unity.
Is there a way around needing the Rhino3dmio dll?

Posts: 1

Participants: 1

Read full topic


Cannot set mesh parameters in order to get only triangles faces

$
0
0

@margari wrote:

Hello,
I’m trying to get a only triangles’ mesh from a ON_BrepFace.
I read in the documentation that the following function (from ON_MeshParameters class) could help me to reach my purpose:

  // 0 = mixed triangle and quads
  // 1 = all triangles
  // 2 = all quads
  const unsigned int FaceType() const;
  void SetFaceType(
    unsigned int face_type
  );

Unfortunately it seems that I’m doing something wrong because after the mesh generation, if I check how many quads the mesh has I reported a number major then 0.
Then if I call the ConvertQuadsToTriangles() function i obtain what I want.

The following is my code:

ON_MeshParameters parameters = ON_MeshParameters::DefaultMesh;
parameters.SetTolerance(0.1);
parameters.SetFaceType(1);

ON_Mesh* mesh = p_bf->CreateMesh(parameters);

int quadNumber = mesh->QuadCount(); // quadNumber = 3744
if (mesh->QuadCount() > 0)
{
   mesh->ConvertQuadsToTriangles();
}
quadNumber = mesh->QuadCount(); // quadNumber = 0

Can you help me?
Many thanks.

Posts: 1

Participants: 1

Read full topic

RhinoCommon: Restore Defaults button on my OptionDialogPage

How to get Custom UnitSystem in RhinoCommon

$
0
0

@benoit.deschenes wrote:

Hello,

We are developing a C# plugin using the RhinoCommon API for Rhino5 & Rhino6 and I am looking for a way to get the scaling value of the “Custom” UnitSystem. The documentation mentions that this value is available in the ON_UnitSystem class (or ON_3dmUnitsAndTolerances depending on the API version), which doesn’t seem to exist inside RhinoCommon and looks like to be an OpenNurbs class. ( https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_UnitSystem.htm or https://developer.rhino3d.com/5/api/RhinoCommon/html/T_Rhino_UnitSystem.htm )

Where would this information be available inside RhinoCommon? Or is it available in OpenNurbs only?

Thank you.

Posts: 2

Participants: 2

Read full topic

C# Splitting Data Tree into smaller chunks- incorrect output

$
0
0

@su.lwpac wrote:

Hi,
I am trying to split a data Tree into smaller chunks.
the Code seems to be working all fine, You can see here:

private void RunScript(DataTree<object> inputTree, ref object A)
  {
    var microTower = SplitBranchLists(inputTree);

    A = microTower;

  }

  // <Custom additional code> 

  public DataTree<object> SplitBranchLists(DataTree < object > inputDataTree)
  {
    DataTree<object> splitBranchLists = new DataTree<object>();
    int splitSize = 3;
    for(int i = 0; i < inputDataTree.BranchCount; i++)
    {
      var dataPath = inputDataTree.Paths[i];
      var dataList = inputDataTree.Branches[i];
      var remainder = dataList.Count % splitSize;
      var divisor = dataList.Count / splitSize;

      for (int n = 0; n < divisor; n++)
      {
        for ( int k = 0; k < dataList.Count - remainder; k += splitSize)
        {
          var tmpsum = 0;
          var startIndex = k + tmpsum;
          splitBranchLists.AddRange(dataList.GetRange(startIndex, splitSize), new GH_Path(dataPath.AppendElement(n)));
          Print(dataList.GetRange(startIndex, splitSize).Count.ToString());
          tmpsum += splitSize;

        }
      }
    }
    return splitBranchLists;
  }

But the Output is not what is expected.

Here is the Script also:
SplitDataTree.gh (9.5 KB)
What is missing, any Idea?

Posts: 2

Participants: 2

Read full topic

C# deleted object in Grasshopper

$
0
0

@Steven wrote:

Hi there,
I’ve been playing around with C# grasshopper components to access the document ObjectTable through rhinocommon. Originally I was looking into how blocks work in Rhino. I noticed that when geometry is ‘converted’ into a block, the original geometry is deleted and copied with a new GUID to the objectTable and referenced by the instancedefinition (block).
This got me wondering what other geometry might be stored in the table, but not “visible”. I noticed that deleted geometry stays on the table until the file is closed, saved and reopened. However, at least from within grasshopper, I’m having difficulty getting a list of the deleted geometry.

For example: I start a new Rhino document and draw three rectangles.
I use the following code to count objects on the geotable:

Rhino.DocObjects.Tables.ObjectTable ot = Rhino.RhinoDoc.ActiveDoc.Objects;
Print(ot.Count.ToString());
foreach (Rhino.DocObjects.RhinoObject objects in ot.GetObjectList(Rhino.DocObjects.ObjectType.AnyObject)) {
  Print(objects.ObjectType.ToString());
  Print(objects.Id.ToString());
}

and it outputs “3” and “Curve” and the GUID of each curve.
I then delete one of the rectangles, hit F5 and the count still says “3” but the list only shows 2 Curves.
I then use the following, but neither loop returns the deleted geometry:

Rhino.DocObjects.ObjectEnumeratorSettings settings = new Rhino.DocObjects.ObjectEnumeratorSettings();
settings.DeletedObjects = true;

Rhino.DocObjects.RhinoObject[] obj = ot.FindByFilter(settings);
for (int i = 0; i < obj.Length; i++) {
  Print(obj[i].Id.ToString());
}
foreach (Rhino.DocObjects.RhinoObject objects in ot.GetObjectList(settings)) {
  Print("   " + objects.Id.ToString());
}

Any suggestions?
As a side note, there is a lot of missing documentation on the rhinocommon site, which isn’t making this exploration any easier! Took me a long time to work out the difference between “InstanceDefinitionTable”, “InstanceObject”, “InstanceReference”, "InstanceDefinition, and “InstanceDefinitions” :smiley:

Thanks,
Steven

Posts: 1

Participants: 1

Read full topic

Rhino3dm.net read custom userdata

$
0
0

@jessen.ch wrote:

Hello,

I would like to know if there is a way to read custom UserData.

The userdata was writen from a rhino plugin. And I do know the GUID and the definition of the userdata.

However I could not find a way to read this userdata in rhino3dm.net, even though I tried to get the data with the same type. It always returns null.

I noticed that I can read it in rhino plugin as this userdata is somehow “registered” when rhino is loaded. But with rhino3dm.net this step seems to be missing…

I would be very grateful if there’s a solution.

Best,
Chen

Posts: 1

Participants: 1

Read full topic

Same command on two plugins best pratice

$
0
0

@MatrixRatrix wrote:

Hello ,

I have several custom commands, and I need to share these commands by more than one pugin on the same pc.

All plugins will need the same commands, I can’t repeat the same command on two different plugins on same pc, but I need that same pc run just one, or just the other, or the both plugins.

What is the best solution in this specific case?

Thanks

Posts: 5

Participants: 2

Read full topic


RhinoDoc.ModifyObjectAttributes fired after each object attribute change

$
0
0

@Will_Wang wrote:

The problem is I want the event handler to only run after all modifications have concluded
Right now if I select 5 objects and change their display color together, my event handler is called 5 times

Posts: 1

Participants: 1

Read full topic

You may need to update the latest Rhino service release to use this plug-in

$
0
0

@nevin.mathew wrote:

Hi ,

we have developed a plugin using the "RhinoCommon Plug-In for Rhinoceros 6 (c#)

RhinoCommon6

When we try to install it on one of the designers machine which have Rhino 5 ,
it’s showing up a message that

“you may need to update the latest Rhino service release to use this plug-in”

MicrosoftTeams-image

Read this link below and checked we have the latest service release, its showing the all the latest service releases are in place
https://wiki.mcneel.com/rhino/getrhinoservicerelease

is there any way we can install this plugin on the machines where Rhino 5 is installed.

thanks,
Nevin

Posts: 4

Participants: 2

Read full topic

Change surface color retrieved from GetObject

$
0
0

@thomas.vincent wrote:

Hello,

I am currently trying to change the color of selected surfaces with GetObject.
When the object is exploded, there is no problem, my code works, but as long as different surfaces are joined, it colors the whole object.

I’ve used this loop to color the object, and I understand that selecting the RhinoObject is the problem, but I couldn’t find a way to change the color of a BrepFace or simply a Surface (go is my GetObject object).

for (int i = 0; i < go.ObjectCount; i++) {
    ObjRef objRef = go.Object(i);
    RhinoObject obj = objRef.Object();
                
    RhinoDoc doc = obj.Document;
    obj.Attributes.ObjectColor = System.Drawing.Color.FromArgb(color.ToArgb());
    obj.Attributes.ColorSource = ObjectColorSource.ColorFromObject;
    obj.CommitChanges();

    doc.Views.Redraw();
}

I am able to retrieve the BrepFace with objRef.Face() and the Surface from the BrepObject but I can’t find any method or attribute that can help me. Any ideas?

Thank you for your answers,
Thomas.

Posts: 1

Participants: 1

Read full topic

What format save a rhino model to upload in Python?

$
0
0

@l.scarzanella wrote:

Hi there, I am making a model with Rhino and I need to upload it in Python as I need to work with the coordinates of the models points. What is the best format I should save my model?

Posts: 5

Participants: 2

Read full topic

Rhino _-Export commands hang when started by a service

$
0
0

@Thierry_BOCK wrote:

Hello,
Rhino hangs when calling _-Export “c:\path\to\file.dxf” a second time
Rhino is started by a script running in the background (session 0), so i cannot see what the problem is. To narrow down the problem, i have used File.WriteAllText.
The plugin is working as expected when called by a script from the powershell command, but not when run from a background service.

The file contains many objects in groups spread over several layers.
for each group clear the current selection, then select the objects of the group, and export them
the problem occurs when i export objects the second time using (path beind the dxf file path, i have set _acadschemes, but also fails with ’ _Scheme=“2004Natural” _Enter’ , note it is a custom scheme based on “2004 Natural”, not a typo):

string cmd = “_-Export “” + path + “.dxf” _Enter”;
if (!RhinoApp.RunScript(cmd, true)) {/* code to log the error */}

i have tried everything I could think of.
this : RhinoCommon - SaveAs does not work ( the delegate is not called when it should be).

Also, the same happens with dwg

Switching to Rhino6 is not currently an option.

Posts: 2

Participants: 1

Read full topic

The Centroid Coordinates Product Moments is not available in RhinoCommon's Area Mass Properties

$
0
0

@taquet wrote:

Hello,

The Product Moments is accessible through the GUI’s Analyze > Mass Properties > Area Moments.

However, it is lacking in the RhinoCommon class:
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Geometry_AreaMassProperties.htm

FYI, I want to access it through Grasshopper.
Also, the WorldCoordinatesProductMoments is available in RhinoCommon, but I believe the Huygens-Steiner theorem of transport only applies when the original axis goes through the centroid of the surface. If anyone has a clue on a more general transport theorem, I am also interested.

Thanks!

Posts: 2

Participants: 2

Read full topic

Should the ExtrudeSurface method be influenced by the curve direction?

$
0
0

@DanBayn wrote:

I noticed that I can get different results when extruding a surface depending on the curve direction. To me this doesn’t make sense. This is how the method is supposed to work according to the help file:

image

But this is how it actually works:

But if I flip the direction of the curve, the extrusion is created where I would expect it to be (following the curve).

image

This doesn’t seem like it’s working correctly to me. I don’t think the curve direction should be a factor at all.

Thanks,

Dan

Posts: 1

Participants: 1

Read full topic


Spacebar is not the same as Enter for ETO forms

$
0
0

@DanBayn wrote:

I have users complaining that the spacebar does not behave like the Enter button to pick the highlighted button on the form. I checked that and I see that too. Enter will use the highlighted button but the spacebar moves the focus to other areas of the form.

image

Is there something I need to add to my script to allow the spacebar to behave as the Enter (so that it is in harmony with what Rhino users are used to)?

Thanks,

Dan

Posts: 1

Participants: 1

Read full topic

RhinoCommon: Access to Bottom/Status Progress Bar

Rhino C++ GetUserString

$
0
0

@aitorerana wrote:

Hi,

I’ve a problem with mi Rhino C++ plugin.
I want to set some attibutes to some objects. I found this code and aparently the first part works propertly (I think) but to ensure I want to catch that user string and print it. The ref and obj are from an array and it loops okey.

const CRhinoObjRef& ref = gv.Object(i);
const CRhinoObject* obj = ref.Object();

if (!obj)
	return failure;

ON_wString key = L"test";
ON_wString text = L"sample text";

// Part 1 start
CRhinoObjectAttributes attribs = obj->Attributes();
attribs.SetUserString(key, text);
context.m_doc.ModifyObjectAttributes(ref, attribs);
// Part 1 end

// Parte 2 start
ON_wString textStr;
attribs.GetUserString(key, textStr);

ON_wString userTextStr;
userTextStr.Format(L"UserText: %s\n", textStr);
RhinoApp().Print(userTextStr);
// Parte 2 end

Thanks.

Posts: 3

Participants: 2

Read full topic

RhinoCommon: Get Rhino Bounds

$
0
0

@lucabrasi wrote:

Hi,

Is there a way to get from Rhinocommon the Rhino bounds? The position of the Rhino window in the screen as in RhinoView.Bounds property.

Thanks,

Posts: 1

Participants: 1

Read full topic

Rendered mode doesn't show objects transforming dynamically (C++)

$
0
0

@Pablo_Garcia-Amorena wrote:

Hi @dale,

I followed your sample Showing Objects Transforming Dynamically to have a getter that draws dynamic transformations on objects.

The problem is that the object is not dynamically shown when display mode is Rendered. All other modes (Shaded, Wireframe) work well.

Do you know how to display the object also in Rendered mode? It’s not important if it’s drawn as wireframe or shaded or with its default material.

I attach here the sample I used (I noticed the code in your link is a bit outdated). It lets the user select an object and define two points to translate it.

cmdSampleTranslate.cpp (5.0 KB)

Thank you very much,
Pablo

Posts: 1

Participants: 1

Read full topic

Viewing all 8565 articles
Browse latest View live