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

Why GH display strangely if the solid brep is created in GHPython with Rhinocommon?

$
0
0

@RetroPost.LT wrote:

Hello All!:grinning:

The below one is solid brep, after using “rg.CreateSolid” or “rg.MergeBreps” or “rg.JoinBreps” in GHPython
In in the middle is surface in GH, after explode the brep.
The top one is the solid brep after bake into Rhino.

Why the below one’s side face divide into 3 part? Is there any way to let it display flat?

Posts: 2

Participants: 2

Read full topic


Best method to loop through Objects to find out what type they are?

$
0
0

@TobyLai wrote:

I am creating a command to allow user to select a bunch of objects on a plane.

My question is how do I loop through the list of objects as there are many types. At the start, I may just want to handle only Curve and TextEntity.

I use GetObject function to get any objects.

But what I find is do I use the GetType() and compare the type of Object.

Is there a smarter way of looping through the list of Geometry?

GetResult result = go.GetMultiple(1, -1);

     for (int i = 0; i < go.ObjectCount; i++)
     {
        // Check the type of the Object and process differently

        GeometryBase geo = go.Object(i).Geometry();


        geoList.Add(geo);

     }


     foreach (GeometryBase g in geoList)
     {
        if(g.GetType().Equals(typeof(PolyCurve)))
        {
           System.Windows.Forms.MessageBox.Show("PolyCurve");
        }
        else if(g.GetType().Equals(typeof(Curve)))
        {
           System.Windows.Forms.MessageBox.Show("Curve");
        }
        else if(g.GetType().Equals(typeof(TextEntity)))
        {
           System.Windows.Forms.MessageBox.Show("TextEntity");
        }


     }

Posts: 2

Participants: 2

Read full topic

Draw on ON_Plane

$
0
0

@a.ugryn wrote:

I tried create new ConstructionPlane and than I tried draw ON_Line on the new Plane, but this line was created relatiw World plane. How can I create new geometry on new plane.

CRhinoView* view = RhinoApp().ActiveView();
if (!view) return CRhinoCommand::failure;

ON_3dmConstructionPlane cplane = view->Viewport().ConstructionPlane();
ON_3dPoint or (40,40,40);
ON_3dPoint aX(100, 40, 40);
ON_3dPoint aY(40, 100, 40);

ON_Plane pln = cplane.m_plane;
pln.SetOrigin(or );

Posts: 1

Participants: 1

Read full topic

C++ Plugin development beginner question

C++ plugins debugging and restarting rhino

$
0
0

@Petras_Vestartas wrote:

Hi,

When creating rhino plugin:

Does every change in visual studio needs restarting rhino to run the code in debug mode?
For instance if I would like to stop rhino while running and change something lets say declare new variable do I need to exit rhino - stop program, build plugin, then load plugin in rhino and test function again? Or is it possible to do it interactively similarly like with grasshopper plugins and visual studio?

Also is it possible to load the plugin in rhino so I would not need to install every time rhino is opened?

Posts: 3

Participants: 3

Read full topic

C++ add ngon to mesh

$
0
0

@Petras_Vestartas wrote:

Would it be possible to get a sample how to add ngon to mesh using c++?

Also why mesh.SetTriangle(int,int,int,int) and mesh.SetQuad(int,int,int,int,int) have +1 number?
For setting up triangle what does the first int represent - is it id?

Is it something like this for defining hex mesh as ngon?
Or there are other option to do this?

int face_count = 6;
int vertex_count = 12;
BOOL bVertexNormals = FALSE;
BOOL bTextureCoordinates = FALSE;

ON_Mesh mesh(face_count, vertex_count, bVertexNormals, bTextureCoordinates);

mesh.SetVertex(0, ON_3fPoint(0.45f, 5.37f, 0.0f));
mesh.SetVertex(1, ON_3fPoint(-0.16f, 4.32f, 0.0f));
mesh.SetVertex(2, ON_3fPoint(0.44f, 3.26f, 0.0f));
mesh.SetVertex(3, ON_3fPoint(1.66f, 3.25f, 0.0f));
mesh.SetVertex(4, ON_3fPoint(2.28f, 4.31f, 0.0f));
mesh.SetVertex(5, ON_3fPoint(1.67f, 5.37f, 0.0f));


mesh.SetTriangle(0,0,2,1);
mesh.SetTriangle(1,5,2,0);
mesh.SetTriangle(2,3,2,5);
mesh.SetTriangle(3,5,4,3);


mesh.ComputeVertexNormals();
mesh.Compact();

unsigned  int m_Vcount = 6;
const unsigned  int m_vi[8] = { 5,4,3,2,1,0 };
unsigned  int m_Fcount = 4;
const unsigned  int m_fi[6] = {0,1,2,3};


mesh.AddNgon(m_Vcount, m_vi, m_Fcount, m_fi);

context.m_doc.AddMeshObject(mesh);
context.m_doc.Redraw();

Posts: 1

Participants: 1

Read full topic

How to change Backface color

$
0
0

@jinwook_Kim wrote:

Hi everyone!

