Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

How to organize this code? Memory handling vs readability

$
0
0

Hi there,

What is the best way to organize code?

  1. Organize by topic categories to be readable and follow logic:

    Add user texts: includes a loop for usertext asignment
    Add objects to group: includes another loop

# Add user texts:
rs.SetUserText(obj, "wallSurface", "Base", attach_to_geometry=False)
rs.SetUserText(obj, "SurfaceType", "Planar", attach_to_geometry=False)
for i in loft:
    rs.SetUserText(i, "wallSurface", "Edge_surface", attach_to_geometry=False)
# Add objects to group
group = rs.AddGroup()
rs.AddObjectsToGroup([obj,surfaceOffset[0]], group)
loft = rs.ExplodePolysurfaces (loft, True)
for i in loft:
    rs.AddObjectToGroup(i,group)
  1. Organize that efficient in terms of memory handling.

    Add user texts:
    Add objects to group: contains one loop (with user text asignment)

# Add user texts:
rs.SetUserText(obj, "wallSurface", "Base", attach_to_geometry=False)
rs.SetUserText(obj, "SurfaceType", "Planar", attach_to_geometry=False)
# Add objects to group
group = rs.AddGroup()
rs.AddObjectsToGroup([obj,surfaceOffset[0]], group)
loft = rs.ExplodePolysurfaces (loft, True)
for i in loft:
    rs.AddObjectToGroup(i,group)
    rs.SetUserText(i, "wallSurface", "Edge_surface", attach_to_geometry=False)

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles