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

Add Texture

$
0
0

@jerry1 wrote:

Who can help me? when I use the example "Add Texture", the result locate the left figure,
its color is gray?? but I use the Rhino Function ... the color is normal(right figure)?

The "Add Texture" program whether lack of some thing?

Posts: 1

Participants: 1

Read full topic


Camera control / Clipping Planes

$
0
0

@wes_mcgee_3d wrote:

I feel like I have a good grasp of controlling the camera settings, but I am a little stuck on one thing. I am working out the math to "simulate" depth of field calculations for a given lens; by simulate, I was going to use the near and far frustrum planes as the bounds of the depth of focus. It all seems pretty fine until I get ready to set those planes (after calculating them based on the current aperature, etc.)

I don't see any relevant set method other than

(in Rhino.Display.RhinoViewPort)

    //
    // Summary:
    //     Sets optimal clipping planes to view objects in a world coordinate 3d bounding
    //     box.
    //
    // Parameters:
    //   box:
    //     The bounding box
    public void SetClippingPlanes(BoundingBox box);

This might be workable, but the fact that it is a world box makes me think its not so easy. If I could give it a box aligned to the camera, great. If its world and the camera is tilted, seems like a lot of extra maths. I have the planes calculated.

Assuming this is the only way...anybody have a tip on the math? Seems you need to make a world aligned bounding box with max diagonal that has endpoints on near/far planes.

Posts: 2

Participants: 1

Read full topic

Apply texture mapping for surfaces

$
0
0

@Tom_Holt wrote:

Hi,

Is it possible to apply texture mapping to surfaces?

For meshes there is something like this in RhinoCommon:
mesh.TextureCoordinates.SetTextureCoordinates(Mapping);

Is there similar thingy for breps/surfaces?

I tried this

private void RunScript(Guid x, Brep y, Plane p, ref object A)
{
Rhino.Render.TextureMapping textureMapping = Rhino.Render.TextureMapping.CreatePlaneMapping(p, new Interval(-400, 400), new Interval(-400, 400), new Interval(0, 1));
Rhino.DocObjects.Tables.ObjectTable.ModifyTextureMapping(x, 1, textureMapping);
}
http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_DocObject...
But I get error:
Error (CS0120): An object reference is required for the non-static field, method, or property 'Rhino.DocObjects.Tables.ObjectTable.ModifyTextureMapping(System.Guid, int, Rhino.Render.TextureMapping)' (line 74)
What does this error mean?

Posts: 1

Participants: 1

Read full topic

Could I modify the Repeat value in Rhino.DocObjects.TextureUvwWrapping.Repeat

Curve.MakeClosed Problem - maybe Bug?

$
0
0

@Tom_ wrote:

Dear @dale
Dear Everybody

Rhinocommon can not close this attached Curve:

makeClosed_test_or_bug.3dm (32.8 KB)

Something is wrong with the complex Curve (green at the right) in the attached Document. The curve is the former Brep-Face-Outer-Loop of a solid, the solid is designed in Solidworks and imported as sldprt.

Rhinocommon s Curve.MakeClose returns true on this curve, but the Curve is not closed afterwards.

Curve.IsClosed; // false
Curve.MakeClose(0.001); // returns true
Curve.IsClosed; // still false

i used the attached command to test.
works fine on the left open rectangle-shape.

what is wrong ?

Thanks for your Help.

best Tom

 protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        const ObjectType filter = Rhino.DocObjects.ObjectType.Curve;
        Rhino.DocObjects.ObjRef objref;
        Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetOneObject("Select curve to close", false, filter, out objref);
        if (rc != Rhino.Commands.Result.Success || objref == null)
            return rc;

        Rhino.Geometry.Curve crv = objref.Curve();
        if (crv == null || crv.IsShort(Rhino.RhinoMath.ZeroTolerance))
        {
            RhinoApp.WriteLine("Curve is short");
            return Rhino.Commands.Result.Failure;
        }

        if (crv.IsClosed)
        {
            RhinoApp.WriteLine("Curve already closed");
            return Rhino.Commands.Result.Success;
        }

        if (crv.MakeClosed(doc.ModelAbsoluteTolerance))
        {
            RhinoApp.WriteLine("MakeClose reports true");
        }
        string message = crv.IsClosed?"closed":"still open";
        RhinoApp.WriteLine("Now the Curve is " + message);

        doc.Objects.AddCurve(
            crv,
            new ObjectAttributes()
                {
                    Name = "ShoulBeClosedCrv",
                    ColorSource = ObjectColorSource.ColorFromObject,
                    ObjectColor = System.Drawing.Color.Red
                }
            );

        return Rhino.Commands.Result.Success;

    }

Posts: 4

Participants: 2

Read full topic

Offset direction

$
0
0

