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

Guid cannot convert to curve

$
0
0

@Lei_Yang1 wrote:

Hello guys,

I wanna refer crvs from layer by Horster Plug-ins and through that I got ID of the crvs.
However with the code “rs.coercecurve(ID)”, the ID cannot convert to curve as I needed.
There must be some piece of code that I missed so anyone know how to finish it?

Thanks so much!
Lei

Posts: 2

Participants: 2

Read full topic


Create Planar (UVW) texture mapping

$
0
0

@diana_lp wrote:

Hello,

I’m currently using this snippit to get a texture mapping onto a surface:

private TextureMapping GetPlanarMapping(Brep brep)
{
    var bbox = brep.GetBoundingBox(false);
            
    var mapping = TextureMapping.CreatePlaneMapping(
                    Plane.WorldXY, 
                    new Interval(bbox.Min.X, bbox.Max.X),
                    new Interval(bbox.Min.Y, bbox.Max.Y), 
                    new Interval(bbox.Min.Z, bbox.Max.Z));

    return mapping;
}

It creates a Planar (UV) mapping that is mostly correct but slightly offset. If switched (in the UI) to UVW it maps correctly. How can I create this as UVW?

Posts: 3

Participants: 2

Read full topic

Developer Rhino Page for Python is in VB?

$
0
0

@tom.norris23 wrote:

I am trying to find a way to escape python commands and this developer page looks like it should help: Canceling a Python script in Rhino but only the first two code snippets are python then the rest of the page is in VB?

The escape examples work as scripts BUT as commands they do not.

I am finding that in commands rs.sleep() does slow down the but does not give rhino a chance to listen to scriptcontext.escpae_test()

And in commands Rhino.RhinoApp.Wait() has no effect

Has anyone found a way to successful escape python commands in rhino 5?

Posts: 2

Participants: 2

Read full topic

Intersection.MeshRay with meshFaceIndices Overload using GHPython

$
0
0

@AndersDeleuran wrote:

Hi All,

I’m trying to implement this Intersection.MeshRay overload through GHPython (i.e. that return the “faces on mesh that ray intersects”). I think I’ve got it working, but just wanted to check that I’m going about it properly. Calling the overload through IronPython seems a wee bit convoluted this way:

import Rhino as rc
from System import Array
import clr

def meshRayIntersect(mesh,point,vector):
    
    """ Intersect a mesh with a ray, including intersected mesh face IDs """
    
    ray = rc.Geometry.Ray3d(point,vector)
    faceIDs = clr.StrongBox[Array[int]]()
    rayP = rc.Geometry.Intersect.Intersection.MeshRay(mesh,ray,faceIDs)
    if rayP:
        rayPt = ray.PointAt(rayP)
        faceIDs = list(faceIDs.Value)
        return rayPt,faceIDs
    else:
        return None

XPt, XIDs = meshRayIntersect(MyMesh,MyPoint,MyVector)

That is, having to instantiate an Array inside a StrongBox prior to calling rc.Geometry.Intersect.Intersection.MeshRay just to return the faceIDs. I might be way off here :man_shrugging:

Cheers,

Anders

Posts: 1

Participants: 1

Read full topic

Quad ON_MeshFace vertex ordering

$
0
0

@NathanM1994 wrote:

Hi,

Maybe a dummy question, I didn’t find any similar thread: for a given quad ON_MeshFace, are their four vertices vi ordered with a given criteria (clockwise or counter-clockwise)? How can I know it?

Thx
Nathan

Posts: 4

Participants: 2

Read full topic

Creating Brep from JSON

$
0
0

@merijndeleur wrote:

Hi Mike,

I realise this topic is 2 years old, however, I’m having the exact same problem.
I’m trying to reconstruct a brep from data I extract from another brep.

The situation:
I have a brep in a script (with trimmed faces) and I’m trying to export it to a JSON, which I can then read in another script to reconstruct it.
So I can get all the curves2d, curves3d, surfaces etc. But somehow I get an invalid brep when reconstructing. Exact same message as above. The preview in the rhino viewport shows the correct geometry by the way.

Did you have any luck fixing the problem?

  • Merijn

Posts: 2

Participants: 2

Read full topic

Custom drawn grips are randomly disappearing (C++)

$
0
0

@gccdragoonkain wrote:

