My Python list will take IN[2] value, but not when I assign the string value directly in the code. Are string values not all equivalent?

My current script will receive a list of strings and when a string value is equal to IN[2] (or IN[3]) then the value will be replaced with "NULL". And yet if I define a variable with the desired value ( Weld1 = "307623") with the same value that I define in a code block. It does not work. And no error message either. I am completely stumped on this one. It was my understanding that if I define Weld1 = IN[1], which IN[1] is wired to a code block with the contents of "307623", then that would be the same as if I define

Weld1 = "307623"

Here is my code below. The IN[0] is a list of strings that all portray the Type Id value of items in revit.

import clr
import Autodesk
import Revit
import RevitServices
from Autodesk.Revit.DB import *
from Autodesk.DesignScript.Geometry import *
from RevitServices.Persistence import *
from RevitServices.Transactions import *
import DSCore as DS
from DSCore import *

#import sys	#clr.ImportExtensions(Revit.Elements)	#from Revit.Elements import *	#clr.ImportExtensions(Revit.GeometryConversion)	#from Revit.GeometryConversion import *	#clr.ImportExtensions(Revit.GeometryReferences)	#from Revit.GeometryReferences import *	#import System	#from System.Collections.Generic import *	#from System import *

####### Trying to remove the specified values from IN[0] list
######Step 1: Get all indices of values present in current list
#####Step 2: Remove Items at said Indices

lost=IN[0]					#List of parameter values to
#list = lost
#ShortList=IN[1]	#list of string values
str1=("307623")	#value to remove from list
#Weld1 = str1
str2=("308609")	#value to remove from list
#Weld2 = str2
				#strs = str1.Append(str2)
num1 = []
num2 = []
Output = 0
x = 0

#Weld1 = IN[2]
Weld2 = IN[3]
Weld1 = "Type Id : 307623";
#Weld2 = "308609"
rep = IN[1]
elementlist = list()
for item in lost:
	if item is Weld1:
		item = rep
	elif item is Weld2:
		item = rep

#str3i = str1i + str2i
#output = List.RemoveItemAtIndex(list, indices);
#NewID = [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z];
#if NewID==(0):
#	List.RemoveItem
#List.RemoveIfNot(NewID, (>=0));

OUT = elementlist

I apologize for all the comments in my code.


Apologies I’m trying to get my head round your issue… TBH I think that if you made a very simple python just to test this, you’d work it out… It would definitely help my tiny brain :smiley:



1 Like

@t.large can you post your dyn as well?

I’m not sure if I follow but have a look at the following;


@t.large also check this article on using the operator “is”


@Mark.Ackerley so essentially what have run into is such:
A Python script uses the Variable Weld1
When I define Weld1 = IN[2] then everything goes as planned. And IN[2] is wired to/from a code block with the contents of "307623";
But if I define 'Weld1 = “307623”` it does nothing at all.

@salvatoredragotta Selection Filter.dyn (22.8 KB)
Here is my DYN.
And after a quick read through of that link, I think my problem was just that. I was using is instead of ==

Looks like that was it! Thank you so much @salvatoredragotta ! That was a real headscratcher for me, one I’ll definitely remember!