ToDSType(True)

Can anyone expain what does this if statement checking. What is the output we get when we apply .ToDSType(True) to a revit API element. Note : Both e and c are Revit API element

if (e.ToDSType(True)!=c.ToDSType(True)):
				edge.append({e.ToDSType(False),c.ToDSType(False)})	

@jobinsunny99 ,

do you have any example in a running project ?

the code snippet is from this function which is used for Dijikstra’s algorithm . Since both e and c are dynamo elements in this dynamo script ToDSType(True) is not used . I am trying to figure out what that if statement is doing. using != operator on two revit or dynamo elements.


01_ShortestPath.dyn (4.9 KB)
@Draxl_Andreas

ToDSType() wraps Revit API Elements into Dynamo Elements and sets the element binding. You need to input true if the element exists in Revit, or false if you have instantiated elements using the Revit API in either Python or C# and need to return them for use in a Dynamo graph.

The equality comparison from your code snippet is pointless. You’d be better off doing this:

if e.Id.IntegerValue != c.Id.IntegerValue:
    edge.append({e.ToDSType(True), c.ToDSType(True)})
3 Likes

I understood your point. but it is working perfectly in Dynamo. I am trying to implement the same in pyRevit
Digikstra Dynamo.dyn (54.5 KB)
here is the dynamo code.If we select 2 open end pipes ,it will give paths between them


@Thomas_Mahon

If you’re planning on using PyRevit then there’s no need to use Dynamo commands, i.e. ToDSType() as it wont do anything, and would again be pointless.

2 Likes

@Thomas_Mahon In pyrevit I modified the function as marked in the below image. But its not giving the desired output. so am trying to figure out the role of if function .