Grasshopper

algorithmic modeling for Rhino

Hi to all,

I'm writting a custom component for Grasshopper in C# with Visual Studio. I have as input:

protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddBrepParameter("BReps", "B", "Breps surfaces", GH_ParamAccess.list);

...

}

Now I select all Breps and export to a IGES file:

Rhino.RhinoApp.RunScript("_-SelAll " + " _Enter", true);
Rhino.RhinoApp.RunScript("_-export " + mIGESFileName + " _Enter", true);

But what I want is to select only the Breps passed as input not all what is present in the Rhino document.  How can I achieve this?

Thanks

Robert

Views: 619

Replies to This Discussion

Hi Tom,

Thanks for answering. Your solution greatly works for me. Thank you.

Rhino.RhinoApp.RunScript("_-SelAll " + " _Enter", true);
Rhino.RhinoApp.RunScript("_-export " + mIGESFileName + " _Enter", true);

That code specifically runs commands on the Rhino document. Those commands are not aware that Grasshopper exists, let alone that there's some breps in a parameter somewhere.

If you have to use the -_Export command, then your only choice is to:

  1. (optional) Hide/delete all objects in the Rhino document? If you can export selected only you don't have to do this.
  2. Bake your objects (you'll have to invent some attributes for them as well, layer, colour, name, etc.)
  3. Select your objects.
  4. Run the Export command.
  5. Delete your objects.
  6. Reinstate the Rhino objects, this means showing/undeleting and potentially restoring the selection.

As you can see that's pretty horrible. An alternative approach is to make a new 3dm file featuring only your breps and then somehow load that file and run the command on it.

I think Steve Baer has been working on (or at least thinking about) ways to run export and import apis on virtual 3dm documents, but you'll have to ask him about that on discourse.

HI David,

Thanks for answering. Your solution is a good alternative i will try for sure. Why do you think this solution can be better than that proposed by Tom based on GUIDS?

Thanks

Robert

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service