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

Progress Bar Cancel?

$
0
0

@benoit.deschenes wrote:

Hi,

We are developing a new command that can take a while to execute and so we want to add a progress bar and the option to cancel the operation. I see that there is the ShowProgressMeter() ( https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_UI_StatusBar_ShowProgressMeter.htm ) method which can be used to display a progress meter in the status bar, but there doesn’t seem to be a built-in way to cancel a command or display a cancel button (next to the progress meter for example) in the RhinoCommon API.

My question is:
Can the the status bar / progress bar be customized using the Eto framework? Or do we need to create our own dialog with progress bar + cancel button if we want to have the cancel option?

Thank you.

Posts: 4

Participants: 2

Read full topic


DrawMeshShaded does not work well with Top/Right/Front viewports

$
0
0

@vaibhav.shah wrote:

Hello,

I am using DisplayConduit to draw robot Mesh dynamically. It works very well in perspective view. However, when I switch to any of the orthogonal views like “Top”, some triangles of the mesh are displayed “inverted” (see picture below).


The mesh looks fine in Perspective view:

I am using DrawMeshShaded inside the overriden PostDrawObjects() method to display these meshes.

Can someone please help on figuring out what could be potentially wrong? Is it a bug with Rhino or am I implementing DisplayConduit wrongly?

Posts: 5

Participants: 2

Read full topic

Idle event not firing whilst cycles is rendering

$
0
0

@pkinnane wrote:

Hi - as per the title, I am seeing that whilst Cycles (ie. the Raytraced Viewport is selected) is rendering, the RhinoCommon Rhino.RhinoApp.Idle event is not firing until I pause the cycles render. Is this the intended functionality? It is quite an issue for plugins which rely on the idle event.

Thanks

Paul

Posts: 1

Participants: 1

Read full topic

Setting Layer.Id

$
0
0

@aitorleceta wrote:

Hi messing up with baking layers assigning a custom Id…

I found that sometimes (!?) I’m not able to change a freshly baked layer Id because its Layer.IdIsLocked state is set to True.

I particular: I don’t understand what needs to happen for a layer to be set as IdIsLocked=True

already hours spent trying to figure out a pattern for this behavior. Some doc layers are blocked, others no ?!

In the end, what I just want to do is to bake a layer which ID is set by me, but “IdIsLocked” is blocking my attempts…

by the way, this is on WIP…

Posts: 1

Participants: 1

Read full topic

C# How to find from a List of data a Geometry Class? and check if is not None?

$
0
0

@andresobregonlopez wrote:

Could someone explain How you could write this Python code in C# script?

import rhinoscriptsyntax as rs

for m in data:
if(m!=None and rs.IsCurve(m)):
curve = m

I try this but did not work:

private void RunScript(System.Object data, ref object A)
{
if (data != null){
Print(" Great, Data is not Null! “);
Print(” I found data");

 /*
// not work
  if (data ==  Rhino.DocObjects.Custom.CustomCurveObject){ 
 
    Print(" I found an Object Curve ");
    A = data; // data is a Curve!
  }
*/  

}

Posts: 2

Participants: 2

Read full topic

Embedding a Rhino.UI.Controls.ViewportControl into a xaml form

$
0
0

@csykes wrote:

I have been trying to embed a Rhino Viewport into my XAML form. I’m thinking the only way to do this will be to create my form with a blank square and add the ViewportControl in during runtime.

I have had a read through and play with SampleCsEtoViewportCommand which was very helpful and tried to add it to my project, this lead me to Eto and as such I have referenced in Eto.dll from the Rhino 7 WIP Folder because the NuGet package seems to have issues.

// SampleCsEtoViewportCommand

`internal class SampleCsViewportForm : Dialog
{
public SampleCsViewportForm()
{
Title = “Rhino Viewport in an Eto Control”;
Resizable = true;
var viewport_control = new
{
new Rhino.UI.Controls.ViewportControl {Size = new Size(400, 200)},
new Rhino.UI.Controls.ViewportControl {Size = new Size(400, 200)}

  };
  Content = new StackLayout
  {
    Padding = new Padding(2),
    Spacing = 5,
    HorizontalContentAlignment = HorizontalAlignment.Stretch,
    Items =
      {
        viewport_control[0],
        viewport_control[1]
      }
  };
}

}

I have a read through the Eto Wiki on GitHub and found no help in the XAML section XAML Tips & Tricks but I did find a section for how to embed Eto.Forms into another application Embed Eto Forms

However I got stuck there on trying to find more on the .ToNative() property that seems to convert an Eto Form to a Windows Form.

System.Windows.Forms.Control myEtoControlAsWinForms = eto.ToNative(true);

I assume I could replace eto with the new StackLayout I created earlier but that doesn’t seem to work.

Thanks

Posts: 2

Participants: 2

Read full topic

Override Close save Dialog

$
0
0

@MatrixRatrix wrote:

On my Skin/Plugin I need to control the extensions that are going to be saved, or override the rhino save dialog box.

On my plugin I create a custom save dialog and solve my problem, but the only problem is when the document is modified and the rhino is closed by the “cross”, is always pointing to the rhino save dialog .
my

Any away?

Thanks

Posts: 2

Participants: 2

Read full topic

How to create a C# code similar to the Gradient component?

$
0
0

@michalina.dengusiak wrote:

Hello!
I am currently learning about C#, and I am wondering whether some of the components could be replaced by code in C#.
I am working on this script, and I want to write a program that will perform the same function as gradient and return the material. I have already replaced three of the components, yet I am struggling with this one. Can you please help :thinking: ?
The vague idea of what I want to do:

Here is my code:

 List<Line> lines = new List<Line>();
    lines.Add(inputLine);
    DivideAndRotate(inputLine, ref lines, angle, minLength);
    Lines = lines;

    //Substituting the length component
    List<double> lengths = new List<double>();
    foreach (Line itemLine in lines)
    {
      lengths.Add(itemLine.Length);
    }
    Lengths = lengths;

    //substituting the Bounds component
    double minValueBounds = lengths.Min();
    double maxValueBounds = lengths.Max();
    Interval bounds = new Interval(minValueBounds, maxValueBounds);
    Domain = bounds;

    //substituting the remap component
    List<double> remaps = new List<double>();
    foreach(double length in lengths )
    {
      remaps.Add(RemapValues(length, minValueBounds, maxValueBounds));
    }
    Remap = remaps;

    //I am not really sure if I should use one of these methods, and which one?
    // How should I do the Gradient function?


    //Rhino.Display.DisplayMaterial material = new Rhino.Display.DisplayMaterial();
    //material = material.Specular(System.Drawing.Color.Lime);

    Rhino.DocObjects.Material material = new Rhino.DocObjects.Material();
    //material.EmissionColor(System.Drawing.Color.Lime);
    material = Rhino.DocObjects.Material.DefaultMaterial;
    material.SpecularColor = System.Drawing.Color.Lime;
    //material.Name = "MyMaterial";

    Material = material;

The GH file:
Gradient_Material_Question.gh (18.3 KB)

Posts: 2

Participants: 2

Read full topic


RhinoApp.Runscript Invoke from event stream

$
0
0

@lando.schumpich wrote:

Hi, I have problems scripting the -_Import command inside of a plugIn.

I have read through multiple posts with similar issues, the typical solutions where to

  • Write a Command and
  • Set the CommandStyle to ScriptRunner

my problem is a bit different though:

I run a server that listens for pings on a port and fires events from which i want to to a file import.
Since the file format -(for now)- is .fbx, which can only be imported via script I need to call RhinoApp.Runscript().

The approach i tried

  • Create a Command in my PlugIn: XXImportFBX with CommandStyle set to Scriptrunner
  • Give the Command a backing field for the FilePath
  • Insice the Command call RhinoApp.Runscript($"-_Import \"{path}\" ")
  • When I catch an Import event, set the backing field to the appropriate FilePath and call RhinoApp.ExecuteCommand(_doc, "XXImportFBX")

This does not work, the command runs but RhinoApp.RunScript just returns false, which I assume is related to this:

When I just type the command name in the commandline, after the FilePath field has been populated everything works fine, so it seems Rhino prohibits calling commands like I try to do it here.

No errors are thrown at any point, RhinoApp.Runscript() returns false, and RhinoApp.ExecuteCommand() returns Result.Success.

Is there any way I can achieve command execution from a non-command-class?
Since the event stream comes from another application I would rather not have the user run a blocking command inside of rhino which freezes the UI until they click something in said other application.

Since you helped in many other posts related to RhinoApp.Runscript() problems I’m pinging you directly @dale, I hope you don’t mind.

Also the zipped files in this post, seemed like they might also be related to the problem I’m having here, as the UI is also on another thread and can’t be a command class:

Thanks in advance,
Lando

Posts: 1

Participants: 1

Read full topic

Using Dynamic draw while orienting on surface

$
0
0

@Phil_Shapiro wrote:

Hi Everyone.
I was working around the dynamic display in RhinoPython starting with the point display provided as an example, trying to adapt it to the following problem but without any success. I need to be able to move a circle center with the mouse while constraining it to a non planar polysurface, with the preview circle plane and circle remaining tangent to the surface at the center point as it moves. Has anyone encountered and solved this ?
Thanks !
Phil

Posts: 3

Participants: 2

Read full topic

Update of the Attributes User Text Window

$
0
0

@Dmitriy wrote:

Hi,

I am changing some of the attributes of the RhinoObject in User Text window manually. After change of certain UserStrings, some other strings are changed as well via Event Watcher Class.
However, I cannot see an update immediately when having focus in the same window. In order to see effect, I need to switch to other window like Object or Material and then back. How to force an update of the values in User text window without switch?
I am already using CommitChanges however still need to switch to other window and back.

Thanks,
Dmitriy

Posts: 4

Participants: 2

Read full topic

Permanently delete material

$
0
0

@MatrixRatrix wrote:

I try delete material on document:

            var textures = doc.Materials;
            foreach (var item in textures)
            { 
                doc.Materials.Delete(item); 
            }

this does not permanently erase, when the .3dm file is opened again on another pc, all textures will be created from the embedded folder again.

I need delete permanently from document.

Thanks

Posts: 6

Participants: 2

Read full topic

Eto LinkButton crash when used in RenderContent UI (V6 & V7)

$
0
0

@jdhill wrote:

I find there is a crash occurring (in 6.26.20118.17211, and 7.0.20119.13305, at least when loading a V6-sdk plugin) when using an Eto LinkButton in a RenderContent UI. To repro, put these classes in a test plugin:

[Guid("0182E9AA-8A98-44A2-B0C1-38639C162635")]
[CustomRenderContent(IsElevated = true)]
public class LinkTestMaterial : RenderMaterial
{
    public override string TypeName => "Link Test"; 
    public override string TypeDescription => "Link Test";

    protected override void OnAddUserInterfaceSections()
    {
        AddUserInterfaceSection(new LinkTestUI());
    }
}

public class LinkTestUI : EtoCollapsibleSection
{
    public override Guid PlugInId => TestRenderPlugIn.PlugInId;
    public override LocalizeStringPair Caption => new LocalizeStringPair("Attrs", "Attrs");
    public override int SectionHeight => 50;

    public LinkTestUI()
    {
        Content = new TableLayout { Rows = { new LinkButton { Text = "link" } } };
    }
}

With the plugin loaded, follow these steps:

1. open the Materials panel
2. create a Link Test material
3. click the link in the material's UI
4. create a Plaster material
5. if it does not crash, select the Link Test material and repeat steps 3-5

There are other actions you can use to trigger it after clicking the link, such as clicking the Back button, or saving with the material in the document, re-opening, clicking the link and closing Rhino (need to save/reopen because the close without saving dialog appears to prevent the crash).

Each method may be somewhat intermittent, but will eventually (should be first or second try) crash with the exception message 'System.Windows.Documents.Hyperlink' is not a Visual or Visual3D.' with the top of the stack trace being:

at MS.Internal.Media.VisualTreeUtils.AsVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)
at System.Windows.Media.VisualTreeHelper.GetParent(DependencyObject reference)
at RhinoWindows.Controls.WpfElementHostBase.<>c.<.ctor>b__1_1(Object sender, KeyboardFocusChangedEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

Posts: 1

Participants: 1

Read full topic

Saving sticky

$
0
0

@JoshD wrote:

Is there a way to save a sticky dictionary between rhino sessions?
I have a script where I am creating quite a large dictionary of objects that is being made from a main script and saved within a sc.sticky to pass this information between a number of smaller scripts.
The issue is when I close Rhino this is lost, and I then need to rerun the large script each time I reopen Rhino even though I havent changed anything within the model.
My first thought was to save this as json in the document user text, but the dictionary also contains objects that aren’t easily converted into text.
Thanks

Posts: 1

Participants: 1

Read full topic

What is the rhino c++ api function for cmd Flow?

$
0
0

@john12 wrote:

Hi,
My system is Rhino 6 C++ SDK.
I want to flow a object along a curve by api function, not by run cmd script.
How can I do?
Please give me a sample.

Posts: 2

Participants: 2

Read full topic


Rhino 7 - FileStepWriteOptions

$
0
0

@sebastian.lippert wrote:

Hi,

i’m wondering whats the best way to export selective data as STEP file with the new *Rhino.FileIO.FileStp.Write()
Method.

Do i need to create a new docobject & copy all relevant data into it, or is there a fast solution similar to
*fwo=Rhino.FileIO.FileWriteOptions()
*fwo.WriteSelectedObjectsOnly=True

Thanks

Sebastian

Posts: 1

Participants: 1

Read full topic

Create mesh and triangle mesh for selected objects

$
0
0

I ran into a group of problems and ask for help. First, I need to use the NonManifoldMerge command for the selected objects (Imprint between surfeaces (command)) on my video I call it without problems, but I don’t know how to call it using the Rhino C # API. After I need to make Mesh for these objects as shown in the video. Here is my code for creating a Mesh, but it still doesn’t appear in Rhino itself.

 protected override Result RunCommand (RhinoDoc doc, RunMode mode)
        {
            doc.Views.RedrawEnabled = false;

            List <ObjRef> objRef = new List <ObjRef> ();
            using (GetObject go = new GetObject ())
            {
                go.SetCommandPrompt ("Select objects");
                go.GeometryFilter = ObjectType.Surface;
                go.GroupSelect = true;
                go.GetMultiple (1, 0);

                if (go.CommandResult ()! = Result.Success)
                {
                    return go.CommandResult ();
                }
              
                for (int i = 0; i <go.ObjectCount; i ++)
                {
                    objRef.Add (go.Object (i));
                }
            }

            foreach (var item in objRef)
            {
                if (doc.Objects.Find (item.ObjectId) is RhinoObject rhinoObject)
                {
                                     MeshingParameters meshingParameters = new MeshingParameters
                    {
                        Tolerance = 0.01,
                        MaximumEdgeLength = 5
                    };

                    rhinoObject.CreateMeshes (MeshType.Render, meshingParameters, true);
                  
                    }
                }
            }

            doc.Views.RedrawEnabled = true;
            doc.Views.Redraw ();

            return Result.Success;
        }

After I need to use the TriangulateMesh command using the Rhino C # API. If anyone has ideas on how to solve these problems, I will be very grateful in advance thanks))

With respect Dmitry))

4 posts - 2 participants

Read full topic

Creating contour from loft

Redrawing Background in Rhino Python

$
0
0

(topic withdrawn by author, will be automatically deleted in 24 hours unless flagged)

1 post - 1 participant

Read full topic

Rhino3dmIO to make obj

$
0
0

I have created a stand-alone app to manipulate Rhino files using the Rhino3dmIO package. I have been asked to add the ability to export a 3dm file to an obj and/or stl file.

I don’t see an immediate solution to this. Is there a way to do it? I’m not really a cad guy, so I admit I don’t know all the ins & out of this.

Thanks!
Don Sayler

1 post - 1 participant

Read full topic

Viewing all 8556 articles
Browse latest View live