@feibih wrote:

Hi
I'm trying to change the direction my offset. In figure A is the result of my code, however, I want the offset to be in the direction of figure B.
I am having difficulty solving this in my code.

        Here is my code:

        var go = new Rhino.Input.Custom.GetObject();
        go.SetCommandPrompt("Select object");
        go.EnablePreSelect(true, true);
        go.EnablePostSelect(true);
        go.GetMultiple(0, 0);

        if (go.CommandResult() != Result.Success)
        {
            return go.CommandResult();
        }

        var selected_objects = go.Objects().ToList();
        foreach (var obj in go.Objects())
        {
            Point3d point1 = new Point3d(obj.Curve().PointAtStart.X + 0.2, obj.Curve().PointAtStart.Y, obj.Curve().PointAtStart.Z + 0.2);
            var curve1 = obj.Curve().Offset(point1, Vector3d.ZAxis, 2, doc.ModelAbsoluteTolerance, CurveOffsetCornerStyle.Sharp);
            foreach (var offset_curve in curve1)
            {
                Guid id = doc.Objects.AddCurve(offset_curve);
                doc.Objects.Select(id);
            }
        }
        doc.Views.Redraw();

Posts: 1

Participants: 1

Read full topic

Change material id

Parallel.For Crash

$
0
0

@Tom_Holt wrote:

Hi,
I would like to use Parallel.For for this simple loop:

private void RunScript(List guid, List plane, Box box)
{
for(int i = 0; i < plane.Count; i++){
Rhino.Render.TextureMapping textureMapping = Rhino.Render.TextureMapping.CreateBoxMapping(plane[i], box.X, box.Y, box.Z, true);
Rhino.RhinoDoc.ActiveDoc.Objects.ModifyTextureMapping(guid[i], 1, textureMapping);
}
}

I tried this one, but it crashes rhino immediately.
Honestly I am new to multi-threading, can somebody tell why crash occurs and how to properly use Parallel.For in this case? Thank you :slight_smile:

private void RunScript(List guid, List plane, Box box)
{
System.Threading.Tasks.Parallel.For(0, plane.Count, i => {
Rhino.Render.TextureMapping textureMapping = Rhino.Render.TextureMapping.CreateBoxMapping(plane[i], box.X, box.Y, box.Z, true);
Rhino.RhinoDoc.ActiveDoc.Objects.ModifyTextureMapping(guid[i], 1, textureMapping);
});
}

Posts: 9

Participants: 3

Read full topic


Read external 3dm file from grasshopper c#

Extracting the layer table from an external Rhino file

$
0
0

@PaulPoinet wrote:

Hi all,

