Grasshopper

algorithmic modeling for Rhino

Here's some background: I am trying to move geometry as smoothly as possible between GIS and Grasshopper. I am in the midst of writing a python script that will output dxf files from GIS (as DXF_R14). Then I would import the DXF file into rhino and bring objects into Grasshopper by their object ID. The challenge in moving the geometry is retaining a specific order to the geometry, so that I can associate any list of data that I want with that geometry, whether it is in GIS or Grasshopper.

It occurred to me that Rhino files have id's for all the objects, and it is possible to "name" objects with scripting tools in Rhino, in order to give them a particular object id. Maybe, possibly, I can find a way to give the geometry specific object ids in the dxf file, using python.
My question is:
if I give object ids to geometry in a dxf file, will the ids persist when I import the dxf file into rhino? Or, can rhino read object ids from dxf files, or does it rename all the geometry with new ids?

I still don't know if I can give specific ids to the dxf file, but if I can . . . . and if I can read those ids using grasshopper . . . . then it would be an awesome way to reorder geometry when I move it between GIS and Grasshopper. It would save a ton of time.

Any help is hugely appreciated!

Views: 2763

Replies to This Discussion

Hi Benjamin,

No. Rhino will assign new IDs to imported objects (only when opening a 3dm file are IDs maintained). Essentially, you should never use IDs to keep track of stuff. Either use Object Names, UserText or UserData. It is absolutely impossible to set the ID of any object, only Rhino is allowed to do this.

Also the order of objects in the Rhino document is not constant. Whenever an object is changed (moved, scaled, assigned to new layer etc.) is moved into UNDO space and a copy of the old object is placed at the top of the object-stack.

What you could do.. maybe... is adjust the IDs in the dxf file after you import the geometry into Rhino. If you have access to the file itself and you know your way around that is. But I'm not sure this solves your problem.

If your problem is only pertinent during a single runtime (i.e. if you don't need your object-matching to persist between different sessions of Rhino), you can build a database in parallel with the 3dm file which contains mappings between dxf and 3dm objects. This is a lot easier than it sounds.

Can you give an example of where it currently goes wrong when you import the geometry into Rhino? Where exactly do you lose the order of objects?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
That is extremely helpful David. Thank you. I am going to keep this in mind and revisit it later. I need to experiment a little more with the existing process. Your database suggestion sounds the closest to what I imagine is the solution with the most reliability and control, but I may not need to take it that far.
So we did a little test importing a small group of geometry from a dxf into Rhino. The dxf was exported from ArcGIS. It turns out that the order of objects in ArcGIS (which is easily viewed in the attribute table), is precisely the reverse order of the objects immediately after they are brought into Rhino.

We exported from GIS, imported the objects into rhino, and then I input the objects into Grasshopper using a command line selection method, and once in grasshopper I could test the order of the objects.
It makes sense that the object stack would be the opposite of the order in GIS, because I imagine that at some point in the import process, there is a loop that goes through the list of objects. So the the object at the end of the stack in the dxf became the most recently edited object in rhino and therefore ended up at the top of the stack.

This really useful for associating data between GIS and grasshopper, because we know that latent order has consistency. The next step might be to name the objects after they are imported into rhino according to an index that they had in a GIS database.

In the end it turns out that it is really easy to maintain the index of objects from GIS into Rhino and Grasshopper, and to therefore retain the associations of other data.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service