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

Extrude Cut Equivalent?

$
0
0

@roeylazarovits wrote:

Hello,

I’m new to Rhino and Grasshopper, and I’m looking for a way to “extrude cut” using Grasshopper’s scripting tools, similar to how you might extrude cut in Solidworks. Essentially, I’m looking to have a complex pipe network move through a box, as shown below.

I’ve tried making meshes out of the box surface and the pipe surfaces below, and then use MeshBooleanDifference to remove the pipe from the box. The result seems to be a simple mesh of a box, as if nothing was cut out.

Is there a better way to approach this? Is there an “extrude cut” command that I haven’t found? Any help on the topic is greatly appreciated!

Thank you!

49%20PM

Posts: 3

Participants: 2

Read full topic


Why does Brep.JoinBreps not create a solid (closed polysurface) for these geometries, when Rhino's Join command does?

$
0
0

@nicolaasburgers wrote:

Hello

When I join the geometries of the objects in the attached file together using Brep.JoinBreps, I can see in the debugger that resulting Brep has its IsSolid=false. When I subsequently run the SelClosedPolysrf command, the resulting joined object isn’t selected.

However when I select these same objects in Rhino and run the Join command, it results in a closed polysurface going by the fact that SelClosedPolysrf selects the resulting object.

I’ve inspected all the surfaces and they each seem to have their normals facing outward. And the fact that the Join command is able to join them together shows that I don’t have a piece missing (a “hole”). But I am obviously missing something here.

Could anyone help me by pointing out what I’m missing in this case? Why does Rhino’s Join command does create a solid, but Rhinocommon’s Brep.JoinBreps doesn’t?

Thanks

Nic
TestJoinBreps.3dm (622.2 KB)

Posts: 3

Participants: 2

Read full topic

Change Background color in Rendered Mode

$
0
0

@t107408022 wrote:

Hello everyone,I’m using Rhino 6, I want to change the background color in the rendered mode (the default color is white), but I have tried various methods, the following code is closest to the results I want, but I don’t know why the views seems to have no change.
If “DisplaySettings” is changed to “AppearanceSettings”, then in the Wireframe mode, Shaded mode…etc, the background color of all viewports can be changed, but this is not what I want…, there are ways Can this be solved?
Thank you so much.

CRhinoView* view = RhinoApp().ActiveView();
CRhinoDisplaySettings displaySettings = RhinoApp().AppSettings().DisplaySettings();
displaySettings.m_background_color_in_rendered_views = ON_Color::Gray160;
RhinoApp().AppSettings().SetDisplaySettings(displaySettings);
return CRhinoCommand::success;

Posts: 1

Participants: 1

Read full topic

C# grid code function

$
0
0

@cokerone1214 wrote:

Hello guys!

I am trying to learn some basics on C# so I am pretty amateur.

I try to make a very simple code of a grid. When I make it normal everything works fine but when I try to use additional code and functions something happens with “multiplier” input. I think that I have to initialize it somehow or what? I would appreciate your help!

Thanks in advance!

Grid.gh (5.3 KB)

Posts: 7

Participants: 2

Read full topic

