Quantcast
Channel: Grasshopper Developer - McNeel Forum
Viewing all 3642 articles
Browse latest View live

How to set scale and target of detail?

$
0
0

@Jakob1 wrote:

Hi,

This is probably a python/rhinoCommon beginners question, but I cant seem to solve it on my own.

I want to create a layout, add a detail view to the layout (top view, but preferably changeable to any other 'standard view'). So far I have managed this by:

if RUN == True:
    rs.AddLayout(name, size)

for layout in sc.doc.Views.GetPageViews():
sc.doc.Views.ActiveView = layout
layout.AddDetailView(name + '1', corner1, corner2, r.Display.DefinedViewportProjection.Top)

I then want the detail view to center over a target point in the rhino document and zoom so it shows the objects in the detail in a certain scale. Should I first create a DefinedViewportProjection that is centered over the target, and then use this to add the detail, or should I rather move the camera after creating the detail? I can't find a method to set the camera of a detail view or zoom. Please help!

Posts: 1

Participants: 1

Read full topic


Ins and Outs of drawing to screen space

$
0
0

@andheum wrote:

I have quite a number of GH components that render geometry (text, curves, meshes, etc) to fixed viewport coordinates to create a sort of "heads-up display." These have always worked okay-but-not-great - the strategy I employ has some drawbacks. What I'm doing generally is to use some of the methods on RhinoViewport like GetWorldToScreenScale and GetFrustum(near/far)Plane in order to figure out where to draw. I am typically picking some depth parameter along the frustum and positioning a screen-parallel plane there, and using ClientToWorld/WorldToClient to convert coordinates.

Some of the limitations of this approach:

  • Depending on what "depth" parameter is chosen, it is hard to control whether the geometry I draw goes "behind" real scene objects. I have tried Push/Pop Depth Testing, Enable/Disable Depth Writing, setting the DepthMode, etc, but have never been successful - perhaps I am just not understanding.

  • I also struggle with clipping issues. I can manipulate the component's clipping box, but this is unfortunately designed for use with world-oriented geometry and not calculated on a per-viewport basis. Because the geometry I'm drawing may be very far from the origin (and the scene) it seems like a mistake to add it to the scene bounding box. is there anything else I can do to prevent clipping, or a better strategy for working with the component's ClippingBox?

  • With these components in use, right-click orbit behavior in the viewport behaves unexpectedly (setting the center of the orbit far away from what one would expect, requiring a constant "recentering" with zoom-selected or some other method.) Is there a way to exclude certain drawn geometry from this calculation?

Would greatly appreciate any guidance DisplayPipeline gurus have for me!

Posts: 1

Participants: 1

Read full topic

Crashing Bug with Grasshopper

Debugging C# Grasshopper Components

$
0
0

@BruceHilbert wrote:

I'm learning to write my own Grasshopper components in C# utilizing the Visual Studio plugin. While I can build the example plugin and utilize it in Grasshopper, when trying to set a breakpoint and debug I run into the exception shown in the screenshot below. I'm afraid I'm a Linux guy, so sorting this sort of low level problem on Windows is not my forte. Any help would be appreciated.
Thanks,
Bruce

Posts: 5

Participants: 3

Read full topic

EtoDocumentEditor not accessible on windows GH in v6

$
0
0

@andheum wrote:

I'm trying to build a cross-platform GH plug-in. It builds nicely on mac under the WIP, but the Grasshopper.Instances.EtoDocumentEditor property is missing on windows. I'm trying to set the owner of an Eto window to be the GH editor - the line of code is this:
HuiWindow.Owner = Grasshopper.Instances.EtoDocumentEditor;

Is there something else I can do, say inside a compile conditional? I tried some stuff with the eto window's NativeHandle property but couldn't figure it out. Or, maybe better, can this property be made accessible in a windows build?

paging @curtisw and @DavidRutten :slight_smile:

Posts: 3

Participants: 2

Read full topic

DataTrees with multiple data types

$
0
0

@BruceHilbert wrote:

Pardon me if my google-fu is weak but I couldn't find this anywhere.