I want to apply different color on surface or mesh.(Display - Object settings - Color Backfaces - Backface color)
There were few topics use Backdiffuse. I read that topics and tried to apply but it’s hard to me.
And I have no idea the Backdiffuse is correct solution…
So I got a few question.

  1. How to change Backface color using rhinoscript or Rhino common sdk?
  2. Can I use Backdiffuse in Rhino 5 windows? Now I using Rhino 5 in windows.
  3. Is there any site or doc which explain how to use Rhino common by python?

Thank you.
Jinwook Kim.

Posts: 1

Participants: 1

Read full topic

Plugin localization


Mesh boolean difference resulting in sum

"Remembering" command options

$
0
0

@jeroenvanlith wrote:

Hey there,

I was wondering how one can “remember” certain command options when a user runs a command. In my current program, the values are always reset to some hardcoded default options.

Does anyone know how to change this?

Thank you,

Jeroen

Posts: 3

Participants: 2

Read full topic

Create NGon Mesh Rhinocommon c#

$
0
0

@tsiddikee wrote:

Hi, I am giving PolylineCurve List as input. That means I have 100 closed planer Polyline Curve and I want a single mesh with ngons .
With single Ngon I could work out how it works.

–Can I take multiple NGons as input and get a single mesh ?
–Does NGon supported in grasshopper Rhino 6?

I tried to draw Ngon mesh, but it is giving only the Ngon for the last Polyline curve in the list.
Just one Ngon.
I never used Ngon before, so please let me know what I did wrong below:

It can be a silly mistake but I am not able to find it ;

public static Mesh MeshFromPolyline(List plineR)
{
Mesh mesh = null;
int countd = 0;
int countf = 0;
for (int i = 0; i < plineR.Count; i++)
{
if (null != plineR[i] &&
plineR[i].IsClosed &&
plineR[i].IsPlanar() &&
plineR[i].PointCount >= 4
)
{
mesh = Mesh.CreateFromClosedPolyline(plineR[i].ToPolyline());
if (null != mesh)
{
var vertices_ind_list = new List(mesh.Vertices.Count);
for (var vi = 0; vi < mesh.Vertices.Count; vi++)
{
vertices_ind_list.Add(countd + vi);
}
countd = countd + mesh.Vertices.Count;
var faces_ind_list = new List(mesh.Faces.Count);
for (var fi = 0; fi < mesh.Faces.Count; fi++)
{
faces_ind_list.Add(countf + fi);
}
countf = countf + mesh.Faces.Count;

                        var ngon = MeshNgon.Create(vertices_ind_list.ToArray(),
                        faces_ind_list.ToArray());
                        if (null != ngon)
                            mesh.Ngons.AddNgon(ngon);

                    }
                }
            }




        if (null != mesh)
                {
                    mesh.FaceNormals.ComputeFaceNormals();
                    mesh.Normals.ComputeNormals();
                    mesh.Compact();
                    if (!mesh.IsValid)
                        mesh = null;
                }


        return mesh;

    }

Posts: 1

Participants: 1

Read full topic

TextObject visibility

$
0
0

@HepChan wrote:

Hi,

I have two meshObjects (one behind the other) with text labels (FRONT, BACK).

I want the textObject to be visible only when it is in the screen visibility as like the meshObject.

image

Here, I do not want to see “BACK” in this view and the text should hide/show as the view is rotated.

How can this be achieved?

the meshObject works fine…

Posts: 4

Participants: 2

Read full topic

Find the vector which perpendicular to screen (c++)

$
0
0

@pythonuser wrote:

Hi:
I am tray to find a 3dvector which perpendicular to screen, in this sample I can get the plane parallel to screen, but the zaxis is not the vector what i want. sorry for my english.

void GetPointt::DynamicDraw( HDC hdc, CRhinoViewport& vp ,const ON_3dPoint& poi)
{
    pl_con.CreateFromFrame(vp.Target(),vp.VP().CameraX(),vp.VP().CameraY());
    ON_3dPoint poi_e(poi);
    ON_Xform xf_vector_move;
    xf_vector_move.Translation(poi-pl_con.origin);
    ON_3dVector z_vector = pl_con.zaxis;
    z_vector.Transform(xf_vector_move);
    ON_Xform poi_move;
    poi_move.Translation(z_vector*100);
    poi_e.Transform(poi_move);
    vp.DrawLine(poi,poi_e);
    CRhinoGetPoint::DynamicDraw(hdc, vp, poi);
};

I am sorry I can not upload the picture.

Posts: 2

Participants: 2

Read full topic

C++ rhino plugin timer

$
0
0

@Petras wrote:

Hi,

Is there a sample code in C++ how to implement timer in rhino plugin (to re-run a function live until some boolean condition is met) let say to move one point linearly?

Posts: 4

Participants: 2

Read full topic

Merging and Image Processing C# Program into Rhino Plugin Ecosystem

$
0
0

@phoberg97 wrote:

Hello Everyone,

