我无法使用vb.net读取所选元素的所有参数。我需要读取所有参数,包括类型参数。 我的代码如下。
Dim picked As Reference = uiapp.ActiveUIDocument.Selection.PickObject(UI.Selection.ObjectType.Element)
Dim ele As Element = uiapp.ActiveUIDocument.Document.GetElement(picked.ElementId)
Dim idasstring As String = picked.ElementId.ToString()
For Each p As Parameter In ele.Parameters
count = count + 1
frmFriDB.lstParameter.Items.Add(" Parameter Name : " + p.Definition.Name.ToString() +
vbCrLf + " Value: " + vbCrLf + p.AsString() + p.AsValueString())
Next
答案 0 :(得分:0)
如果参数是String参数,则只能使用p.AsString()。您可以使用Parameter.StorageType属性来检查它。
此页面应为您提供更多信息:http://help.autodesk.com/view/RVT/2014/ENU/?guid=GUID-D003803E-9FA0-4B2B-AB62-7DCC3A503644
要检索类型参数,您需要检索表示类型的元素:
Dim typeEle as Element = uiapp.ActiveUIDocument.Document.GetElement(ele.GetTypeId())
从那里,以与从元素中重新获取它们相同的方式从type元素中检索参数。
我建议花一些时间阅读帮助文档,然后再继续。
最后一点,您可以直接从Reference中检索元素,所以行
Dim ele As Element = uiapp.ActiveUIDocument.Document.GetElement(picked.ElementId)
可以替换为
Dim ele As Element = uiapp.ActiveUIDocument.Document.GetElement(picked)