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

Scaled bitmap export

$
0
0

@jvdg1 wrote:

I would like to export bitmaps of objects in a scaled manner. So I would like 1 pixel in the file to correspond with excatly 1 millimeter in the model. I managed to do this manually by printing to a file. But I would like to automate it in .net or Rhinoscript. But I can’t seem to get the printing automated that way. Preferably a solution that is not limited to the resolution of the display. Perhaps using a render windows?
Thanks, Johan

Posts: 1

Participants: 1

Read full topic


Give Object a Name with Rhino Common?

$
0
0

@flokart wrote:

Hi all,

I tried to Add a Name to a Object but it is not appearing in the Rhino UI but if i print it the object attribute.name exist.

import Rhino as rh

L = rh.RhinoDoc.ActiveDoc.Objects.FindByLayer('Line')
for i in L:
    print i.Attributes.Name
    i.Attributes.Name = 'Test' 
    print i.Attributes.Name


None
Test

A tip why the name dont appear in the object property panel is welcome

Unbenannt

Posts: 4

Participants: 2

Read full topic

Error when using _-CopyRenderWindowToClipboard

$
0
0

@jvdg1 wrote:

When scripting the command _-CopyRenderWindowToClipboard is giving me the following error:
Error copying image to clipboard.
It works fine manually from the renderwindow.
Or do I need to specify the window somehow?
Johan

Posts: 1

Participants: 1

Read full topic

New linetype

Convert Branch Item to double or string ? in C#

$
0
0

@flokart wrote:

Hi all,

i try to convert the branch item to a double or string depending whats inside.
For example this Item 6 i would like to convert to a double how does it work…i tried

var x =  Test.Branch(0)[0];
Convert.ToDouble(x);
A = x.GetType();

But it says
Unbenannt
and the input is
Unbenannta
or ist System.Int32 a double ?

Posts: 3

Participants: 2

Read full topic

Snapshots Creation

How to transform the uvw of getcolor() into world coordinates

$
0
0

@1668082946 wrote:

Hi

I want to get the texture color and world coordinates of some arranged specific points on the mesh.

I think we can get the texture color with TextureEvaluator.getcolor(Point3d uvw,Vector3d duvwdx,Vector3d duvwdy).

But,How to transform the uvw of getcolor() into world coordinates?

Or How to transform world coordinates into the uvw?

And can you show me some examples?

Posts: 1

Participants: 1

Read full topic

Any way to access geometry of linked blocks?

$
0
0

@taitam wrote:

Hi,
I am trying to access the geometry of a linked block in a GH component.

The following code with embed block in a GH component is working fine.

var meshList = new List<Mesh>();
var name = "myblock";
var idef= doc.InstanceDefinitions.Find(name);
var bkObj = bk.GetObjects();

for (int i = 0; i < bkObj.Count(); i++)
{
  if (bkObj[i].ObjectType == ObjectType.Mesh){meshList.Add((Mesh) bkObj[i].DuplicateGeometry());}
}
A = meshList;

However when it comes to linked blocks, GetObjects method doesn’t return any geometry…
Any idea?

Note that I am not looking at baking geometry using AddInstanceObject method.

thx

Posts: 1

Participants: 1

Read full topic


Curve.ClosedCurveOrientation(...) gives different result in Rhino6 compared to Rhino5

$
0
0

@donato1 wrote:

I have the same curve in Rhino5 and Rhino6.
In Rhino5 I get correct result (if compared to what I see also in Rhino when performing Analyze Direction),
in Rhino6 i get the opposite (and apparently wrong) result.
Is that a bug in Rhino6? Something changed?

Posts: 1

Participants: 1

Read full topic

Invalid Meshes and Duplicate Vertices

$
0
0

@Brad_Campbell wrote:

I have found several threads with discussions about having invalid meshes due to duplicate vertices. In the old .NET sdk this was not the case. Duplicate vertices were allowed. My plugin creates meshes which I import and export as regular grids, that is I write rows of vertices and the number of rows and columns. This format is required for some of our simulations. The simulations handle duplicate vertices fine and this is how we deal with surfaces that come to a point. The restriction on duplicate vertices in Rhino6/RhinoCommon leaves me scratching my head about how to deal with this. No clean solutions come to mind.

This may blow up my plugin for RhinoCommon all together, since these type a if surfaces show up frequently.

Does anyone have any potential solutions for this? Removing duplicate vertices destroys the ordering of the vertices, which is critical.

Posts: 2

Participants: 2

Read full topic

EdgeLine bad for finding distance to point

$
0
0

@Terry_Chappell wrote:

@pascal,
I am developing a Python script to trim a mesh in cases where Rhino’s Mesh trim fails. As part of this, a closed boundary curve is projected onto a mesh which creates points everywhere the line crosses the edge of a mesh face. ClosestPoint is used to find which mesh face the point falls on and then the distance from the point to each face edge is found to select the closest edge. But the shocking thing I discovered is that if I used the EdgeLine method to get lines representing the 3 edges, then the measured distances are about a million times less accurate than using the 3 vertices of a face to make 3 edge lines from scratch. Below is shown the portion of the script where I compare these two approaches:

# Use vertices of face to make edge lines for the face.
i2,i3,i1,ix = faces[f_index]; p1,p2,p3 = vertices[i1],vertices[i2],vertices[i3]
# Make lines for edges of face from vertices.
l1,l2,l3 = Line(p1,p2),Line(p2,p3),Line(p3,p1)
# Find distance from boundary point pt to edge lines.
d1p,d2p,d3p = l1.DistanceTo(pt,True),l2.DistanceTo(pt,True),l3.DistanceTo(pt,True)
# This gives very accurate results.
print 'Vertices: face {0} Distances = {1:.4e}, {2:.4e}, {3:.4e}'.format(f_index,d1p,d2p,d3p)
	
# Use EdgeLine to make edge lines of face.
e1,e2,e3 = edges.GetEdgesForFace(f_index)
# Get edge line of edges.
l1,l2,l3 = edges.EdgeLine(e1),edges.EdgeLine(e2),edges.EdgeLine(e3)
# Find distance from boundary point pt to edge lines.
d1p,d2p,d3p = l1.DistanceTo(pt,True),l2.DistanceTo(pt,True),l3.DistanceTo(pt,True)
# This is a million times less accurate.
print 'EdgeLines: face {0} Distances = {1:.4e}, {2:.4e}, {3:.4e}\n'.format(f_index,d1p,d2p,d3p)

If you run the attached Python script on the attached .3dm file, you will see a printout of the distances from each boundary point to the 3 edges of the mesh face it crosses calculated in 2 ways (1) First with the lines for the edges of the face constructed using the mesh vertices and (2) using EdgeLine to create a line for each edge. On each printout line (a few are shown below), the distance to the closest edge is very small, around 1e-14 when using vertice-created lines and around 1e-6 when using EdgeLine-created lines. Changing the document Absolute tolerance made no difference in this result.

Vertices:  face 1720 Distances = 8.8818e-16, 1.7747e-01, 6.7850e-02
EdgeLines: face 1720 Distances = 1.8368e-06, 1.7747e-01, 6.7850e-02

Vertices:  face 1719 Distances = 1.4222e-01, 1.4211e-14, 2.1637e-01
EdgeLines: face 1719 Distances = 1.4222e-01, 8.2492e-07, 2.1637e-01

One could say both are small so why worry? But for large meshes with 10M faces, I had been getting many failures in identifying the correct edge using EdgeLine. Now that I have switched to using vertice-created lines, all these failures are gone. This has provided a major improvement in the robustness of my mesh trimming script.

Is it reasonable that these two methods should give a million times different result?

EdgeLinePoor.py (10.3 KB)
TinyMeshEdgeLinePoor.3dm (341.4 KB)

Posts: 1

Participants: 1

Read full topic

Does Rhino6 Grasshopper has a dll hell?

$
0
0

@Nguyen_Minh_Chau wrote:

I encountered this problem a few months ago. Please see this thread. My post is at the end

Basically, I could not call out my recently created custom object even when I already load in the most recently built dll.

I came across this article about dll hell in Revit. Wonder if Rhino6 and grasshopper has a similar issue

Posts: 1

Participants: 1

Read full topic

Disable reading Instance Definition from external file

Texture fullpath

$
0
0

@gennaro wrote:

Hi all,

I am trying to get the full path in this way material.m_textures[ti].m_image_file_reference.FullPath().
The problem is that if I copy paste the project in another folder the path does not update and I get the previous one.
Is there a way to get the correct one?
Thanks

G.

Posts: 1

Participants: 1

Read full topic

Custom viewport projection

$
0
0

@sarg wrote:

Hi all,

Is it possible to define custom projections for Rhino viewports? I’m thinking of fisheye, equirectangular projections, etc., but really anything that can map screen positions to 3d rays (and vice versa) with a function.

Something tells me the projection types do a more than just that, so I’m guessing the answer is no … but thought I’d throw it out there anyway.

Jon

Posts: 1

Participants: 1

Read full topic


SetCustomGeometryFilter issue

$
0
0

@LarryL wrote:

Hi Dale/Steve,

I’m trying to create a CustomGeometryFilter delegate that just selects planar surfaces. The sample command is below. I seem to be missing something because the delegate appears to be called for all of the geometry in my model so it returns true for some things and false for others, the net result is it doesn’t return from the Get call. If I just return true all of the time in the delegate, it works fine when I select the planar srf, but of course also returns when I select other objects. I’m attaching a sample model with a planar srf to demonstrate.

What am I missing here?

using Rhino;
using Rhino.Geometry;
using Rhino.Commands;
using Rhino.Input.Custom;
using Rhino.DocObjects;

namespace examples_cs
{
public class CustomGeometryFilterCommand : Command
{
private double m_tolerance;
public override string EnglishName { get { return “csCustomGeometryFilter”; } }