I am retrieving an external 3dm file in Grasshopper (using c#).
I would like to access the layer table, with its nested information.

So far, I only managed to extract the layers as an IList.

This function seems limited since it is not possible to access the FullPath of each layer (the layers are defined here only by their name). Even by looping through those and calling the FullPath property, it only returns the name.
Then I tried to call the GetChildren() function and it returns an error.

Is there an alternative way to achieve what I try to do, or is the nested information lost if one attempts to read the layers from an external rhino file?

Posts: 9

Participants: 3

Read full topic

Run command in other command

$
0
0

@jordy1989 wrote:

Hi,

I have a function that requires the user to click some positions. It is possible for the user to use '_RotateView while clicking. Now I thought it was also possible to click my custom views functions while using this command.

Why is does these not work? BeginCommand is not called with my functions but is with the RotateView.
Do I need to set something to make a function work in other commands?

Thanks for reading.

Posts: 5

Participants: 2

Read full topic

VS Template for File Export

$
0
0

@Mary_Graham wrote:

Just starting to look at c++ plugins for Rhino5 64bit using VS 2010

Creating a sample using the "General Utility" template worked perfectly

Creating a sample using the "File Export" template throws this error:

TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified.

What do I need to change about the project to make this work?

Posts: 3

Participants: 2

Read full topic

Creating STL from vertices and faces

$
0
0

@jordy1989 wrote:

Hi all,

I got a list with vertices and a list with faces.
In each list the X, Y and Z or 3 items after each other.
Same with the faces. For example. In the face list a triangle is faces(0), faces(1) and faces(2).

I got this code to convert it to a STL.
But something is going wrong and I am just staring blind to a screen...

If someone got the time please take a quick look:

Dim x As Integer = 0
Dim y As Integer = 1
Dim z As Integer = 2
Dim filename As String = "testScan.stl"
Dim stlString As New StringBuilder
stlString.AppendLine("solid " & filename)
For i = 0 To Faces.Count - 1 Step 3

Dim face1 As Integer = Faces(i)
Dim face2 As Integer = Faces(i + 1)
Dim face3 As Integer = Faces(i + 2)

Dim p1() As Single = {vertices(face1 + x), vertices(face1 + y), vertices(face1 + z)}
Dim p2() As Single = {vertices(face2 + x), vertices(face2 + y), vertices(face2 + z)}
Dim p3() As Single = {vertices(face3 + x), vertices(face3 + y), vertices(face3 + z)}

stlString.AppendLine("facet normal 0.0 0.0 0.0")
stlString.AppendLine("        outer loop")
stlString.AppendLine("                vertex " & p1(x).ToString.Replace(",", ".") & " " & p1(y).ToString.Replace(",", ".") & " " & p1(z).ToString.Replace(",", "."))
stlString.AppendLine("                vertex " & p2(x).ToString.Replace(",", ".") & " " & p2(y).ToString.Replace(",", ".") & " " & p2(z).ToString.Replace(",", "."))
stlString.AppendLine("                vertex " & p3(x).ToString.Replace(",", ".") & " " & p3(y).ToString.Replace(",", ".") & " " & p3(z).ToString.Replace(",", "."))
stlString.AppendLine("        endloop")
stlString.AppendLine("endfacet")

Next
stlString.AppendLine("endsolid " & filename)

Posts: 3

Participants: 2

Read full topic

What's the structure of the array that the Mesh.Split() method returns when cutting with plane?

$
0
0

@Ivan1 wrote:

Hello,

so I am using a plane to cut / split meshes. The split method returns an array of meshes, but I want to determine which parts of the meshes are on which side of the plane. Generally speaking, when you cut an object, you get two pieces. Is there any structure within the returned array that gives me information about this specific problem.
Is there any order of the meshes inside the array at all?
Or are the meshes just "randomly" thrown together and then returned as an array?

Posts: 2

Participants: 2

Read full topic

Bug Report: Having Groups inside Block Instance

$
0
0

@dordek wrote:

Hi guys,

Whenever I make group inside block instances it works fine till the moment I close block edit mode. When I open block edit again, everything is ungrouped.
The only solution I have, for now, is to make another block instance inside this block but that sometimes gets too much of complication because for editing of that same group/block you need to find it in the hierarchy and edit it separate from the rest of the model so it usually takes more time for me. For example, when you are in block edit mode you can not match properties with the objects from the rest of the model directly, or have rest of the model (parent block) normally visible, and so on.

Basically, I wanted to ask if this is fixed already in some of the newer versions because maybe no one reported it. I am using Rhino 5.9.40609.20145 and I don't remember I had this problem in earlier versions.

Posts: 1

Participants: 1

Read full topic


ETO closing and reopening forms

$
0
0

@Jack_Perry wrote:

I have a question about ETO forms. I want to be able to close a form, and the redraw it later. When I run this script it doesn't allow me to call drawForm() a second time. Looking at the ETO docs, I learned that if I close a form I can reopen a new one, but it doesn't allow me to reopen a form that has already been opened and closed beforehand. Are there any work arounds to this?

Thanks so much, here is my code:

import Rhino
import rhinoscriptsyntax as rs
from Rhino.UI import *
from Eto.Forms import Form, CheckBox, TableRow, TableCell, Drawable, GroupBox, BorderType, Panel, DynamicLayout, VerticalAlignment, TableLayout, ColorPicker,Dialog, Label, TextBox, StackLayout, StackLayoutItem, Orientation, Button, HorizontalAlignment, MessageBox, ProgressBar, ImageView, TextAlignment
from Eto.Drawing import *
import scriptcontext
import os

dir = os.path.dirname(file)

Initialising form

initialForm = Dialogbool
initialForm.Title = "Automated House Design"
initialForm.Resizable = False

layout = TableLayout()
layout.Spacing = Size(5,5)
layout.Padding = Padding(10,10,10,10)

Defining textboxes, progress bars and buttons

progressBar = ProgressBar(Value = 0, MaxValue = 50)
addSelectedButton = Button(Text = "Add Selected to Favourites")

Defining checkboxes for images

checkbox1 = CheckBox()
checkbox2 = CheckBox()
checkbox3 = CheckBox()
checkbox4 = CheckBox()
checkbox5 = CheckBox()
checkbox6 = CheckBox()

favouritesArray = []
unwantedArray = []

Defining boxes for images

boxArray = []
box1 = ImageView()
box1.Image = Bitmap(os.path.join(dir, 'box.png'))

box2 = ImageView()
box2.Image = Bitmap(os.path.join(dir, 'box.png'))

box3 = ImageView()
box3.Image = Bitmap(os.path.join(dir, 'box.png'))

box4 = ImageView()
box4.Image = Bitmap(os.path.join(dir, 'box.png'))

box5 = ImageView()
box5.Image = Bitmap(os.path.join(dir, 'box.png'))

box6 = ImageView()
box6.Image = Bitmap(os.path.join(dir, 'box.png'))

def L(text):
return Label(Text = text, VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Right)

def drawForm():
#Drawing objects to form
layout.Rows.Add(TableRow(TableCell(L("Please choose which houses you like"))))
layout.Rows.Add(TableRow(TableCell(box1), TableCell(box2), TableCell(box3)))
layout.Rows.Add(TableRow(TableCell(checkbox1), TableCell(checkbox2), TableCell(checkbox3)))
layout.Rows.Add(TableRow(TableCell(box4), TableCell(box5), TableCell(box6)))
layout.Rows.Add(TableRow(TableCell(checkbox4), TableCell(checkbox5), TableCell(checkbox6)))
layout.Rows.Add(TableRow(TableCell(addSelectedButton)))
layout.Rows.Add(TableRow(TableCell(progressBar)))

initialForm.Content = layout

initialForm.DefaultButton = addSelectedButton


result = initialForm.ShowModal(RhinoEtoApp.MainWindow)

return result

def formclose():
drawForm()
initialForm.Close()
MessageBox.Show(" close 1")
drawForm()
MessageBox.Show("close 2")
initialForm.Close()

formclose()

Posts: 1

Participants: 1

Read full topic

Copying objects in Rhino memory issue

$
0
0

@Tom_Holt wrote:

Hi,

I would like to ask if it possible use more intelligent method than this.

What I am doing is basically taking one object guid.
Duplicate (copying it) it and transform it (scale, rotate and plane to plane transformation)

for (int i = 0; i < planes.Count; i++)
{
int c = i%G.Count;
Guid temp = Rhino.RhinoDoc.ActiveDoc.Objects.Duplicate(G[c]);
Rhino.RhinoDoc.ActiveDoc.Objects.Transform(temp, xform[i], true);
}

This is good for a few thousand objects, like above boxes.

But then I get memory issue, when copying much larger numbers of objects or objects are higher res.
It is O(n) operation and rhino file size increases from few mb to hundreads of megabytes, while I am just copying one single element with several transformations.

I noticed that copying blocks (I do not know how to do it using rhinocommon) does not increase Rhino file size as it is referencing to the same object and allows some basic transformation too. Maybe this would be method, I do not know.

What would be the best solution to have "light geometry" when copying once instance hundreads of times?
Could you please give a hand how to do it using rhinocommon?

Posts: 6

Participants: 3

Read full topic

EnableRedraw Python

$
0
0

@Jack_Perry wrote:

Hello,

I am using Rhino 6 WIP

I have a few

"rs.EnableRedraw = False"

scattered throughout my program, and none of:

"rs.EnableRedraw = True"

However, Geometry is still being drawn to the screen. I was wondering if maybe I have an error in the way I'm writing this? I've seen a few different documentations for this including: rs.EnableRedraw(False), rs.EnableRedraw = "False". I've tried a few of them but with no luck. I'm using Python.

I'm looking at this page for the documentation: http://developer.rhino3d.com/api/RhinoScriptSyntax/win/#document-EnableRedraw

If I try rs.EnableRedraw(False) i get an error: "bool is not callable"

Thanks.

Posts: 2

Participants: 1

Read full topic

Accessing only one group member

$
0
0

@PaulPoinet wrote:

Hi all,

I have a Rhino file with plenty of groups. Each group contains a considerable number of objects.
Those objects have the same name. I try to access quickly the name of one object in each group.
This is my code so far:

    // All groups in doc
    Rhino.DocObjects.Tables.GroupTable groupTableDoc = doc.Groups;

    // Iterate through the group table
    // and retrieve the name of the first object for each group
    List<string> objName = new List<string>();
    int groupCount = groupTableDoc.Count;
    for (int i = 0; i < (groupCount); i++){
      Rhino.DocObjects.RhinoObject groupObject = groupTableDoc.GroupMembers(i)[0];
      objName.Add(groupObject.Attributes.Name);
    }

    A = objName;

This method works but if one does that within a large rhino file containing more than 400 groups and each containing around 20-50 objects, it takes quite a long time (around 30sec) since it goes through all group members for each group.
Unfortunately, there is no .Item method within the GroupTable class in order to access only one specific group member.
Is there any other alternative you might think of?

Thanks

Paul

Posts: 1

Participants: 1

Read full topic

Curve piping rhino what is the logic behind light geometry?

$
0
0

@Tom_Holt wrote:

Hi,

I would like to ask what is the logic behind some of render commands related to geometyr such as curve piping?

These tools are created for rendering purposes.

Are they activated when rendering is running?
How is the goemetry stored as Instance objects or something else that it does not eat the memory?

Posts: 10

Participants: 3

Read full topic

Viewing all 8667 articles
Browse latest View live