Grasshopper

algorithmic modeling for Rhino

Hi all,

I have subdivided a single dome surface into numerous small 4-sided (quad) and 3-sided (triangular) surfaces. I want to extract the x,y and z coordinates of vertices of each small surface. Does anyone how to implement this in Rhino?

Best regards,

Sushant

Views: 8190

Replies to This Discussion

Using [Closest Point] you can get rid of all the ones that have a distance greater than 0. YOu then need to order them along the referenced curve to get your Nodes.

See next reply for File

Error when uploading... try again

Attachments:

The components are already there just delete the [Join Text] and then rearrange as below

Panel[7] = D,

Panel[8] = UX,UY,UZ,ROTX,ROTY,ROTZ

Panel[7] --> (A) Concatenate[4]

Find Similar Member[2] (¡) --> (B) Concatenate[4]

Find Similar Member[2] (i): Graft = True

Concatenate[4] --> (A) Concatenate[5]

Panel[8] --> (B) Concatenate[5]

Concatenate[5] --> # this is you answer

You have to appreciate i did that solely from memory. What ever works

i was trying to export the points to CSV file regardless of the input data, but you are right; the script needs some tweaking to remove duplicates ... maybe the loop should check the existing points before adding a new point ID .. or something like that

i solved the duplicates issue .. and i also commented on functions so you can easily tweak the code yourself

import rhinoscriptsyntax as rs
import ghpythonlib.components as ghcomp

f = open("C:\ghExport.csv","wr") #file path change it if you want
f.write('SurfaceID,NodeID,x-value,y-value,z-value\n') #setting columns titles


#function to write a new row in CSV file
#the string is divided just to be easier to read
def writeNewRow(parentId,id,pt):
    s = str(parentId)+',' #SurfaceID column
    s = s + str(id)+',' #NodeID column
    s = s + str(pt[0])+',' #x-value column
    s = s + str(pt[1])+',' #y-value column
    s = s + str(pt[2])+'\n' #z-value column
    f.write(s)


#setting the point id list without dublicates
ptList = []
for srf in srfList:
    pts = rs.SurfacePoints(srf)
    for pt in pts: ptList.append( pt )
ptList = ghcomp.CullDuplicates(ptList).points

#setting the surface id list
if srfList:
    for i,srf in enumerate(srfList):
        points = rs.SurfacePoints(srf)
        for pt in points:
            for j in range(len(ptList)):
                if rs.PointCompare(pt,ptList[j]): # retrieving node ID
                    writeNewRow(i,j,pt)
                    break

f.close()

best of luck,

Attachments:

i understood the problem, i tried to create a 3-points surface in rhino and its editpoints were still 4. So i figured why not working with mesh instead ... and it worked .. but of course you have to change the command inside the script instead of using the rs.SurfacePoints(srf) we will be using rs.MeshVertices(srf)

Attachments:

when the surface is converted to mesh, it had more than one face; that's why it has more than 3 vertices. so i tried to reduce it in rhino using (_ReduceMesh) command and it works but i couldn't access the same command in python or grasshopper. so i couldn't solve it.

i recommend you to start a new discussion with this specific issue.

you have to manually create a new file in <C> partition and call it ghexport.csv before the first launch .. after that the code can modify the file ... or you can simply change the path of the file inside python .. both will work

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service