	protected override Result RunCommand(RhinoDoc doc, RunMode mode)
	{
		GetObject getPlane = new GetObject();
		getPlane.SetCommandPrompt("Select planar surface.");
		getPlane.DisablePreSelect();
		getPlane.SubObjectSelect = false;
		getPlane.GeometryFilter = ObjectType.Surface;
		getPlane.GeometryAttributeFilter = GeometryAttributeFilter.TopSurface;
		getPlane.SetCustomGeometryFilter(PlanarSurfaceGeometryFilter);
		getPlane.Get();
		if (getPlane.CommandResult() == Result.Success && getPlane.Result() == Rhino.Input.GetResult.Object)
		{
			Rhino.UI.Dialogs.ShowMessage("Got it", "Message");
		}

		return Result.Success;
	}

	private bool PlanarSurfaceGeometryFilter(RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex)
	{
		//return true;
		return null != geometry && geometry is Brep && (geometry as Brep).IsSurface && (geometry as Brep).Surfaces[0].IsPlanar();
	}
}

}

Posts: 2

Participants: 1

Read full topic

WPF Custom Plugin Load error

$
0
0

@kyungmin.so wrote:

Hello, I got trouble when I load my plugin.

I developed plugin with wpf and reactiveui and visual studio 2017.

  • condition: solution Configuration is Debug
    When I set solution Configurations to Debug and start rhino6 using visual studio, Install my plugin is Ok.

But, when I open rhino.exe and install my plugin, rhino 6 suddenly closed.

  • condition: solution Configuration is Release
    When I set solution Configurations to Release and start rhino6 using visual studio, Loading plugin return error and message is below image.
    .
    But, when I start visual studio again, plugin is already installed.

When I open rhino.exe and install my plugin, rhino 6 suddenly closed samely Debug condition

In my guess, when I create DockBar, rhino is closed.

var createOptions = new DockBarCreateOptions
            {
                DockLocation = DockBarDockLocation.Left,
                Visible = true,
                DockStyle = DockBarDockStyle.LeftAndRight,
                FloatPoint = new System.Drawing.Point(0, 0)
            };
            this.MyDockBar = new MainViewDockBar();
            this.MyDockBar.Create(createOptions);

public class MainViewDockBar : DockBar
    {
        private readonly MainView mainView;

        public MainViewDockBar()
            : base(MyRhinoCAMPlugIn.Instance, BarId, "WPF")
        {
            this.mainView = new MainView();
            this.SetContentControl(new WpfHost(this.mainView, null));
        }

        public static Guid BarId => new Guid("{c520731e-376a-4d82-975a-403664fca2fc}");
   }

this is my creating dockbar code.

I don’t know why my plugin can’t load.


When I change dockbar to Panel, No error happen…

-Kyungmin

Posts: 1

Participants: 1

Read full topic

Opening Panel with mouse (RMB then LMB on plugin name)

$
0
0

@gabor.konstanzer wrote:

Hey there, it seems to me that opening the panel of my plugin via the panel-tabs bar has changed between Rhino5 and 6. I have a text editor in on my panel and it has information inside it. If i close it and reopen it via the panel-tabs bar in rhino5 it seems to me that it just hides and shows the panel, but in rhino6 it somehow shows another instance of the plugin-panel, which is uninitialized because I don’t handle this scenario apperently.

If I just Open the panel like this at first, then it start the plugin and goes through the init process and works just fine. The problem only appears if I close it like this and reopen it like this.

I have 2 possible scenarios in my mind.

  1. Rhino6 somehow has a cached version of the raw UI and shows that on reopen.
  2. Rhino6 truly closes the whole plug-in(in contrast to rhino5) with this panel-tab bar mouse way, and then it restarts the plug-in on reopen and I just don’t catch that scenario and don’t initialize my plug-in.

Could someone help me with this, what can cause this and how to solve no loose information on reopen?

Thanks,
Kosi

Posts: 1

Participants: 1

Read full topic

Bug within Attribute Name in Rhino6

$
0
0

@mi_sprinzl wrote:

Hello,
maybe someone knows a work around. I had no problems with this snipped of code in Rhino5 but in Rhino6 it makes some strange mistakes:

Rhino.DocObjects.ObjectAttributes Attributes = new Rhino.DocObjects.ObjectAttributes();
Attributes.Name = “[DEF]Area[NAME]” + Command;
var guid = doc.Objects.AddCurve(Rec.ToNurbsCurve(), Attributes);

In Rhino5 the Name is => [DEF]Area[NAME]Command => Super Duper OK
In Rhino6 the Name is => ^[DEF]Area[NAME]Command => Error

What going on in Rhino6. I never switched because of performance issues with Rhino6 but some clients want to move to Rhino6. This is a serious bug because lots of projects are based on Naming convention.

cheers
Michael

Posts: 3

Participants: 2

Read full topic

AssemblyInfo generator class for Rhino

$
0
0

@ivelin.peychev wrote:

Hi @stevebaer,

I see when compiling ghpy plugins the AssemblyInfo class derives from the class GhPython.Assemblies.PythonAssemblyInfo

How feasible would it be to create similar class for compiling Rhino Plugins as well?

Or perhaps it already exists?

Thanks in advance.

Posts: 1

Participants: 1

Read full topic

Viewing all 8553 articles
Browse latest View live