Unexpected Curve.CreateBlendCurve result in RhinoCommon (C#)

$
0
0

@davidjgall wrote:

image

In the image above, all curves are 2D planar curves. The red curve is the desired result. It was produced using a default application of the interactive command BlendCrv. In C#, all my efforts to duplicate the red curve turn out looking like the blue curve. I’ve tried everything I can think of to change the result and it just keeps returning the same result every time. Here’s the code snippet I’m using:

rhCrvBlend = Curve.CreateBlendCurve(rhCrvParent, rhCrvParent, BlendContinuity.Tangency);
doc.Objects.AddCurve(rhCrvBlend);

I’ve tried all sorts of variations on the theme using a single parent curve and multiple parent curves, and I get the same result in Rhino 5 32-bit, Rhino 5 64-bit, and Rhino 6. I’ve tried changing the BlendContinuity to Curvature and it only makes the sharp corner less conspicuous. I don’t understand why RhinoCommon is “throwing” the control points so far away from the parent curves. When I interactively construct the BlendCrv, the control points do not extend past the midpoint of the created curve. I’ve tried scaling the model by a factor of 100 and I get the same results, so it’s not a matter of tolerances or some weird snap setting (I tried disabling Osnap, Ortho, GridSnap, and SmartTrack in code, too, just in case).

Posts: 2

Participants: 2

Read full topic

Development side...context menus

Properties window slows down object selection

$
0
0

@dgebreiter wrote:

Hello,

it appears this old issue has once again become relevant in Rhino 6.
Selecting many objects using Rhinocommon is very slow if the object properties dialog is open.

Selecting all objects in a dcoument using “_selAll” is fast, independently of whether the object properties dialog is open.
The RhinoCommon doc.Objects.Select() functions are equally fast, but if the object properties dialog is open, the selection is followed by a delay of several seconds.

Is there a way in RhinoCommon to reproduce the speed of “_selAll”? A working way to disable the properties panel during selection?

Many thanks for any help!

Daniel

public class SelectionDebug : Command
{
    public SelectionDebug()
    {
        // Rhino only creates one instance of each command class defined in a
        // plug-in, so it is safe to store a refence in a static property.
        Instance = this;
    }

    ///<summary>The only instance of this command.</summary>
    public static SelectionDebug Instance
    {
        get;
        private set;
    }

    ///<returns>The command name as it appears on the Rhino command line.</returns>
    public override string EnglishName
    {
        get { return "SelectionDebug"; }
    }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {

        IEnumerator<RhinoObject> ros = doc.Objects.GetEnumerator();
        List<Guid> nextGuids = new List<Guid>(); //guids of objects in Rhino document
        while (ros.MoveNext())
        {
            nextGuids.Add(ros.Current.Id);
        }

        Stopwatch sw = new Stopwatch();
        sw.Start();
        //Option 1
        Rhino.RhinoDoc.ActiveDoc.Objects.Select(nextGuids);
        sw.Stop();
        RhinoApp.WriteLine("option 1 took" + sw.ElapsedMilliseconds);
        sw.Restart();



        //Option 2
        foreach (Guid guid in nextGuids)
        {
            RhinoObject rO = Rhino.RhinoDoc.ActiveDoc.Objects.Find(guid);
            if (rO != null)
            {
                rO.Select(true);
            }
        }
        sw.Stop();
        RhinoApp.WriteLine("option 2 took" + sw.ElapsedMilliseconds);
        sw.Restart();



        Guid guidP = Rhino.UI.PanelIds.ObjectProperties;
        bool open = Rhino.UI.Panels.IsPanelVisible(guidP);

        if (open)
        {
            Rhino.UI.Panels.ClosePanel(guidP);
        }

        sw.Reset();
        
        sw.Start();
        //Option 1
        Rhino.RhinoDoc.ActiveDoc.Objects.Select(nextGuids);
        sw.Stop();
        RhinoApp.WriteLine("option 1b took" + sw.ElapsedMilliseconds);
        sw.Restart();



        //Option 2
        foreach (Guid guid in nextGuids)
        {
            RhinoObject rO = Rhino.RhinoDoc.ActiveDoc.Objects.Find(guid);
            if (rO != null)
            {
                rO.Select(true);
            }
        }
        sw.Stop();
        RhinoApp.WriteLine("option 2b took" + sw.ElapsedMilliseconds);
        sw.Restart();


        if (open)
        {
            Guid guid = Rhino.UI.PanelIds.ObjectProperties;
            Rhino.UI.Panels.OpenPanel(guid);

        }

        doc.Views.Redraw();

        return Result.Success;
    }

}

Posts: 1

Participants: 1

Read full topic

How to get PageViews from Rhino.FileIO.File3dm?

$
0
0

@tom_svilans wrote:

Hi,

I’ve looked through the API, and I can’t seem to find a way to programmatically create a new 3dm file, add objects and layouts to it, and write it to disk without using RhinoDoc, since this would require me to close and open a file for each one that want to export.

Adding objects and layers is fine, but is there a way to add PageViews, or read layout geometry from a template file through the FileIO namespace?

The goal is to have a template Rhino file with some layouts and named objects which I would then load, copy, and populate with geometry, change data, etc. and then write to a folder. Ideally, I would do this through Python or C#, since I’d like to export geometry created in Grasshopper automatically. So far everything works, except the bit with the layouts.

Any tips or feedback would be much appreciated!

Tom

Posts: 1

Participants: 1

Read full topic


Partially split a solid with a surface

New linetype

DifferenceBetween Rhino 5 & 6 For PageToModelRatio?

$
0
0

@trevor.d.reid wrote:

I have two plugins—one for Rhino 5 the other for Rhino 6—which use similar code. But when acting on the same file each yields different results for PageToModelRatio. Given detail is an instance of Rhino.DocObjects.DetailViewObject:

double ratio = detail.DetailGeometry.PageToModelRatio

In Rhino 5 ratio will be 0.17891563008952949. In Rhino 6, for the the same detail view from the same file ratio will be 0.031881150585873874.

Is there a difference between the two environments or some property that I need to ensure is set in order to get the same value in both versions?

Thanks!

Posts: 5

Participants: 2

Read full topic

End while(true) loop with right mouse click

$
0
0

@seppeldue wrote:

Inside a while(true) loop i use GetOption to change a set of parameters an create a set of breps. The loop runs until the breps are the way i want them. Right now an EscapeKeyEvent is used to exit the loop.
I want to use a right mouse click to exit the loop.
So fare i suspect that the GetOption is controlling the mouse events, but i dont get it to work.
Is it the if(go.Command.Result…) line that should do the trick?

Posts: 3

Participants: 2

Read full topic

Plug-in listen when file is opened

$
0
0

@Goodriver wrote:

Is it possible to have a plug-in that listens when the user opens a new file and executes code automatically based on the file opened? How can it be done in c# in Rhino for Windows?
Thanks,
Victor

Posts: 1

Participants: 1

Read full topic

Start plugin at startup

$
0
0

@Goodriver wrote:

I’m trying to make my plug-in load at startup. I’ve added the following lines to my class:

        public new PlugInLoadTime LoadTime;
        public MyPlugIn()
        {
            LoadTime = PlugInLoadTime.AtStartup;
        }

However, it does not seem to work. Any ideas?
Thanks,
Victor

Posts: 2

Participants: 2

Read full topic

C# expression body syntax in Grasshopper Plugin class getters

$
0
0

@jmcauley wrote:

I know that this is small beer, and it’s mostly my OCD but…

when I create a new plugin I am compelled (by the power of Patty) to edit this:

namespace WingCutters
{
    public class WingCuttersInfo : GH_AssemblyInfo
    {
        public override string Name
        {
            get
            {
                return "WingCutters";
            }
        }
        public override Bitmap Icon
        {
            get
            {
                //Return a 24x24 pixel bitmap to represent this GHA library.
                return null;
            }
        }
        public override string Description
        {
            get
            {
                //Return a short string describing the purpose of this GHA library.
                return "";
            }
        }
        public override Guid Id
        {
            get
            {
                return new Guid("89b9ca79-7ccc-41f3-972f-768283efb797");
            }
        }

        public override string AuthorName
        {
            get
            {
                //Return a string identifying you or your company.
                return "John";
            }
        }
        public override string AuthorContact
        {
            get
            {
                //Return a string representing your preferred contact details.
                return "";
            }
        }
    }
}

into this:

namespace WingCutters
{
    public class WingCuttersInfo : GH_AssemblyInfo
    {
        public override string Name => "WingCutters";
        public override Bitmap Icon => null;
        public override string Description => "Creates wing cutout and trim and flaps volume and trim to speed things up";
        public override Guid Id => new Guid("89b9ca79-7ccc-41f3-972f-768283efb797");
        public override string AuthorName => "John";
        public override string AuthorContact => "";
    }
}

uh, just because.

Could you change future plugin code generaters to use the expression body syntax? Where it makes sense.

The component ComponentGuid and Icon are also candidates for this.

Posts: 1

Participants: 1

Read full topic


Get the correct UVs after texture mapping change

$
0
0

@gennaro wrote:

Hi all,

I am trying to extract uvs of an object. The way I extract them is this:

ON_TextureMapping texture_map;
ON_Xform localXform;
const ON_MappingRef* pMR = obj->Attributes().m_rendering_attributes.MappingRef(uuidCurrentRenderingPlugIn);
CRhinoTextureMappingTable& table = ::RhinoApp().ActiveDoc()->m_texture_mapping_table;
if (pMR) {
        const int iCount = pMR->m_mapping_channels.Count();
        if (pMR->m_mapping_channels.Count() > 0) {
             const ON_MappingChannel& mc = pMR->m_mapping_channels[0];
             int iIndex = mc.m_mapping_index;
             localXform = mc.m_object_xform;
             texture_map= table[iIndex];
      }
}
mesh->SetTextureCoordinates(texture_map, &localXform);
for (int p = 0; p < mesh->m_V.Count(); p++) {
       ::RhinoApp().Print("%f , ",meshDup->m_T[p].x);
       ::RhinoApp().Print("%f \n ",meshDup->m_T[p].y);
 }

The problem is that if I change the texture mapping from the GUI (rotation, repetition, offset) the UVs do not change and they are always in a range [0,1]. I might have misunderstood but I expected to find the transformation applied onto the UVs. And however I do not know where to get these change made in the GUI.
Is there any way to get the correct uvs of an object?
Thanks in advance,

G.

Posts: 1

Participants: 1

Read full topic

Trying to Apply Surface mapping in Rhinocommon

$
0
0

@josh_blanchard wrote:

Hello all,
I am trying to apply surface mapping to a surface that it being rebuilt programmatically. The V component is based on a factor of the surfaces width (we have a huge volume of individual models that need parameterized surface mapping).

    For Each NewGuid In NewGuidList
        Dim New_Obj As Rhino.DocObjects.BrepObject = RhinoDoc.ActiveDoc.Objects.Find(NewGuid)
        Dim Obj_Ref = New DocObjects.ObjRef(NewGuid)
        Dim Temp_Brep As Brep = Obj_Ref.Brep()
        Dim Temp_Crv As Curve() = Nothing
        Dim Temp_Pts As Point3d() = Nothing
        Intersect.Intersection.BrepSurface(Temp_Brep, IntPlane, doc.ModelAbsoluteTolerance, Temp_Crv, Temp_Pts)
        Dim Temp_Length As Double = Temp_Crv(0).GetLength
    Next

At this point I have a rebuilt surface, and the length I need.
In the command menu, what I would put at this point is
_-ApplySurfaceMapping 1 (Temp_Length / 5) 1 _enter

I’m hoping that their might be an analogous function in rhinocommon. Also, because of certain restrictions, I am having to work with Rhino5 on this project.

Thanks for any help!

Posts: 1

Participants: 1

Read full topic

Unable to load plugin: application initialization failed

$
0
0

@Matthieu_from_NAVINN wrote:

Hi,
I’ve got an issue with a plugin I’m developing. It used to load properly in Rhino6 but I stopped working on it for a couple of months and now i’m stuck with an error “Unable to load plugin: application initialization failed” when trying to load it.
I’ve tried with the same .rhi installer that used to work, so it should not be a missing reference issue.

Is there any way to get more debug info on plugin load time than this empty error message?
Thanks for helping
Matthieu

Posts: 3

Participants: 1

Read full topic

Mesh.CreateFromBrep(brep) returns too many vertices

$
0
0

@mikity_kogekoge wrote:

Hello,
I’m struggling with a weird behavior of Rhino.Geometry.Mesh.CreateFromBrep(brep).
This function takes a MeshSettings as a parameter, but it also provides an option not providing MeshSettings. That’s what I’m testing.
I attached Rhino file and GH file that reproduce my problem.
There are two Polysurfaces that are identical, only the difference is the location.
The Mesh.CreateFromBrep(brep) returns a mesh with 150 vertices for the first one and 59500 vertices for the second one. Is this a bug? Or otherwise what causes this?
Please somebody help…

Thank you.

exmaple

meshbrep.gh (3.9 KB)
example.3dm (125.4 KB)

Posts: 5

Participants: 2

Read full topic

Align polysurface to plane

$
0
0

@jvdg1 wrote:

I’m trying to align unknown polysurfaces to the XY-plane. I rotate the object and monitor what happens to the dimensions of the bounding box. This gets me quite close to actual alignment to the plane, but never really there. There must be a better way to do this?
Thanks, Johan

Posts: 2

Participants: 2

Read full topic

Viewing all 8553 articles
Browse latest View live