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

Brep.ClosestPoint strange result

$
0
0

@djordje wrote:

There is a strange behavior that I am getting with Brep.ClosestPoint method in both Rhino 6 and Rhino 5.
I have a polysurface consisted of two, exactly the same (mirrored) surfaces.
There is a point in between them, lying in the middle of the brep edge that they share:

Judging by this reply from @menno, Brep.ClosestPoint is suppose to identify the closest point to be lying on the brep edge in the middle, which would then result in the normal of this point to be [0,0,1] (the average normal between two brep faces).

But for some reason Brep.ClosestPoint identifies that the closest point actually lies on one of the brep faces (brep face 1), which then incorrectly shows the normal to be the normal of that face.
Why is that so?
This is the example code:

import rhinoscriptsyntax as rs
import System
import Rhino
import clr

# inputs - brep, pt
brep_id = rs.GetObject("select brep")
pt_id = rs.GetObject("select pt")
brep = rs.coercegeometry(brep_id)
pt = rs.coerce3dpoint(pt_id)

# out parameters
closestPt_out = clr.StrongBox[Rhino.Geometry.Point3d]()
ci_out = clr.StrongBox[Rhino.Geometry.ComponentIndex]()
u_out = clr.StrongBox[System.Double]()
v_out = clr.StrongBox[System.Double]()
maxDist = 0
normal = clr.StrongBox[Rhino.Geometry.Vector3d]()


succ = Rhino.Geometry.Brep.ClosestPoint(brep, pt, closestPt_out, ci_out, u_out, v_out, maxDist, normal)

print "closest type: ", ci_out.ComponentIndexType  # prints "Rhino.Geometry.ComponentIndexType.BrepFace" instead of "Rhino.Geometry.ComponentIndexType.BrepEdge"

Any help would be welcomed.
Attached is the 3dm file brep closest pt.3dm (41.0 KB)

Posts: 4

Participants: 2

Read full topic


CaptureToBitmap()

$
0
0

@Matthieu_from_NAVINN wrote:

Hi,
I’ve got an issue with the function .capturetobitmap : the elements drawn on my custom display conduit are not captured. How could I fix this?

I tried

Dim myview As Display.RhinoView = doc.Views.ActiveView
Dim Bmp As Drawing.Bitmap = myview.CaptureToBitmap(New Size(myview.Size.Width, myview.Size.Height), False, False, False)

and

Dim myview As Display.RhinoView = doc.Views.ActiveView
            Dim view_capture = New Display.ViewCapture With {
                .Width = myview.ActiveViewport.Size.Width,
                .Height = myview.ActiveViewport.Size.Height,
                .ScaleScreenItems = False,
                .DrawAxes = False,
                .DrawGrid = False,
                .DrawGridAxes = False,
                .TransparentBackground = True
            }
            Dim Bmp As Drawing.Bitmap = view_capture.CaptureToBitmap(myview)

but in both cases the display conduit elements are not captured.

Posts: 1

Participants: 1

Read full topic

Add line perpedincular to existing line - c#

$
0
0

@gustavo.uzcategui wrote:

Hi,

Probably an easy question regarding C#, but after a few hours I am still not able to do it.
I have a slanted line and i would like to add line perpendicular to the existing line.
Can you please give me some hints how this can be done?

Posts: 3

Participants: 2

Read full topic

Inverted Text - mirror - c#

$
0
0

@gustavo.uzcategui wrote:

I have an inverted text with the mirror command, I want to put it normal again but without moving it from the position where it is-

Ex. image

I want to put it “This is a prove” without move his center

Code C#

Posts: 1

Participants: 1

Read full topic

C# Point array to C++

$
0
0

@db368 wrote:

I’m trying to get an array of points from C# to C++, but it doesn’t seem that there is a publically accessible interoperable type to do so. Going off of the C# api live on github, I can seee that PullPointsToSurface uses Rhino.Collections.Point3dList.GetConstPointArray() to pass points to a native function, however GetConstPointArray() is an internal type and cannot be accessed outside of rhino common itself.

Is there any way I can do this in my own dll?

Thanks in advance.

Posts: 2

Participants: 2

Read full topic

Create custom spline definition in c++

$
0
0

@mike8 wrote:

Rhino uses NURBS geometry that is constructed from a set of control points, weights, and NURBS basis functions.

I’d like to know if its possible for me to create my own spline definition and use in Rhino that are defined through my own custom basis functions and grips (control points). If so, what would this take? And where can I begin learning how to go about implementing something like this?

Thank you,
-mike

Posts: 1

Participants: 1

Read full topic

Refreshing DisplayConduit while in selection/option mode

$
0
0

@rgr wrote:

Hi,

