Description
Automatically number blocks (using VisualArq parameters). Experimental script, has to be tested and updated.
Author and license
Script by MLAV.LAND, licensed under the GNU GPL 3 License.
Code
import rhinoscriptsyntax as rs
import clr
clr.AddReference("VisualARQ.Script")
import VisualARQ.Script as va
def main():
rs.EnableRedraw(False)
# Get all block instances in the document
block_instances = rs.GetObjects("Pick some blocks", 4096, preselect=True)
if not block_instances:
print("No block instances selected.")
return
autoId = 1
# Iterate through each block instance
for block in block_instances:
# Get and set VisualARQ parameters
parameterIds = va.GetAllObjectParameterIds(block, True)
identifierParamId = None
for paramId in parameterIds:
paramName = va.GetParameterName(paramId)
if paramName == "_00Id":
identifierParamId = paramId
if identifierParamId:
# Format autoId to always have two digits
formatted_autoId = str(autoId).zfill(2)
va.SetParameterValue(identifierParamId, block, formatted_autoId)
print(formatted_autoId)
autoId += 1
if __name__ == "__main__":
main()
print("All objects IDs are numbered :)")