Hi,
Trying to bulk convert notes from uppercase to sentence case and have had a go at a python script (I have 2 scripts, trying to figure out which one will work best). The script works when I get the item at a certain index but when I try to put the list into the python script it gives an error. Any ideas? Also if anyone thinks one script is better then the other let me know.
Script 1:
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
# The inputs to this node will be stored as a list in the IN variables.
import re
def convert_to_sentence_case(text):
sentences = re.split(r'(?<=[.!?])\s+', text)
formatted_sentences = [sentence.capitalize() for sentence in sentences]
return ' '.join(formatted_sentences)
# Example usage
input_text = IN[0]
result = convert_to_sentence_case(input_text)
OUT = result
Script 2:
# Python script to convert string to sentence case in Dynamo
# Input string
input_string = IN[0]
# Function to convert string to sentence case
def convert_to_sentence_case(input_string):
# Check if the string is not empty
if input_string:
# Convert the string to lowercase and then capitalize the first letter of each sentence
return '. '.join(map(str.capitalize, input_string.split('. ')))
else:
return "Please provide a non-empty string."
# Call the function and pass the input string
output = convert_to_sentence_case(input_string)
# Output the result
OUT = output