I want to divide an object(for demo purposes I took a curve) and give the user the ability to preview the result by drawing planes at the division points by drawing a custom DisplayConduit. How can I refresh the display conduit everytime a different value is picked until the user is satisfied?

my feeble attempt below:

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        //create test curve
        Line ln = new Line(new Point3d(0, 0, 0), new Point3d(1000, 0, 0));
        doc.Objects.AddLine(ln);
        doc.Views.Redraw();

        //select:
        const ObjectType geometryFilter = ObjectType.Curve;
        int integer = 300;
        OptionInteger optionInteger = new OptionInteger(integer, 200, 900);

        GetObject go = new GetObject();
        go.SetCommandPrompt("Select Beam");
        go.GeometryFilter = geometryFilter;
        go.AddOptionInteger("Segment_Length", ref optionInteger);
        go.GroupSelect = false;
        go.SubObjectSelect = false;
        go.EnableClearObjectsOnEntry(false);
        go.EnableUnselectObjectsOnExit(false);
        go.DeselectAllBeforePostSelect = false;

        for (; ; )
        {
            GetResult res = go.Get();

            if (res == GetResult.Object)
            {
                break;
            }
            else if (res == GetResult.Option)
            {
                //if (go.Object(0).Object().Geometry != null)
                //{
                //    var myConduit = new MyConduit(go.Object(0).Object().Geometry as Curve, optionInteger.CurrentValue)
                //    {
                //        Enabled = true
                //    };
                //}

                continue;
            }
            else if (res != GetResult.Object)
            {
                return Result.Cancel;
            }
        }

        if (go.Object(0).Object().Geometry != null)
        {
            var myConduit = new MyConduit(go.Object(0).Object().Geometry as Curve, optionInteger.CurrentValue) { Enabled = true };
        }

        #endregion
        return Result.Success;
    }
}

class MyConduit : Rhino.Display.DisplayConduit
{
    private Curve Curve { get; set; }
    private int Divider { get; set; }

    public MyConduit(Curve curve, int divider) : base()
    {
        this.Curve = curve;
        this.Divider = divider;
    }

    protected override void PostDrawObjects(DrawEventArgs e)
    {
        base.PostDrawObjects(e);
        e.Display.EnableDepthWriting(false);
        e.Display.EnableDepthTesting(false);
        double[] parameters = this.Curve.DivideByLength(this.Divider, false);

        foreach (double param in parameters)
        {
            Plane pl = new Plane(this.Curve.PointAt(param), Plane.WorldYZ.Normal);
            Rectangle3d rect = new Rectangle3d(pl, new Interval(-200, 200), new Interval(-200, 200));
            e.Display.DrawCurve(rect.ToNurbsCurve(), System.Drawing.Color.MediumVioletRed, 2);
        }
    }
}

Posts: 1

Participants: 1

Read full topic

Make an object a layer

$
0
0

@falola.yusuf wrote:

I am generating objects via Rhinoscript, How can an make each object a layer, having its layer name and color.

Posts: 2

Participants: 1

Read full topic


Mirror correspondent

$
0
0

@gustavo.uzcategui wrote:

Hi, I’m using rhino 5 with c#

I have two identical geometries and i execute the _mirror command.
Is there any way to know which geometry is the mirror of another ? that is, which geometry corresponds a which mirror ?mirror

Posts: 2

Participants: 2

Read full topic

How to get a mesh from meshobject

$
0
0

@Mat_S wrote:

Starting with getting objects on a layer, I am trying to combine into a mesh.

objs = Rhino.RhinoDoc.ActiveDoc.Objects.FindByLayer(layername)

When going through the objs and running into a mesh:
rs.coercemesh(obj) returns None
obj.ObjectType returns MeshObject: (unamed)(-xxxxx)
rs.IsMesh(obj) returns False
mesh.Append(obj) returns an Error: Expected Mesh, got MeshObject

Posts: 2

Participants: 2

Read full topic

DynamicDraw - draw in shaded mode

IsPointOnFace from C++

$
0
0

@db368 wrote:

In a C++ library using the rhino SDK and Open Nurbs I’m trying to perform a check to see if a point returned from ON_Rayshooter_ShootRay is on a trimmed brep or not. I’ve seen a suggestion to use BrepFace.IsPointOnFace . in a previous post, however I’m having difficulty finding the method in C++.

Is there another way to perform this check, or am I missing something? Any help is appreciated.

Posts: 1

Participants: 1

Read full topic

Curve parameter coodinates

$
0
0

@ricardo.eira wrote:

Hello

I have this:

import rhinoscriptsyntax as rs
id = rs.GetObject(“Select a curve”)
if id:
point = rs.GetPoint()
if point:
param = rs.CurveClosestPoint(id, point)

    print "Curve parameter:", param

