Get parameters listed in notepad to string in Dynamo

Hello,

I have the following problem. I have a notepad with a script for exporting parameters in revit. I need to get some of the parameters sorted into strings, so that i can make the Dynamo script collect data/parameters for Doors, Windows etc., but only the parameters that the notepad have listed. Does anyone know how to go from a notepad uploaded to a File Path, and end up with a string containing the correct parameters? :slight_smile:

The parameters that i need to sort is the ones listed as “AUFM…”


The immediate issue with your graph is that you’re not providing a valid input to the separator. You’ve closed your string and left yourself with an invalid line in the code block, but beyond that, I don’t think you’re providing the right input to begin with. You need to provide a character or string that would separate your input string into separate lines - something like a tab by the looks of your input file.

How can i provide it with a tab? :wink:

“/t”; should work. But I get / and \ confused on my phone keyboard so if that fails use the opposite.

I am all new to this, so how would you sort the parameters listed in the beginning “AUFM_ClassCode”, “AUFM_ClassName”, “AUFM_Type-ID” and “AUFM_Produkt-ID”? I need to get those sorted in a separate string-node

Pulling information out of a string file is kind of a “brute force” approach. There’s very little intelligence in this format that’s going to help you out. You need to look at your file’s formatting and figure out how you can programmatically get to the values you want.

My first approach would be something like this:

  1. Split by line break ("\n")
  2. Remove first 5 lines / lines with "#" (template info)
  3. Remove lines with "PropertySet"
  4. Split by tab ("\t")
  5. Get third item in sublist (third column in line)

Start with checking if it is structured data - open the file in excel and use the import wizard


Follow the prompts and import

Save as excel or as .tsv tab separated text file
Process using python is going to be one way to go

from pathlib import Path

file = Path(IN[0])

# get lines, remove new line characters, convert to list for processing
with file.open() as f:
    data = list(map(str.rstrip, f))

# Using dictionaries to be able to use data by key
properties = {}
pset = {}

while data:
    # Get each line from top
    # Removes each line so eventually list is empty (i.e. None)
    line = data.pop(0)
    
    # Skip comments and blank lines
    # These could also be filtered before processing
    if line.startswith("#") or line == "":
        continue
    
    if line.startswith("PropertySet:"):
        if pset:  # We have already been here
            # Add previous pset to properties
            properties.update({psetname: pset, "type": ptype})
        
        # Reset for next set of property lines 
        pset = {}
        psetname, _, ptype, = line.split("\t")[1:]
        continue
        
    if line.startswith("\t"):  # Property lines start with a tab
        prop, datatype, pname, = line.split("\t")[1:]
        pset.update({prop:{"dtype": datatype, "pname": pname}})

# Finally update with last pset
properties.update({psetname: pset, "type": ptype})

OUT = properties