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

It is any way to learn more about rhino?

$
0
0

Hi,
I am interested in Geometric graphics, in the last few years,I have learned a lot of knowledge from the open source code of rhino, thank you rhino.
Now I must continue to learn if I am to make further progress. So I want to ask, it is possible rhino open the code still closed source like RhinoGetPerpendicularCurvePlane, sweep1, sweep2 …? :grinning:

3 posts - 2 participants

Read full topic


Creating 2d surface from Rows x Cols controlpoints

$
0
0

hi There,

Im trying to deform a texture using a grid of control points that initially are a uniform grid (texture is not deformed) and one can move control points to deform texture (a map between the rectangle and the new 2d surface)

Seems like a simple thing. However, after I create the surface, the result of PointAt(u,v), 0 <= u,v <= 1 are very different from the control points values (in the form Point4d(x,y ,0,1))

    size = [460, 250]
    dim = 3
    u_degree = 2
    v_degree = 2
            
    # creates internal uninitialized arrays for 
    # control points and knots
    self._surf = NurbsSurface.Create(
        dim,
        False,
        u_degree + 1,
        v_degree + 1,
        size[0],
        size[1]
    )
    u_knot = [0] * (size[0] + u_degree - 1)
    v_knot = [0] * (size[1] + v_degree - 1)

    for i in range(u_degree):
        u_knot[i] = 0

    for i in range(u_degree, len(u_knot)):
        u_knot[i] = 1.0

    for i in range(v_degree):
        v_knot[i] = 0

    for i in range(v_degree, len(v_knot)):
        v_knot[i] = 1.0

    
    # add the knots
    for i in range(0, len(self._surf.KnotsU)):
        self._surf .KnotsU[i] = u_knot[i]
    for j in range(0, len(self._surf.KnotsV)):
        self._surf .KnotsV[j] = v_knot[j]

    # Rational control points can be in either homogeneous
    # or euclidean form. Non-rational control points do not
    # need to specify a weight. 
    items = gridItem.GetItems()
    for row in range(len(items)):
        for col in range(len(items[row])):
            item = items[row][col]
            pos = item.pos()
            # log.error('>>>>>>>> ITEM row,col = %r, %r =>> %r, %r', row,col,pos.x(), pos.y())
            self._surf.Points[col, row] = Point4d(pos.x(), pos.y(), 0, 1)

Currently my control points vary x,y in range (0,0 to 460, 250)

But PointAt retturns in the range completelly different (75, 35).

I guess is something related to the knots. I have 11 knots.

What I need is the control points to stay in the surface matching teh regular grid initially, and then the grid will be deformed so the surface can map the texture deformation

What is missing?
Thanks!!

1 post - 1 participant

Read full topic

Rhino.NodeInCode

$
0
0

Hello Everyone,

To find the components that do not show up in the Library I use this method:

var component = Rhino.NodeInCode.Components.FindComponent(“string”);
var componenttFunction = (System.Func<object,object,object>) sort.Delegate;
A = componentFunction(variable,variable);
This method works when the function has only one output. For the components that they have more than one output I get "IronPuthon.Runtime.List " repeated the same number as outputs number.
How can I solve this problem and choose the desired output of chosen component?
Here as an example I tried to call Sort List component. I attach to this text here.

Best,

1 post - 1 participant

Read full topic

NurbsCurve.UVNDirectionsAt

$
0
0

Hi McNeel,

I just found these new methods for Rhino 7:

https://developer.rhino3d.com/wip/api/RhinoCommon/html/M_Rhino_Geometry_NurbsCurve_UVNDirectionsAt.htm
https://developer.rhino3d.com/wip/api/RhinoCommon/html/M_Rhino_Geometry_NurbsSurface_UVNDirectionsAt.htm

I thought that since curves are unidimensional objects, their second or third derivative was undefined in 360 degrees of freedom. And to get one, you have to use some heuristic. This is what I did in the next version of Peacock, I have a curve object that contains an alignment object to evaluate the normal at any parameter via the closest point direction to the alignment geometry.