I mostly understand how to work with Datatrees in a component I'm writing in C#. However, our application (which I'm trying to replace bit by bit with custom components) utilizes mixed type Datatrees. For example, we have a tree where each branch contains a point in the first entry, and int then the second, a vector in the third, etc. How do I create such a beast in C#? Is there some sort of multi-templating paradigm I'm not aware of?

Posts: 3

Participants: 2

Read full topic

Adding UserData in GH

$
0
0

@Philipp1 wrote:

Hi guys,

I am trying to add a custom object-type via UserData.add(...) to Geometry Objects using the C#-component. I m currently writing gh components which do an "equivalent" job as a rhino plugIn (which is already there), that uses UserData already. The PlugIn orientates on this http://developer.rhino3d.com/guides/rhinocommon/plugin-user-data/
and I was wondering whether the same idea works also within gh. I tried UserString & UserDictionary which is working fine, but this would mean some enormous workaround in the existing code (of the plugIn) which I m trying to avoid...

I got this helpful example (http://frasergreenroyd.com/how-to-add-custom-user-data-to-rhino-obj...) but its just not working out for me and I woudl like to understand the reason. I am always getting "Object reference not set to an instance of an object".

The Class which is storing the UserData looks like this. Its built in VS and referenced as .dll into the scripting component:

 public class MeshUserData : Rhino.DocObjects.Custom.UserData
 {
     public List<double> meshResults;

     public MeshUserData()
     {
          meshResults = new List<double>();
     }
  }

I attached the .gh (I cant provide the .dll here) which I am using. Many thanks for any help or hints I could get on understanding the problem and reason behind this Error and making it work!!
AddUserDataTest.gh (2.2 KB)

Posts: 1

Participants: 1

Read full topic

Automating Grasshopper as a Windows Application

$
0
0

@ParamDesSing wrote:

Be warned, this is a pretty obscure question.

Has anyone every tried to automate Grasshopper from "outside", i.e. manipulating as a windows application?
Especially with components that use additional windows, like, for example Galapagos?

As I see it, this woudln't be possible via the Grasshopper SDK, since the controls of the Galapagos windows are not exposed (not to mention third-party components).

Instead, I'm looking at way to automate windows apps, such as:



These are based on .Net, Python 2.7 and a custom scripting language, respectively.

My question is:
Has anyone ever tried something like this? What would be major obstacles?
(For now, I think the biggest challenge would locating components and clicking them, since one wouldn't necessarily know where they are. One the other hand, using menus and buttons and typing text should be fine.)

Posts: 1

Participants: 1

Read full topic


Equivalent of TextObject in RhinoCommon

$
0
0

@snabela wrote:

Is there an equivalent of Rhino's TextObject command in RhinoCommon, which directly creates surfaces from text? I am using Rhino.Geometry.TextEntity.Explode so far to create curves from text, but for some fonts the results are unusable.

Posts: 1

Participants: 1

Read full topic

Visual Studio debug C#

$
0
0

@Jakob1 wrote:

Hey,
I'm having problems with the Visual Studio debugger.
I've written a simple C# component that I can both run and debug on my other computer, but when I tru to run the debugger from Visual Studio i get this message:

FatalExecutionEngineError occurred
Message: Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'c:\Program Files (x86)\Rhinoceros 5\System\Rhino4.exe'.
Additional information: The runtime has encountered a fatal error. The address of the error was at 0x14ff0efa, on thread 0xe78. The error code is 0x80131623. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

Which is also quite strange as Im running Rhino 5 and not Rhino 4.

I suppose this question is quite similar to https://discourse.mcneel.com/t/visual-studio-grasshopper-debugger/21883/4 , but I cant get it working just by setting up the /bin in GrasshopperDeveloperSettings, it seems something else is wrong too. I get the same error when I try to debug an empty GHA template.

Posts: 1

Participants: 1

Read full topic

rs.ExtendSurface returns bool!?

$
0
0

@Jakob1 wrote:

Hey,
Im trying to create a rhinoscript/python node that extends an untrimmed surface, but reading the documentation on rs.extendSurface I found this in the online documentation:

Parameters:
surface_id = identifier of a surface
parameter = tuple of two values definfing the U,V parameter to evaluate.
The surface edge closest to the U,V parameter will be the edge that is
extended
length = amount to extend to surface
smooth[opt] = If True, the surface is extended smoothly curving from the
edge. If False, the surface is extended in a straight line from the edge
Returns:
True or False indicating success or failure

rs.ExtendSurface returns only true or false indicating success or failure, but no actual surface or surface_id!?
How can I retrieve the exteneded surface for further GH operations?

Posts: 3

Participants: 2

Read full topic

Debugging C# Grasshopper Components in Visual Studio without starting Rhino

$
0
0

@BruceHilbert wrote:

As a follow up to this thread, I was wondering if there is a straighforward way to set up a different VS configuration to allow the debugging of some complex code without the need to start Rhino. In particular, I'd like a configuration that starts in a Main() where I could test some code/classes that will eventually be used in a component proper. I've played with this but have been unable to get it to work. My VS-fu is weak :slight_smile:

Posts: 2

Participants: 2

Read full topic

Define outputs from within the ghpython code

Run grasshopper from python/Rhinocommon

$
0
0

@Willem wrote:

Hi,

I know one can run python scripts inside grasshopper components. However I'm investigating if I can run grasshopper inside a python script.

E.g:
I want to run a python script where somewhere in the pipeline I run my geomtry through a grasshopper definition and collect the output for further processing in python.

Thanks
-Willem

Posts: 2

Participants: 2

Read full topic

Coerce Guid Failure in Python with Rhinoscript Syntax

$
0
0

@drdru7029 wrote:

Hi, I've come across a strange error regarding type hints which has been stopping me from being able to use certain rhinoscript syntax functions. I can create and manipulate geometry as usual, sometimes needing to change the type hint from guid to curve, etc. When I try to change the type hint back into a guid for use in another function, it fails and I the type check shows 'NoneType'. Is there something I'm doing wrong or, otherwise, any way to retrieve a guid in this situation? Thanks!
Link to image of problem

Link to GH file: type hint.gh (2.7 KB)

Posts: 2

Participants: 2

Read full topic


Grasshopper doesn't like Tektosyne library

$
0
0

@ZUARDIN_AKBAR wrote:

Hi Everyone!

I am trying create a WPF window that will open everytime i doubleclick my component. The window itself does work but then when I tried to use a library called Tektosyne (you can find the library here http://www.kynosarges.de/Tektosyne.html) the component just disappeared from GH. The reason why i use this library because i want to build some function related to geometry and graphic for interactive data visualization. I am planning to use it for generating delaunay and set a pixel info of the visualization graphic.

Does any one has experience with similar problems?

Cheers!

Akbar

Posts: 1

Participants: 1

Read full topic

Rhino crashes on native call

$
0
0

@Gustav_Good wrote:

I am trying to implement some Intel Math Kernel Library functionality in a grasshopper plugin. See link below for the example I am trying to implement:
https://software.intel.com/en-us/articles/using-intel-mkl-in-your-c-program
I can get this working in a c# windows forms program just fine, but as soon as I run it through grasshopper and I make a call to the mkl-dll's Rhino and Grasshopper crashes without giving me an exception.
See code code snippet below:

/** Pardiso wrappers */
public class Pardiso
{
private Pardiso() { }
public static int pardiso(IntPtr[] handle,
ref int maxfct, ref int mnum,
ref int mtype, ref int phase, ref int n,
double[] a, int[] ia, int[] ja, int[] perm,
ref int nrhs, int[] iparm, ref int msglvl,
double[] b, double[] x, ref int error)
{
return PardisoNative.pardiso(handle, <--!!!RHINO CRASHES HERE!!!
ref maxfct, ref mnum, ref mtype, ref phase, ref n,
a, ia, ja, perm, ref nrhs, iparm, ref msglvl,
b, x, ref error);
}
}
/** Pardiso native declarations */
[SuppressUnmanagedCodeSecurity]
public class PardisoNative
{
private PardisoNative() { }
[DllImport("mkl_rt.dll", CallingConvention = CallingConvention.Cdecl,
ExactSpelling = true, SetLastError = false)]
internal static extern int pardiso([In, Out] IntPtr[] handle,
ref int maxfct, ref int mnum,
ref int mtype, ref int phase, ref int n,
[In] double[] a, [In] int[] ia, [In] int[] ja, [In] int[] perm,
ref int nrhs, [In, Out] int[] iparm, ref int msglvl,
[In, Out] double[] b, [Out] double[] x, ref int error);
}

Am I doing something wrong?

This is all I get from Visual Studio:

The program '[6772] Rhino.exe: Managed (v4.0.30319)' has exited with code 2 (0x2).

See grasshopper forum post for complete code:
http://www.grasshopper3d.com/forum/topics/native-call-causes-grasshopper-and-rhino-to-crash

Posts: 2

Participants: 1

Read full topic

Mechanism for referenced Rhino geometry refresh

$
0
0

@andheum wrote:

So I'm a bit puzzled by something. Everything I try in my own component to construct geometry from an object reference in rhino, it only seems to get me halfway to normal "Referenced Object" behavior - it shows up as "Referenced Brep" or "Referenced mesh" and I can see it - but when the geometry changes, it does not update dynamically. if I just spit out the Guids and pass them through a geometry parameter in GH, everything behaves as expected - but if I try to construct the referenced geometry myself, no dice. What happens in that moment that tells the param to "expire" or refresh itself when the geometry is changed?

Posts: 5

Participants: 2

Read full topic

Need help, Python recursive subdivision

$
0
0

@Jakob1 wrote:

Hey,
I've been trying to create a python function that takes a flat list of closed triangular polylines and subdivide dem at a given parameter (in my example .5 of each curve) returning 4 new triangles for each polyline in the line. I would then like to set the number of iterations, so that 1 polyline triangle first turns into a total of 4, 16, 64, etc, forming smaller and smaller polyline triangles within the scope of the first one. I'm not a very experienced progammer and this is the first time I take on the task of creating a recursive function, so please bear with me.

I've managed to get the basic recursiveness of the function working, altough it the recursive part seems to only iterate over the last polyline in the list. I've been staring at this for hours now and would be really greatful for any help getting this right!

Here is my function:

#performs subdivision on a list of equilateral triangle polylines

def subDivEquiTriangles2(polylines, generation, recursionLevel):
    if generation > recursionLevel: return
    generation += 1

    for p in polylines:
        newPoints = []
        for i in range(len(p)-1):
            newPoints.append(Rhino.Geometry.Point3d((p[i][0] + p[i+1][0])/2, (p[i][1] + p[i+1][1])/2, (p[i][2] + p[i+1][2])/2))
        subD = [
        Rhino.Geometry.Polyline([p[0], newPoints[0], newPoints[2], p[0]]),
        Rhino.Geometry.Polyline([newPoints[2], newPoints[1], p[2], newPoints[2]]),
        Rhino.Geometry.Polyline([newPoints[0], p[1], newPoints[1], newPoints[0]]),
        Rhino.Geometry.Polyline([newPoints[0], newPoints[1], newPoints[2], newPoints[0]])
        ]
        #REPLACE EACH VALUE IN SUBD WITH 4 NEW
        if generation <= recursionLevel:
            for i in range(len(subD)):
                subD[i:i+1] = subDivEquiTriangles2(subD, generation, recursionLevel)
    return subD

and here is a picture of what it produces:

Many thanks

Jakob

Posts: 5

Participants: 3

Read full topic

Loops in ghPython

$
0
0

@nazanin_tabatabaei wrote:

hello,
I have a question about loops in gh.python.
The loop is supposed to do something until the input is y, in this case(print"why").however it doesn't do the tasks (print"why") until my input is "y".and then it will print all of them at once. I was wondering if there is a way to see the results each time I run the loop instead of waiting until it ends and then see them all together?!

while True:
x=rs.GetString("u happy?")
if x=='y':
break
if x=='n':
print("why")

Posts: 1

Participants: 1

Read full topic

Viewing all 3642 articles
Browse latest View live