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

Null Exception when trying to create GH_Structure

$
0
0

@a.ai wrote:

I want to create a data tree (GH_Structure) from two collections of curves (superblocks and parcels), checking which parcels are inside which block and assigning them to the respective block (parent node) as children. Each branch should contain one GH_curve object.
I get a Null Exception (Object reference not set to an instance to an object).
What am I doing wrong? I suspect I dont generate a valid data tree.

    private void RunScript(List<object> x, List<object> y, ref object A, ref object B)
    {
    List<GH_Curve> BlockCurves = new List<GH_Curve>();
    List<GH_Curve> ParcelCurves = new List<GH_Curve>();

    GH_Structure<IGH_Goo> dataTree = new GH_Structure<IGH_Goo>();
    List<GH_Curve> myParcelCurves = new List<GH_Curve>();

    foreach (object crvItem in x)
    {
      GH_Curve gh_curve = new Grasshopper.Kernel.Types.GH_Curve();
      GH_Convert.ToGHCurve(crvItem, GH_Conversion.Both, ref gh_curve);
      BlockCurves.Add(gh_curve);
    }
    Print(BlockCurves.Count.ToString());

    foreach (object crvItem in y)
    {
      GH_Curve gh_curve = new Grasshopper.Kernel.Types.GH_Curve();
      GH_Convert.ToGHCurve(crvItem, GH_Conversion.Both, ref gh_curve);
      ParcelCurves.Add(gh_curve);
    }
    Print(ParcelCurves.Count.ToString());



    // check if information on buildable areas has been passed by user, use respective curve collection

    myParcelCurves = ParcelCurves;

    for (int i = 0; i < BlockCurves.Count; i++)   //for each block create path and fill in GH_Curve
    {
      Polyline block = new Polyline();
      bool cast = BlockCurves[i].Value.TryGetPolyline(out block);
      if (cast && block.IsValid && block.SegmentCount > 2)
      {
        GH_Path pth = new GH_Path(i);
        dataTree.Append(BlockCurves[i], pth);
        Print(pth.ToString());
        //Print(i.ToString());

      }
      else { Exception e = new Exception("Block at index " + i + " is either invalid or not a polyline."); }

      int parcelPathIdx = 0;
      for (int j = 0; j < myParcelCurves.Count; j++)    //for each parcel check if in block, if yes, append to (new) path
      {
        Polyline parcel = new Polyline();
        bool cast1 = myParcelCurves[j].Value.TryGetPolyline(out parcel);
        if (cast1 && parcel.IsValid && parcel.SegmentCount > 2)
        {
          if (IsInside(parcel.CenterPoint(), block))
          {
            GH_Path path = new GH_Path(i, parcelPathIdx);
            dataTree.Append(myParcelCurves[j], path);
            //Print(parcelPathIdx.ToString());
            Print(path.ToString());
            parcelPathIdx++;

          }

        }
        else { Exception e = new Exception("Parcel at index " + j + " is either invalid or not a polyline."); }//check if parcelcurve is inside block
      }

    }
    Print(dataTree.DataCount.ToString());
    //Print(dataTree.AllData().ToString());
    A = dataTree;

    Print(dataTree.PathCount.ToString());
    //B = myPaths;
  }

  // <Custom additional code> 
  public static bool IsInside(Point3d _pt, Polyline _crv)
  {
   //checks if point is within a curve
  }

Posts: 5

Participants: 2

Read full topic


Embedding blocks by batch in Rhino 6

$
0
0

@Darryl_Menezes wrote:

Hi,
I have many linked blocks in a file. And most of the linked blocks have common child blocks inside them. I am selecting blocks, and looping through all selected blocks. For all those selected blocks, I use

foreach (InstanceDefinition iDef in instanceDefinitionsToEmbed)
{
Doc.InstanceDefinitions.DestroySourceArchive(iDef, true);
}

The blocks are ebmedded, but as they contain common child blocks, I keep getting the prompt where I have to choose whether to keep Model Block, File Block or Both blocks.
If there are 1000 blocks, I have to respond to the prompt 1000 times as each of them have common child blocks. Is there any way to skip this and always choose one option untill and unless specified? Thanks

Posts: 2

Participants: 2

Read full topic

Big Files with a lots of point

$
0
0

@Markus_Erhardt wrote:

Hi everybody, I have files containing a lots of points (all of them contains informations) and when I
execute the function Rhino.Command("_-Export myfile.3dm ", vbFalse) it takes really too long. Is there a way to be faster?

Posts: 1

Participants: 1

Read full topic