So, how do define the normal direction of a curve? How do you make it consistent for any two parameters along the curve?

3 posts - 2 participants

Read full topic

How to join two surfaces to preserve their usertext

$
0
0

Hi there,

I am just looking for a solution for surface editing. How can the joint (flat on the same plane) surfaces preserve their UserText after joining them as probably new object is created after execution. I tried the JoinSurfaces and then MergeAllFaces command.

sf1 = rs.JoinSurfaces([sf1,objs[0][1]],True) # Delete original surface
rs.Command("MergeAllFaces SelID " + str(sf1)+ " _Enter",False)

I use Python.

1 post - 1 participant

Read full topic

Grip selection

$
0
0

Hi all. Rhino 6, 7 rhino common c#.
Is there some event to detectd the selection of control points ?
If not there is some trick like mouse up event to detect it ?

Thanks

1 post - 1 participant

Read full topic

Grips for holes?

$
0
0

Hi there,

I would like to ask if it is possible to modify a planar surface by its grips. I created a planar surface by the Planar Curve Command but the hole does not have grips. Is there other way to modify the planar surface to also retain the hole in the same position?

planar grips

1 post - 1 participant

Read full topic

Is something like "AddOptionString" possible?

$
0
0

Hi.

Is it possible to add a user input string to the options as in the image?
The user would take the following steps:

  1. Press “String=default value”
  2. Type a custom string as input
  3. Press enter
  4. Automatically go back to the same menu as in the image
  5. Press enter and continue the command

image

The situation in the image comes from this code example: https://developer.rhino3d.com/samples/rhinocommon/add-command-line-options/

Your answers would be greatly appreciated.

Josien

2 posts - 2 participants

Read full topic


New project Vazlat3D

$
0
0

Hi there, I have started a new project on Github.

The scripts are about a quick solid generator for architectural object such as wall, roof and slab. I wish to release more scripts in the next weeks bit by bit. My plan is, to develop it further to provide a standalone plugin, with user interface later.
My aim is to learn more and gain experience in programming.

If anyone wish to join, more then welcome.

I named it after a Hungarian word “vázlat” that means sketch.

1 post - 1 participant

Read full topic

Bug in Mesh.GetNakedEdges() when using double precision vertices

$
0
0

I noticed that there is a discrepancy of points returned by Mesh.GetNakedEdges() and the actual points in the Mesh.Vertices collection if double precision vertices are used. It would be nice if that method, which returns Polyline[] with double-precision vertices, uses the double precision vertices if available.

@dale can you put this in the bug tracker?

For a quick reproduction, see this code

public Result RunCommand(RhinoDoc doc, RunMode mode)
{
  Mesh m = new Mesh();
  m.Vertices.UseDoublePrecisionVertices = true;

  Random r = new Random(12345);
  m.Vertices.Add(new Point3d(r.NextDouble(), r.NextDouble(), r.NextDouble()));
  m.Vertices.Add(new Point3d(r.NextDouble(), r.NextDouble(), r.NextDouble()));
  m.Vertices.Add(new Point3d(r.NextDouble(), r.NextDouble(), r.NextDouble()));
  m.Vertices.Add(new Point3d(r.NextDouble(), r.NextDouble(), r.NextDouble()));

  m.Faces.AddFace(0, 1, 2, 3);

  Polyline[] pls = m.GetNakedEdges();
  if (null == pls || !pls.Any())
    return Result.Failure;

  foreach (Polyline pl in pls)
  {
    foreach (Point3d pt in pl)
    {
      Point3d closest = Point3d.Unset;
      double dist = Double.MaxValue;
      for (int i = 0; i < 4; ++i)
      {
        Point3d meshVertex = m.Vertices.Point3dAt(i);
        double d = (meshVertex - pt).SquareLength;
        if (d < dist)
        {
          dist = d;
          closest = meshVertex;
        }
      }

      RhinoApp.WriteLine($"Looking for: {pt.X:R} {pt.Y:R} {pt.Z:R}");
      RhinoApp.WriteLine($"Closest point: {closest.X:R} {closest.Y:R} {closest.Z:R}");
      RhinoApp.WriteLine($"Distance: {pt.DistanceTo(closest):R}");
    }
  }
  
  return Result.Success;
}