This return the parameter on curve closest from point, I need to Know
The coordinates xyz of this parameter curve, how I get this?

Thanks

Posts: 3

Participants: 2

Read full topic

Modify Text Object Justification (Python)

$
0
0

@dbodey wrote:

Hello,

Does anyone know how to modify Annotation Text justification without recreating the text using Python. AddText has a parameter to modify justification when creating text, but it does not appear that TextObjectJustification was created for Python.

This is my assumption because this exists:

https://developer.rhino3d.com/api/rhinoscript/geometry_methods/textobjectjustification.htm

But it is not in this list:
https://developer.rhino3d.com/api/RhinoScriptSyntax/#geometry-TextObjectText

If I am simply misunderstanding something, please let me know.

Thank You

Posts: 1

Participants: 1

Read full topic

Trim/Split Brep with multiple cutters

$
0
0

@Dmitriy wrote:

Hi,
As I see Brep has a Split method for accepting of the multiple cutters.
I did a simple example (see enclosed) but cannot see desired result (blue surface to be split by 2 green surfaces):
Trim_Split_Example.3dm (52.6 KB) Trim_Split_Example.gh (2.9 KB)
What can be the problem?

Another question: is it possible to add also multiple cutters for Trim method in RC?

Thanks,
Dmitriy

Posts: 1

Participants: 1

Read full topic


Rhino Light Power parameters

$
0
0

@marton.parlagh wrote:

The RhinCommon API exposes some Rhino Light Power parameters:
PowerWatts
PowerLumens
PowerCandela

Are these used anywhere? Or these are only placeholders for future stuff?

(When I check these the values are always 0)

Márton

Posts: 1

Participants: 1

Read full topic

Gumball API Documentation

$
0
0

@SergeyK wrote:

I’ve tried to create a custom gumball for my own objects, but I’ve often seen the "Missing <summary> documentation" in the RhinoCommon API. It creates some problems for understanding what’s going on and how to make what I want.
Can you provide some description of this functionality?

Posts: 1

Participants: 1

Read full topic

Is there a rhinocommon method as _BooleanSplit command?

Layouts // Review

$
0
0

@zale_orcid wrote:

Hi would anyone like to work with me on a workflow that is best set up for my practice?

I have a lot of confidentiality and contractual problems but if I can work in private with someone and show them exactly what I am looking for, I think I could really nail this workflow.

It’s challenging, and I need someone who is knowledgeable in blocks, scripting/programming/plugins, can help me to implement some of these cool scripts I have found and create a really solid process…

We will take a look at my current 2d drawing packets and we will attempt to convert them to what I have in mind. I will need to create custom view settings, peterstools (I think), these page layout tools (I think) and somehow figure out how to do the blocks correctly so I do not need to explode and lose the data. All while trying to minimize the file size. Which is why I have resorted to 2d linework and no 3d models in my layouts because the file size is insane. BUT I’m running into issues with revisions (as usual) which is why I wished for “dynamic views/make2d”… this would solve everything. I think this is essentially section tools but not just for sections. Can I just use section tools for any view ? will this work?

I’ll need all views but special views, like showing the framing only and not having to deal with “hideindetail” ?, or exploded views that keep everything intact. I’m going to have to utilize saveview, I’m looking for an exploded assembly function/script/whatever — do they exist?

Also does anyone have a cool pack of “view styles” that do not come with Rhino? I do not mind creating my own but I’m hoping something close to what I am looking for has already been done.

Basically Im hoping to find someone who can look at my current process and improve upon it or give me a completely different persepective. I’ve been using rhino layouts for a long time and I’ve struggled immensely with it. But I’m glad I’m still here because it has improved and I have faith one day it will get to that epic level of modeling and drawing. I feel its really close.

Posts: 1

Participants: 1

Read full topic

EnsurePrivateCopy() on an InstanceDefinition causes overflow

$
0
0

@clement wrote:

Hi @dale,

i accidentally used EnsurePrivateCopy on an InstanceDefinition which crashed RH6 caused by some kind of overflow. To reproduce:

import Rhino

def DoSomething():
    msg = "Select block instance"
    obj_type = Rhino.DocObjects.ObjectType.InstanceReference
    rc, obj_ref = Rhino.Input.RhinoGet.GetOneObject(msg, False, obj_type)
    if rc != Rhino.Commands.Result.Success: return
    
    iref = obj_ref.Object()
    if not iref: return
    idef = iref.InstanceDefinition
    if not idef: return

    try:
        idef.EnsurePrivateCopy()
    except Exception as ex:
       print ex

_
c.

Posts: 1

Participants: 1

Read full topic

Viewing all 8527 articles
Browse latest View live