Block edit issue - update?

$
0
0

@ParanoidAndroid wrote:

Hi,

will these issues:

be prioritized at some point?

Currently the problems with the block edit mode are the only thing preventing us from using the changequeue instead of observing the changes made to the objects within the rhino doc. I’ve tried several approaches to workaround the issue but as soon as nested blocks are involved every single approach fails.

For an alternative, “alternative” solution: Is there by chance an event that is raised when the block edit mode is finished/canceled that I am not aware of?

Posts: 1

Participants: 1

Read full topic

C++ Is there a tween curve/surface function?

I want to know about usefulness of scripts

$
0
0

@avungyerd wrote:

Hi,there
I started to learn python script.
I want to know usefulness of scripts at grasshopper.
What advantages do you make to creat scripts,and what scripts is suitable for rhino and grasshopper?
I am sorry for the vague question, but I would like to know what I can do to use scripts .

thank you.

Posts: 4

Participants: 3

Read full topic

How to compile C++ ON code as dll?

$
0
0

@pagarcia wrote:

Hello,

I have a library (basically a derived piece of ON_UserData) that I need to compile as dll to use in a RH5 C++ plug-in.

Is this possible? What is the way to do it?

Many thanks,
Pablo

Posts: 4

Participants: 2

Read full topic

Wrong SDK help .chm file included in Rhino 6 SDK


Preview NurbsSurface in conduit

$
0
0

@adl.architetto wrote:

Hi, i’m trying to give a preview of a nurbs surface my plugin is generating before the users presses enter to confirm the settings.
In the CRhinoDisplayPipeline there is DrawNurbsSurface(const ON_NurbsSurface &nurbs_surface, int display_density=1), which is useful, but it only dispalys the wires. What i’d like is to offer a shaded preview of the nurbs surface.

Any idea how to get that done?

NOTE:what i tried was to try to use ON_Brep::Create(ON_NurbsSurface *&pNurbsSurface) method to create a Brep out of the ON_NurbsSurface, and use that to call DrawShadedBrep (brep), but the Create() method throws an access violation.

Posts: 1

Participants: 1

Read full topic

RTree search Overlaps

$
0
0

@dsonntag wrote:

Don’t know if I should post this here or another group, if this is the wrong group feel free to move the topic. I am scripting some stuff in Grasshopper, but basically the questions refers rather to Rhino.Common objects.

I have the following code to find the overlap between two RTrees:

// class level variables
private List<int> index1;
private List<int> index2;

// Callback Function
void SearchCallback(object sender, RTreeEventArgs e)
{
    this.index1.Add(e.Id);
    this.index2.Add(e.IdB);
}

// ... this happens inside a method
this.index1 = new List<int>();
this.index2 = new List<int>();
double tol = 1.0E-3;
RTree tree1 = new RTree();  
RTree tree2 = new RTree();

// ...
// some code to fill the trees
//

RTree.SearchOverlaps(tree1, tree2, tol, SearchCallback);

So this all seems to works OK, sometimes many intersections are found, sometimes none, but still two questions:

  1. Why does the SearchOverlaps function always return false ? This would mean not the entire tree had been searched, but doesn’t seem to be the case
  2. For now I get my results using class level variables which are assigned in the callback function, is this the way this is supposed to work? The other search functions have an object argument in the function header, which allows to pass around search data.

Thanks!

Posts: 3

Participants: 2

Read full topic

How does Rhino History data structure look like?

$
0
0

@ivelin.peychev wrote:

Following this discussion:

I watched a video explaining that Grasshopper evolved from Rhino History. I assumed the data structure would be the same. As far as I understand everything inside GH happens around the Data Trees, but now it appears Data Trees are nothing but advanced lists. They do not contain information about how 2d/3d objects are changed they only contain lists of objects (being it 2d/3d, strings, int, float, transformations, etc)

If so, how is then History remembering “parent” objects. Is there a way via code/scripting to access “parent” objects from the history? Therefore, in a way to get the actual object not by defining it directly but through definition of its “parents”?

Posts: 3

Participants: 2

Read full topic

Form Show() opening window behind Rhino UI

$
0
0

@pkinnane wrote:

Hi - as per the title - in Rhino6, I see a random situation where the following code opens my form UNDER the Main Rhino UI panel (so there is a second icon on the Windows toolbar, and the Rhino window has to be moved to see my form). This does NOT happen in Rhino5. My code is…

MyForm.Show(System.Windows.Forms.Control.FromHandle(Rhino.RhinoApp.MainWindowHandle()));

