0

I am not able to read all the parameters of selected element using vb.net. I need to read all the parameter including type parameters. My code is as follow.

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
Colin Stark
  • 591
  • 3
  • 15
Imagine
  • 1
  • 1

1 Answers1

0

You can only use p.AsString() if the parameter is a String parameter. You can check this using Parameter.StorageType property.

This page should give you more info: http://help.autodesk.com/view/RVT/2014/ENU/?guid=GUID-D003803E-9FA0-4B2B-AB62-7DCC3A503644

To retrieve type parameters, you need to retrieve the element that represents the type:

Dim typeEle as Element = uiapp.ActiveUIDocument.Document.GetElement(ele.GetTypeId())

From there, retrieve the parameters from the type element in the same way that you retrived them from the element.

I recommend spending some time reading the help documentation before continuing any further.

One final note, you can retrieve an element directly from a Reference, so the line

Dim ele As Element = uiapp.ActiveUIDocument.Document.GetElement(picked.ElementId)

can be replaced with

Dim ele As Element = uiapp.ActiveUIDocument.Document.GetElement(picked)
Colin Stark
  • 591
  • 3
  • 15