Is there some “bounding region” mechanism or clipping behavior inside CRhinoMeshObject that causes custom grips to be clipped? I’m seeing my lines and points randomly disappear when dragged far away from the “source” object. I’m assuming there’s some bounding region I need to update?

Rendering code for my grips below:

void CRhinoMyObjectGrips::Draw(CRhinoDrawGripsSettings &dgs)
{
  UpdateMyObject();

  if(auto ccModel = controlCage.lock())
  {
	auto editInds = ccModel->getEditMeshTriangles();
	auto editIndsQuad = ccModel->getEditMeshQuads();
	uint3 *triData = (uint3 *)editInds->getData();
	uint4 *quadData = editIndsQuad ? (uint4 *)editIndsQuad->getData() : nullptr;
	int numTris = editInds->getCount()/3;
	int numQuads = editIndsQuad ? editIndsQuad->getCount()/4 : 0;

	for(int i = 0; i < numQuads; i++)
	{
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[quadData[i].x].GripLocation(), m_MyObject_grips[quadData[i].y].GripLocation());
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[quadData[i].y].GripLocation(), m_MyObject_grips[quadData[i].z].GripLocation());
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[quadData[i].z].GripLocation(), m_MyObject_grips[quadData[i].w].GripLocation());
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[quadData[i].w].GripLocation(), m_MyObject_grips[quadData[i].x].GripLocation());
	}

	for(int i = 0; i < numTris; i++)
	{
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[triData[i].x].GripLocation(), m_MyObject_grips[triData[i].y].GripLocation());
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[triData[i].y].GripLocation(), m_MyObject_grips[triData[i].z].GripLocation());
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[triData[i].z].GripLocation(), m_MyObject_grips[triData[i].x].GripLocation());
	}
  }

  CRhinoObjectGrips::Draw(dgs); //grip points are disappearing too
}

Posts: 5

Participants: 3

Read full topic

ETO for mac Visual Designer?

$
0
0

@ChristopherBotha wrote:

Hi all.

I am near final area of porting about 30 tools to a plugin, my problem is I want grasshopperesque controls, which are dead simple to create in winforms, and of course work fine in r5 and r6… but i want to be able to service mac platform too, meaning i have to go ETO,

I can find some code examples of how to do this, but its like going back to 1990 and hard coding the components in python TK. This means if i need to get back in there later its a nightmare to change code.

I tried using the eto VS snapin tool but cannot find its visual designer component that will allow me to manipulate sliders etc graphically.

Can anyone point me to a simple easy to understand tutorial on how to get ETO working similarly to just using visual studio forms designer?

Many Thanks!

Posts: 1

Participants: 1

Read full topic


Display performance question

$
0
0

@MateuszZwierzycki wrote:

Trying to capture multiple views in the most optimal way - is there any other option than RhinoView.CaptureToBitmap() ? I found this function quite slow (10 ms to capture one image), where the _testmaxspeed command runs here at >320 fps - effectively rendering the view in ~3ms. Thanks for any help in advance.

Posts: 2

Participants: 2

Read full topic

MeshFromPoints Rhino6 any .NET in RhinoCommon that can call this method?

$
0
0

@Petras_Vestartas wrote:

Hi,

Is there any rhinocommon method that call rhino6 command MeshFromPoints?

Or is it just that the same .rhp file and it will not be added as a method to call it throught .net?

a

Posts: 4

Participants: 2

Read full topic

C++ Template file

How to access PersistantSettings

$
0
0

@bartek wrote:

The Rhino command allows to override public override void LoadProfile(string lpszSection, ref RMA.Rhino.MRhinoProfileContext pc).
I can not find anything similar in Rhino 6. I have found PersistantSettings, but I have no idea how to access them. Is there any example?

Posts: 1

Participants: 1

Read full topic

Problem creating fillet between 2 curves by calling _Fillet command

$
0
0

@bmartin wrote:

Hello,

I’m trying to create a fillet between two curves on Rhino 5 SR14. It works like magic when I use the button and select the two curves but I cannot make it work from a Python script calling the _Fillet command. Attached, you will find the project containing the two curves and the script I’m using…

FiletTestProject.3dm (25.9 KB)

FiletCmdTest.py (834 Bytes)

Thanks for your help!

Bruno

Posts: 4

Participants: 2

Read full topic

Custom grips drag undo doesn't work