Im currently working on a Plugin for Rhino it has multiple commands and a lot of other utils. We are using C# and Rhinocommon to develop for Windows and Mac. The following problems only appears on my mac at the moment, but i haven’t tested it on windows yet. (Using Visual Studio for Mac currently)

So we created a tiny C# project that is searching for paths in a rendering of a model. It is using some Libs for example ImageProcessor and one for path finding. Running it standalone works without any issues at all. Integrating this project into our Rhino Plugin seemed very straight forward, just adding the needed references and Libs worked fine. But unfortunately the command is not doing anything at all and seems to be crashing because of an assembly reference issue. The error log shows missing reference “MonoMac” Version x.y.z. but adding this reference in Visual Studio(It also says “provided by visual studio” in the Edit References Menu) is not resolving the issue.
Anybody out there who has experience with this error or adding C# projects (little Utils) into a Rhino Common Plugin?

Currently i am trying a very dirty workaround running the C# executable of the tiny project with the mono command within a shell script thats called in the Rhino Plugin. The crazy thing is with other C# projects this works just fine. But my little Image Processing project is not executed when called within a command. Also there are no error shown.

I know its not very specific, i can provide more detailed information if needed.

Thank you in advance.

Best Regards,
Philipp

Posts: 1

Participants: 1

Read full topic


[C++] Not able to change RHINO_PLUG_IN_VERSION

$
0
0

@pagarcia wrote:

Hello,

When I create a default template Rhino 5 C++ plug-in, the plug-in version is set as

RHINO_PLUG_IN_VERSION( __DATE__" "__TIME__ )

and the release can be installed. However, when I change the version for something like

RHINO_PLUG_IN_VERSION( L"2.3" )

then I cannot install it, there’s this message:

pic01

Can somebody tell me the correct syntax or what’s happening? @dale suggested it could be because I have Rhino 6 Beta installed in the same computer, but I tried in another one that does not have it and the same happens. @will ?

Pablo

Posts: 1

Participants: 1

Read full topic

ExtractMeshfaces or DeleteMeshFaces c# RhinoCommon 6

Calling LayerProperties with RedrawEnabled set to False

$
0
0

@romio82 wrote:

Hi All,
maybe @dale and @stevebaer are the ones to approach?

In a small plugin I’m working on at the moment I would like to change the layout (RhinoPageView) printer via script. As it doesn’t seem to be possible to do this fully scripted, I’m using the native “_LayoutProperties” command to access layout printer settings.
In RH5 I disabled Redraw before calling “_LayoutProperties” to prevent Rhino from switching to the layout view in the background…
In RH6 this still works as long as the layout wasn’t open before. As soon as it gets opened once, it will always be opened when calling “_LayoutProperties”.

To illustrate my point I sketched out a small script: layoutPropertiesBehaviour.py (962 Bytes)

Steps to reproduce the issue:

  • Let the script run in a new empty RH6 instance (a new layout will be created and the layout properties are being shown without actually switching to the layout)
  • If you let the script run a second time, it directly jumps to the properties, again without switching view
  • Now switch to the layout view by clicking on its tab and after it is loaded, switch back to TopView
  • Let the script do it’s thing once more. It will now switch to the layout view automatically before opening the Properties window

Is this behaviour intended? In my opinion it was more consistent in RH5.
And the way to use my Plugin was less distracting. I’d like to have that back :slight_smile:

Best, Romuald

Posts: 1

Participants: 1

Read full topic

How to use python 3 in rhino

FIT Options

$
0
0

@ChristopherBotha wrote:

Im finishing up this littel guy

but I have an issue in trying to reduce pointcount, after I get my polylines back I .Tonurbscurve, then rebuild. Id prefer to fitcrv with a tolerance, but my program shows nothing… no matter what tolerance I use.

CUrrent Code: (using iterations of dekink and rebuild)

if (get_rc == GetResult.Option)
{
List Smoothed = new List();
var Lines = Outlines(FileName,InvertImage.CurrentValue);
foreach(Polyline line in Lines)
{
for (int i = 0; i < KinkRemoval.CurrentValue; i++)
{
line.Smooth(1);
}
var Dekinked = line.ToNurbsCurve().Rebuild(line.Count/RebuildMultiple.CurrentValue, 3, false);
Dekinked.Scale(0.1);
Smoothed.Add(Dekinked);
}
PointsConduit.ConduitEdges = Smoothed;
doc.Views.Redraw();
continue;
}

and the code that does not work… any ideas where I am going wrong?

(FitTolerance being a double value in my command line.)

if (get_rc == GetResult.Option)
                {
                    List<Curve> Smoothed = new List<Curve>();
                    var Lines = Outlines(FileName, InvertImage.CurrentValue);
                    foreach (Polyline line in Lines)
                    {
                        var Dekinked = line.ToNurbsCurve().Fit(3, fitTolerance.CurrentValue, 0);
                        Dekinked.Scale(0.1);
                        Smoothed.Add(Dekinked);
                    }
                    PointsConduit.ConduitEdges = Smoothed;
                    doc.Views.Redraw();
                    continue;
                }

Posts: 1

Participants: 1

Read full topic

Viewing all 8667 articles
Browse latest View live