Does anyone know how to fix this pls?

Thanks

Paul

Posts: 1

Participants: 1

Read full topic

How to handle mouse click to execute rhino command?

$
0
0

@664667296 wrote:

How to handle mouse click to execute rhino command?
when I add a command in Button_Click envent,the command is not executed.

Posts: 3

Participants: 1

Read full topic

*.wrl import in Rhino 6 succeeds but file has no content

$
0
0

@s.andraos wrote:

Hi,
I’ve just tried importing a *.wrl file into Rhino 6 and, as the title indicates, the process was marked as successful -"Successfully read file “D:\Downloads\Cube_1mAtOrigin.wrl” but there is nothing in my rhino file afterwards. The mesh is present when I open the same file with Rhino 5.
The attached file is a minimal repro, cube with sides of 1m with the base face(s) centred on the origin.

Has to be zipped to allow upload.

Cube_1mAtOrigin.zip (511 Bytes)

Thanks in advance,

Sebastian

Posts: 2

Participants: 2

Read full topic

How to use color bar in Rhino


Run/Solve a Grasshopper file without starting Rhino

$
0
0

@val.martinez2045 wrote:

I would like to run a Grasshopper file without actually starting Rhino, or at least with no UI. My use case is to solve, bake and export meshes on a server, using various input parameters. Speed matters because the baked meshes should then be available for the person that made the request.

Since I don’t need the editor UI on the server and displaying the meshes naturally consumes time and resources, I’m looking for a way to avoid that. Preferably by using the RhinoCommon.dll without actually starting Rhino or alternatively by running Rhino headless (to avoid render and editor overhead).

Is this possible with Rhino 6? I’ve looked for docs about this but so far haven’t been lucky.

I’ve seen similar questions have been asked in the past, but perhaps something’s changed by now (or perhaps when Rhino Inside is ready?).

I’ve already built a demo based on the SampleCsAutomation example, but it doesn’t work without UI and with UI it’s not terribly fast.

Posts: 4

Participants: 2

Read full topic

Rhinoscriptsyntax as Rhinocommon sources

$
0
0

@Jarek wrote:

Hi All,

I recall seeing an online version of all of the Rhinoscriptsyntax methods as RhinoCommon source code. Can’t find it now… any ideas where to look?

thanks

–jarek

Posts: 1

Participants: 1

Read full topic

Cant not turn off object grips in v5 (c#)

$
0
0

@pythonuser wrote:

Hi;
I run this core in v5 sr14, after the program stop, the surface’s grips still turn on.How cant I turn off the surface’s grips?

            Rhino.DocObjects.ObjRef objRef;
            Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetOneObject("Select surface for control point editing", false, Rhino.DocObjects.ObjectType.Surface, out objRef);
            if (rc != Rhino.Commands.Result.Success)
                return rc;
            Rhino.DocObjects.RhinoObject obj = objRef.Object();
            if (null == obj)
                return Rhino.Commands.Result.Failure;
            Rhino.Geometry.Surface srf = objRef.Surface();
            if (null == srf)
                return Rhino.Commands.Result.Failure;
            obj.GripsOn = true;
            doc.Views.Redraw();
            Rhino.DocObjects.GripObject[] grips = obj.GetGrips();
            for (int i = 0; i < grips.Length; i++)
            {
                Rhino.DocObjects.GripObject grip = grips[i];
                double u, v;
                if (srf.ClosestPoint(grip.CurrentLocation, out u, out v))
                {
                    Rhino.Geometry.Vector3d dir = srf.NormalAt(u, v);
                    dir.Unitize();
                    dir *= 0.5;
                    grip.Move(dir);
                }

            }
            doc.Objects.GripUpdate(obj, true);

            obj.GripsOn = false;//Cant not turn off object grips

            doc.Views.Redraw();
            return Rhino.Commands.Result.Success;

Posts: 1

Participants: 1

Read full topic

3mf material support

Get highest point of geometry / get points actually touching the bounding box

$
0
0

@alexander.meyer wrote:

Is there a way to get the point / line / curve “setting” the extend of a bounding box in a specific direction?

I have a mesh and need to get the point with the biggest z-value. From the bounding box, I can of course get the z-value itself, but how do I now find the point / curve that is actually touching the BoundingBox?

I tried Mesh/Plane intersections, but don’t get any intersections, since it is just a “touching” contact.

Any way to get the actuall touching point?

EDIT: Should propably have mentioned this before, I am working in RhinoCommon.

Posts: 3

Participants: 2

Read full topic

Viewing all 8594 articles
Browse latest View live