我是 C# 和 Api 的初學者,所以我很難將有用的解決方案轉換為我的代碼。請大家幫忙了解一下怎么做到的?在目標需要找到最短路線。有一些元素通過連接器相互連接。有了這個,我可以找到所有可能的方法(下面可能實作的代碼),但不能用兩個鍵來做 self.weights 的字典。
Python代碼的由來
start = IN[0]
end = IN[1]
edges = IN[2]
graph = Graph()
for edge in edges:
graph.add_edge(edge[0],edge[1],1)
class Graph():
def __init__(self):
"""
self.edges is a dict of all possible next nodes
e.g. {'X': ['A', 'B', 'C', 'E'], ...}
self.weights has all the weights between two nodes,
with the two nodes as a tuple as the key
e.g. {('X', 'A'): 7, ('X', 'B'): 2, ...}
"""
self.edges = defaultdict(list)
self.weights = {}
def add_edge(self, from_node, to_node, weight):
# Note: assumes edges are bi-directional
self.edges[from_node].append(to_node)
self.edges[to_node].append(from_node)
self.weights[(from_node, to_node)] = weight
self.weights[(to_node, from_node)] = weight
我如何找到連接器并制作所有可能的下一個節點的字典
foreach (Connector con in cset)
{
if (con.IsConnected)
{
string key = con.Owner.Id.ToString();
if (conn_dic.ContainsKey(key))
{
List<Connector> conns = conn_dic[key];
conns.Add(con);
conn_dic[key] = conns;
}
else
{
conn_dic.Add(key, new List<Connector>() { con });
}
}
}
uj5u.com熱心網友回復:
Revit API 完全基于 .NET。所有 .NET 源代碼都轉換為中間語言 IL(維基百科)。您可以反編譯中間語言以重新創建原始源代碼。這使您能夠輕松有效地將源代碼從一種 .NET 語言轉換為另一種語言,例如從 Python 轉換為 C# 或 VB.NET。許多.NET 反編譯器都使用了這種可能性。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/534986.html
標籤:PythonC#应用程序接口数据转换revit-api
下一篇:使用來自屬性的反應動態獲取API
