NameError: name 'string' is not defined

Hi all,

i had been getting this bug recently and i couldnt find any way to solve it. i googled this error online and it shows that it is an ironpython bug(?) apparently. Is there any other workaround for this error?
attached picture is the ss of the error:


and the code below code from the script:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import python library
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import os

# Import math library
from math import *

#Import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

# Import Element nodes in Dynamo
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import DSCore nodes in Dynamo
clr.AddReference('DSCoreNodes')
from DSCore import *

#Import System Library
clr.AddReference('System.Core')
from System.Collections.Generic import List

#Preparing input from dynamo to revit
ParaValues = IN[0]
ParaTypes = IN[1]

sublist, Pt, Pv, list= [], [], [], []

for Paratype,Paravalue in zip(ParaTypes,ParaValues):
	for Pt,Pv in zip(Paratype,Paravalue):
		if Pt == __builtins__.get("Number") and Pv == __builtins__.get("Type Here"):
			Pv = 0000
		elif Pt == "Number" and (isinstance(Pv,string) == True):
			Pv = 0000		
		elif Pt == "Number" and Pv == "Type Here":
			Pv = True
		elif Pt == "Number" and Pv == "Yes":
			Pv = True
		elif Pt == "Number" and Pv == "No":
			Pv = False
		elif Pt == "Number" and (Pv != True or Pv != False):
			Pv = True			
		elif Pt == "Number" and isinstance(Pv,string) == False:
			Pv = "Type Here"	
		sublist.append(Pv)		
OUT = sublist

@stillgotme try changing string to str

image

1 Like

Wow it actually is working again… i swear it was working well a few weeks back with the exact same code… thanks again @salvatoredragotta

1 Like