Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, all
I want to get the value of type parameters of an element, and i write the codes as below:
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] [Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)] [Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)] public class cmdParameter : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements) { UIApplication uiApp = commandData.Application; Document doc = uiApp.ActiveUIDocument.Document; Selection sel = uiApp.ActiveUIDocument.Selection; Transaction ts = new Transaction(doc, "http://test.com"); ts.Start(); //选中的元素,这里选中一个管道Pipe Element elemPick = null; Reference refelem = sel.PickObject(ObjectType.Element, "请选择一个风管"); elemPick = doc.GetElement(refelem.ElementId); //遍历元素的普通参数 string strParameter = "基本属性"; foreach (Parameter p in elemPick.Parameters) { strParameter += p.Definition.ParameterGroup + "," + p.Definition.Name + "," + p.AsValueString() + "\n"; } strParameter += "类型属性:\n"; //遍历元素的类型属性 ElementType elemType = doc.GetElement(elemPick.GetTypeId()) as ElementType; foreach (Parameter p in elemType.Parameters) { //doc.GetElement(p.AsElementId()); strParameter += p.Definition.ParameterGroup + "," + p.Definition.Name + "," + p.AsValueString() + "\n"; } TaskDialog.Show("parameter", strParameter); ts.Commit(); return Result.Succeeded; } }
i can get the parameters of elemType, but can not get the value of them, is there any problem in my code?
Thanks a lot!
Solved! Go to Solution.