import rhinoscriptsyntax as rs # Delete all existing objects to start fresh allobjs = rs.AllObjects() if allobjs: # Check if there are objects to delete rs.DeleteObjects(allobjs) # Define initial parameters for text, size, and height of extrusion initial = "N" size = 40 hgt = 60 # Create text and explode into curves mytext = rs.AddText(initial, (0, 0, 0), height=size) crv = rs.ExplodeText(mytext, True)[0] # Extract the first curve (e.g., the letter 'N') # Select the curve and extrude it to create a surface rs.SelectObject(crv) rs.Command("-_ExtrudeCrv Solid=No {} _Enter".format(hgt)) # Deselect the curve to ensure only the surface is selected for further operations rs.UnselectAllObjects() # Select the extruded surface (last created object) srf = rs.LastCreatedObjects(select=True)[0] # Select the last created surface (extrusion) print("Surface created: {srf}") # Debugging print # Now perform the rebuild operation on the surface only rs.Command("-_Rebuild UPointCount=10 VPointCount=4 UDegree=3 VDegree=3 DeleteInput=Yes _Enter") # --- Create contours in the Z direction --- # Increase the spacing between floors contour_spacing_z = 5.0 # Spacing between floors rs.Command("Contour _SelID {} 0,0,0 0,0,1 {} _Enter".format(srf, contour_spacing_z)) # Get the newly created contour curves contours_z = rs.LastCreatedObjects() print("Contours created in Z direction: {contours_z}") # Debugging print # Ensure contours are selected, then extrude them to create "floors" floors = [] # List to keep track of floor surfaces created if contours_z: for contour in contours_z: rs.SelectObject(contour) # Extrude each contour once to create a floor extrusion_result = rs.Command("-_ExtrudeCrv Solid=Yes 1.0 _Enter") # Use 1.0 thickness for visibility if extrusion_result: floors.append(contour) # Store the contour used for the floor print("Successfully extruded contour for floor: {contour}") # Debugging print else: print("Failed to extrude contour: {contour}") # Debugging print # Deselect all objects before generating new contours rs.UnselectAllObjects() # --- Create contours in the X direction --- rs.SelectObject(srf) # Increase the spacing between pipes contour_spacing_x = 4.0 # Spacing between pipes rs.Command("Contour _SelID {} 0,0,0 1,0,0 {} _Enter".format(srf, contour_spacing_x)) # Get the newly created contour curves in the X direction contours_x = rs.LastCreatedObjects() print("Contours created in X direction: {contours_x}") # Debugging print # Create pipes along the contours in the X direction if contours_x: for contour in contours_x: rs.SelectObject(contour) # Create pipes with a specified radius pipe_result = rs.Command("Pipe 0.2 _Enter") if pipe_result: print("Successfully created pipe for contour: {contour}") # Debugging print else: print("Failed to create pipe for contour: {contour}") # Debugging print initial = "I" size = 40 hgt = 60 # Create text and explode into curves mytext = rs.AddText(initial, (40,0,0), height=size) crv = rs.ExplodeText(mytext, True)[0] # Extract the first curve (e.g., the letter 'N') # Select the curve and extrude it to create a surface rs.SelectObject(crv) rs.Command("-_ExtrudeCrv Solid=No {} _Enter".format(hgt)) # Deselect the curve to ensure only the surface is selected for further operations rs.UnselectAllObjects() # Select the extruded surface (last created object) srf = rs.LastCreatedObjects(select=True)[0] # Select the last created surface (extrusion) print("Surface created: {srf}") # Debugging print # Now perform the rebuild operation on the surface only rs.Command("-_Rebuild UPointCount=10 VPointCount=4 UDegree=3 VDegree=3 DeleteInput=Yes _Enter") # --- Create contours in the Z direction --- # Increase the spacing between floors contour_spacing_z = 5.0 # Spacing between floors rs.Command("Contour _SelID {} 0,0,0 0,0,1 {} _Enter".format(srf, contour_spacing_z)) # Get the newly created contour curves contours_z = rs.LastCreatedObjects() print("Contours created in Z direction: {contours_z}") # Debugging print # Ensure contours are selected, then extrude them to create "floors" floors = [] # List to keep track of floor surfaces created if contours_z: for contour in contours_z: rs.SelectObject(contour) # Extrude each contour once to create a floor extrusion_result = rs.Command("-_ExtrudeCrv Solid=Yes 1.0 _Enter") # Use 1.0 thickness for visibility if extrusion_result: floors.append(contour) # Store the contour used for the floor print("Successfully extruded contour for floor: {contour}") # Debugging print else: print("Failed to extrude contour: {contour}") # Debugging print # Deselect all objects before generating new contours rs.UnselectAllObjects() # --- Create contours in the X direction --- rs.SelectObject(srf) # Increase the spacing between pipes contour_spacing_x = 4.0 # Spacing between pipes rs.Command("Contour _SelID {} 0,0,0 1,0,0 {} _Enter".format(srf, contour_spacing_x)) # Get the newly created contour curves in the X direction contours_x = rs.LastCreatedObjects() print("Contours created in X direction: {contours_x}") # Debugging print # Create pipes along the contours in the X direction if contours_x: for contour in contours_x: rs.SelectObject(contour) # Create pipes with a specified radius pipe_result = rs.Command("Pipe 0.2 _Enter") if pipe_result: print("Successfully created pipe for contour: {contour}") # Debugging print else: print("Failed to create pipe for contour: {contour}") # Debugging print # Clean up by deleting the original surface initial = "C" size = 40 hgt = 60 # Create text and explode into curves mytext = rs.AddText(initial, (60, 0, 0), height=size) crv = rs.ExplodeText(mytext, True)[0] # Extract the first curve (e.g., the letter 'N') # Select the curve and extrude it to create a surface rs.SelectObject(crv) rs.Command("-_ExtrudeCrv Solid=No {} _Enter".format(hgt)) # Deselect the curve to ensure only the surface is selected for further operations rs.UnselectAllObjects() # Select the extruded surface (last created object) srf = rs.LastCreatedObjects(select=True)[0] # Select the last created surface (extrusion) print("Surface created: {srf}") # Debugging print # Now perform the rebuild operation on the surface only rs.Command("-_Rebuild UPointCount=10 VPointCount=4 UDegree=3 VDegree=3 DeleteInput=Yes _Enter") # --- Create contours in the Z direction --- # Increase the spacing between floors contour_spacing_z = 5.0 # Spacing between floors rs.Command("Contour _SelID {} 0,0,0 0,0,1 {} _Enter".format(srf, contour_spacing_z)) # Get the newly created contour curves contours_z = rs.LastCreatedObjects() print("Contours created in Z direction: {contours_z}") # Debugging print # Ensure contours are selected, then extrude them to create "floors" floors = [] # List to keep track of floor surfaces created if contours_z: for contour in contours_z: rs.SelectObject(contour) # Extrude each contour once to create a floor extrusion_result = rs.Command("-_ExtrudeCrv Solid=Yes 1.0 _Enter") # Use 1.0 thickness for visibility if extrusion_result: floors.append(contour) # Store the contour used for the floor print("Successfully extruded contour for floor: {contour}") # Debugging print else: print("Failed to extrude contour: {contour}") # Debugging print # Deselect all objects before generating new contours rs.UnselectAllObjects() # --- Create contours in the X direction --- rs.SelectObject(srf) # Increase the spacing between pipes contour_spacing_x = 4.0 # Spacing between pipes rs.Command("Contour _SelID {} 0,0,0 1,0,0 {} _Enter".format(srf, contour_spacing_x)) # Get the newly created contour curves in the X direction contours_x = rs.LastCreatedObjects() print("Contours created in X direction: {contours_x}") # Debugging print # Create pipes along the contours in the X direction if contours_x: for contour in contours_x: rs.SelectObject(contour) # Create pipes with a specified radius pipe_result = rs.Command("Pipe 0.2 _Enter") if pipe_result: print("Successfully created pipe for contour: {contour}") # Debugging print else: print("Failed to create pipe for contour: {contour}") # Debugging print initial = "O" size = 40 hgt = 60 # Create text and explode into curves mytext = rs.AddText(initial, (110, 0, 0), height=size) crv = rs.ExplodeText(mytext, True)[0] # Extract the first curve (e.g., the letter 'N') # Select the curve and extrude it to create a surface rs.SelectObject(crv) rs.Command("-_ExtrudeCrv Solid=No {} _Enter".format(hgt)) # Deselect the curve to ensure only the surface is selected for further operations rs.UnselectAllObjects() # Select the extruded surface (last created object) srf = rs.LastCreatedObjects(select=True)[0] # Select the last created surface (extrusion) print("Surface created: {srf}") # Debugging print # Now perform the rebuild operation on the surface only rs.Command("-_Rebuild UPointCount=10 VPointCount=4 UDegree=3 VDegree=3 DeleteInput=Yes _Enter") # --- Create contours in the Z direction --- # Increase the spacing between floors contour_spacing_z = 5.0 # Spacing between floors rs.Command("Contour _SelID {} 0,0,0 0,0,1 {} _Enter".format(srf, contour_spacing_z)) # Get the newly created contour curves contours_z = rs.LastCreatedObjects() print("Contours created in Z direction: {contours_z}") # Debugging print # Ensure contours are selected, then extrude them to create "floors" floors = [] # List to keep track of floor surfaces created if contours_z: for contour in contours_z: rs.SelectObject(contour) # Extrude each contour once to create a floor extrusion_result = rs.Command("-_ExtrudeCrv Solid=Yes 1.0 _Enter") # Use 1.0 thickness for visibility if extrusion_result: floors.append(contour) # Store the contour used for the floor print("Successfully extruded contour for floor: {contour}") # Debugging print else: print("Failed to extrude contour: {contour}") # Debugging print # Deselect all objects before generating new contours rs.UnselectAllObjects() # --- Create contours in the X direction --- rs.SelectObject(srf) # Increase the spacing between pipes contour_spacing_x = 4.0 # Spacing between pipes rs.Command("Contour _SelID {} 0,0,0 1,0,0 {} _Enter".format(srf, contour_spacing_x)) # Get the newly created contour curves in the X direction contours_x = rs.LastCreatedObjects() print("Contours created in X direction: {contours_x}") # Debugging print # Create pipes along the contours in the X direction if contours_x: for contour in contours_x: rs.SelectObject(contour) # Create pipes with a specified radius pipe_result = rs.Command("Pipe 0.2 _Enter") if pipe_result: print("Successfully created pipe for contour: {contour}") # Debugging print else: print("Failed to create pipe for contour: {contour}") # Debugging print rs.DeleteObject(srf)