$
0
0

@gccdragoonkain wrote:

Now I know there are more high-level approaches to custom grips, but I prefer to keep this approach for now due to the versatility I may need in the future.

I’m implementing my custom grips and they are working fine, however when I drag a grip, then hit ctrl+z, while the mesh object resets correctly, the grips remain in the old wrong position. I expected these to reset and for CRhinoObjectGrips::NewObject() to be called (it isn’t).

What do I need to add here to make undo work as expected? I don’t (yet) use any custom data attached to the mesh or grips.

Posts: 1

Participants: 1

Read full topic

Pythonnet?

$
0
0

@kitjmv wrote:

Hello !

Have you a solution for use Python 3 ?
Or can i use Python+Pythonnet in replacement ?

Really, I’m confused, I’m starting to learn Python and it’s everywhere recommended to use Python 3.
I see,

and

and other experimental solutions, but Rhino is a professional tool, right?

Thank you

Posts: 1

Participants: 1

Read full topic


How to convert parameter space curve to on-surface curve

$
0
0

@gccdragoonkain wrote:

Is this possible? I want to evaluate straight-line (or 2D bezier) curves to curves along surface.

  double d00, d01, d10, d11;
  brep.Face(0)->GetDomain(0, &d00, &d01);
  brep.Face(0)->GetDomain(1, &d10, &d11);
  auto linearCurve = new ON_LineCurve(ON_2dPoint(d00, d10), ON_2dPoint(d01, d11));

  doc.AddCurveObject(somehowConvertToSurface(linearCurve, brep.Face(0))); //???

Posts: 1

Participants: 1

Read full topic

C++ iterative object display

$
0
0

@Petras_Vestartas wrote:

Hi,

I have simple question regarding displaying object through rhino pugins / c++.

  1. Is the only way to display object is by baking it? Like context.m_doc.AddSomeGeometryType()

  2. If I have simple for loop and in each iteration I move point by one unit in z axis. Each iteration I would like to display.

Would I need to somehow get existing point object in rhino and bake each time? Do rhino commands always executes a function only once? Or there is a similar approach like grasshopper ExpireSolution(true) method?

Is there any example illustrating this?
The reason for asking just for iterative display purposes while method is running.

Posts: 3

Participants: 2

Read full topic

Issue with events at compilation

$
0
0

@Matthieu_from_NAVINN wrote:

Hi,
I’ve got an issue with rhino event handlers: Everything works fine when I run my project on debug mode, but if I make a release and install it, the events are never raised.
Any idea?
Best regards
Matthieu

Posts: 2

Participants: 2

Read full topic

Picking group of objects with Geometry Filter

$
0
0

@D-W wrote:

I’m trying to pick group with geometry filer but i get message “Cannot use these objects.Removing them from selection”

With single object everything worked ok so i assume bitwise operators are here ok:

                go.AcceptNothing(false);
                go.DisablePreSelect();
                go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface | Rhino.DocObjects.ObjectType.Extrusion | Rhino.DocObjects.ObjectType.Brep | Rhino.DocObjects.ObjectType.Mesh | Rhino.DocObjects.ObjectType.InstanceDefinition | Rhino.DocObjects.ObjectType.InstanceReference;
                go.GroupSelect = true;
                go.Get();

@Dale would you mind to look at this? I tried adding go.GetMultiple(1,0) but nothing changed.

Posts: 3

Participants: 2

Read full topic

Curve.Offset and MSTest

$
0
0

@Chuck_Driesler wrote:

I’m writing a set of grasshopper components in Visual Studio 2017, and I have a collection of unit tests (set up with Tom Makin’s solution here) that have been working well.

Any time I try to run tests that involve Curve.Offset(), though, it throws my favorite error: “Object reference not set to an instance of an object.” I spent some time yesterday debugging the problem and am pretty sure it’s this specific method, and all of its versions.

For reference, I’m testing a slightly reformatted version of this older grasshopper component (which uses Curve.Offset() just fine). Lines 50 & 51 are the troublemakers in the new project’s tests.

This is my first time unit testing, and some searching brought up references to threading, which I’m not completely proficient in. Is this issue a limitation of certain RhinoCommon methods, or is it something I’m just approaching the wrong way?

Posts: 8

Participants: 3

Read full topic

Viewing all 8547 articles
Browse latest View live