How to create a vertex position list

I’m a Sound Engineer by profession and I often have to use simulation software to design large arena sized Sound systems. The simulation software that is provided by the manufacturer is not able to import any file format other than a text file of polygon vertex points, in a particular format. I have workflow at the moment which usually starts with importing a DXF or DWG file and then generating polysurfaces of the useful features. The relevant layers of polysurfaces are then exported out of Rhino as an OBJ file. That OBJ file is then imported into Modo where I use a python script to extract the point positions of each polygon and save this resulting list as a text file that the Simulation software is able to import. In a ideal world I’d like to do all the scripting in one piece of software ( Rhino) which would save time when someone changes the design. Attached is an example text file which is then imported into the simulation software. I’m not a programmer and it took me a while to figure out the Python script for modo, the essence of which is as follows:

meshes = modo.Scene().items(itype='mesh')

for mesh in meshes:
    for polygon in mesh.geometry.polygons:
        f.write('"Label","{} {}"\n'.format(mesh.name, polygon.index))

        for vertex in polygon.vertices:
            f.write('{},{},{}\n'.format(*vertex.position))
        f.write("\";\"\n")
f.close()

ExampleFile.txt (2.6 KB)

I’m sure this is something that can be achieved within Rhino or Grasshopper I just need a bit of direction.

Hey Colin,

have you ever opened a .obj file with the text editor when saved as ascii? you basically have the list complete already in there. a 5min work on excel would do fine I think.
Untitled

and another question. in this ideal world you describe, what exactly is automated? the point extraction?
can you provide an example file where the relevant layers are visible?
Ben

Hi benedict, Yes the excel route would work, but as I mentioned previously, elements of the drawings often change and I’d rather be able to work within Rhino if I can in order to streamline the process and reduce possibility of Spinal Tap style errors. Essentially I’m looking to pull the vertex positions of each polysurface into the a text file that can then be imported into the simulation software. I’ve attached a simplified example of the file I export to Modo. In Modo my script runs through each layer and writes the vertex positions of each polygon to the txt file.
Simplestage.3dm (1.5 MB)

Hi again,

I quickly threw something together

meshVertex2txt.gh (8.8 KB)


Untitled

does this do what you need?

I am sorry its in c# and not python, but its just the writing part, I’m pretty sure you could do the same thing with py in the py editor or figure out how to change the code.

with this change you can extract each surface edge point and write to the file:

1 Like

Thanks Benedict, Looks like its going in the right direction, although it doesn’t work for me, I wonder if its because I’m running the Mac version of Rhino? thanks for looking at this.
Colin

Hey @colinpartridge

oh, thats a pity, I don’t have a mac, but was sure c# would be working for both win and mac…
I admit not to know how to correct that without having a mac :frowning:

what does it show? is the c# element red or do you simply have no output?

B

Hi Benedict, I’m new to the whole grasshopper world so its more than likely my problem. I’ll get back to you soon, I thought I had a couple of free days to work on this but some paying work is getting in the way.
Cheers

Colin

1 Like

Hi Benedict, finally found time to look at this again, it was failing because of the path definition. Once I had changed that to a path node and pointed it to a txt file on my mac it worked as expected. This looks like a promising start. Thanks for your help.
Colin

Hey Colin,

that’s great news. Well done! I suspected it to be some problem with the path, but have no clue how mac’s file structure works…

Have you seen the “python script” element in grasshopper? I you are more comfortable with python than C#, this might be a better playground:)

If you don’t mind posting your working result here, it might helps other users looking for the same goal and would complete the win and mac “collection”

Ben