Output: 4x discrepancies O(10^-9):

Looking for: 0.066746935248374939 0.070159509778022766 0.774765133857727
Closest point: 0.066746934813795109 0.070159508879370752 0.77476513514982781
Distance: 1.6327766057913135E-09

1 post - 1 participant

Read full topic

Retrieve object from memory using its identifier

$
0
0

What would be the best way (ideally with IronPython) to access an object using its memory address?
By address I mean the hex identifier which is often part of repr string.

ie.:

import Rhino.Geometry as rg
curve = rg.Circle(rg.Point3d(0,0,0), 10).ToNurbsCurve()
print curve
print hex(id(curve))

<Rhino.Geometry.NurbsCurve object at 0x0000000000000083 [Rhino.Geometry.NurbsCurve]>
0x83

I am aware that referencing objects this way would be bad practice, but assuming Rhino keeps the objects in the memory I imagine it could be really useful for debugging (ie. logging the identifiers and later inspecting the geometry that caused an exception).

1 post - 1 participant

Read full topic

Writing Document User Data, Rhinocommon]

$
0
0

(topic withdrawn by author, will be automatically deleted in 24 hours unless flagged)

1 post - 1 participant

Read full topic

Plugin on Mac

$
0
0

Hi all,

I am trying to understand how rhp works on Mac.

  1. How/where Rhino finds/loads the plugin?
    From this document (https://developer.rhino3d.com/wip/guides/rhinocommon/uninstalling-plugins-mac/), it seems ~/Library/Application Support/McNeel/Rhinoceros/MacPlugIns/ is the place that Rhino loads plugin from. Is this the only place? or plugin can be loaded from a path that is added in something like Mac’s version of Registry (https://developer.rhino3d.com/guides/rhinocommon/registering-plugins-windows/)

  2. How does Rhino load plugin from Visual Studio’s debug mode?
    I am trying to test plugin in Mac’s Visual Studio, I found there are two items in plugin manager, and I checked each details, they are the same GUID, and file path. Plugin is still in plugin manager even after I removed rhp from the original path (on Windows, plugins will be unloaded if rhp is removed).


cc @dale

Thanks,
Mingbo

1 post - 1 participant

Read full topic

Is it possible to add a plane to geometry? What do you use User Data for?

$
0
0

I’m creating objects through a command I made and I’m wondering if it’s possible to add a plane to that object, such that I can access that plane from a different command without having to do lots of analysations. Is this something suitable for User Data? Or what do you use User data for?

1 post - 1 participant

Read full topic

How to know if a text is wrapped?

$
0
0

Hi, I work with .NET and I have a model with wrapped texts. I need to analyze each object and export it to a dxf file, if it is a text, I want to know if it is wrapped or not and the size of the adjustment to apply it to the exported text.
Is there a way to know if the text is wrapped through the object’s properties (Annotation Type) ?

1 post - 1 participant

Read full topic


WIP7. Material texture not showing on viewport. BUG?

$
0
0

Hi, I’m trying to assign a renderMaterial to a programatically added object using Python. Strange thing happening here:

Once object added to the document, I check in object properties the correct material was assigned.

If material color is defined by a bitmap, the texture is not displaying in Rendered mode.
If material color is defined with a color, the color is displayed correctly in Rendered mode.

In Raytraced mode material texture is correctly displayed IF when I baked the object display mode was NOT Raytraced. Otherwise, if rendermode was Raytraced, material texture wont appear correctly (burned out, incorrecty scaled)

if I manually change the textured material to diffuse material, and then reassign the textured material, then it will correctly show up in rendered mode.

I recorded a video to show this behaviour:


Seems a bug, but maybe I’m not correctly making things with my code…
import Rhino
import Rhino.Geometry as rg
from Rhino.RhinoDoc import ActiveDoc as doc

#create two boxes
interval = rg.Interval(0,100)
box = rg.Box(rg.Plane.WorldXY,interval,interval,interval)
box01 = box.ToBrep()
box02 = box01.Duplicate()
box02.Translate(150,0,0)

#retrieve renderMaterials by name
box01MatName = 'mat_textured'
box02MatName = 'mat_noTexture'
for mat in doc.RenderMaterials:
    if mat.Name == box01MatName:
        renderMat01 = mat
    elif mat.Name == box02MatName:
        renderMat02 = mat

#bake objects and get the RhinoObject
attr = doc.CreateDefaultAttributes()
id01 = doc.Objects.Add(box01,attr)
rhinoObject01 = doc.Objects.FindId(id01)
id02 = doc.Objects.Add(box02,attr)
rhinoObject02 = doc.Objects.FindId(id02)

#assign renderMaterials to RhinoObject
rhinoObject01.RenderMaterial = renderMat01
rhinoObject02.RenderMaterial = renderMat02

#commit changes
rhinoObject01.CommitChanges()
rhinoObject02.CommitChanges()

8 posts - 3 participants

Read full topic

Eto Window.Icon property raises "handle is invalid" exception in Rhino 6 SR26

$
0
0

After the recent service release for Rhino 6 (SR26), the Icon property of the Eto.Forms.Window class produces the following error:

The line of code referenced in the error message is shown below:
image
Note that “forms” and “drawing” refer to Eto.Forms and Eto.Drawing, respectively.

Commenting out the “self.Icon = …” line allows the plugin to run without error, but obviously precludes the use of a custom window icon.

My current fix is to just comment out the problem line of code and stick with the default icon, but I thought it would be worth posting here so others are aware of the bug.

2 posts - 2 participants

Read full topic

Automate iterations on rhino plug in (umi)

$
0
0

Hi,
I am using a plug in called UMI on Rhino 6. I can build a building in this plug in. However, I want to run 2000+ iterations of this building by changing a few input parameters, uploading different input files to the plug in, run the simulation and save these results. I do not know how to run these iterations since, as far as I know, the plug in does not have such a function where I can vary the parameters and generate different simulations automatically. What would you recommend me? should I try to automate these by creating a batch file? or should I do this in visual studio or in python? any tipps would be very much appreciated.

4 posts - 3 participants

Read full topic

RhinoCommon "Could not load file or assembly 'RhinoCommon,'

$
0
0

Hello,

I am trying to launch a specific file in Rhino from a C# application built in Visual Studio
It works fine just using Process.Start() but it opens a new instance of Rhino every time.
I would like to have Rhino already running and just have it open the specified file so i don’t have to wait for Rhino to start up every time.
I have tried the Rhino.RhinoDoc.Open()function but I get the following error

System.IO.FileNotFoundException:‘Could not load file or assembly ‘RhinoCommon, Version=6.2620147.6510,Culture=neutral,PublicKeyToken=552281e97c755530’ or one of its dependencies.The system cannot find the file specified.’

I seem to have the latest RhinoCommon installed and seem to have it referenced to my project.

Does anyone have any idea why this isn’t working?

2 posts - 2 participants

Read full topic

Winforms not returning errors in Rhino 6

$
0
0

Hello, I am developing a python plug in for rhino using the Winforms UI, and recently made the switch from Rhino 5 to Rhino 6. When I am testing the UI in Rhino 6 and press a button that should cause an error, nothing happens. Previously in Rhino 5 this would return an error in the Rhino Python Editor.

I am running the UI using Rhino.UI.Dialogs.ShowSemiModal(my_winform_ui)

Does Winforms act differently in Rhino 6 vs Rhino 5, or is there a variable I should have on to allow errors to show up?

Let me know what other information I should provide if needed. Thanks!

1 post - 1 participant

Read full topic

Viewing all 8706 articles
Browse latest View live


Latest Images