创建三维视图,遍历参数


start


[Transaction(TransactionMode.Automatic)]

[Regeneration(RegenerationOption.Automatic)]

public class CreateView : 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;


        XYZ direction = new XYZ(1, 1, 1);

        View3D view3D = doc.Create.NewView3D(direction);

        if (null == view3D)

        {

            throw new Exception("Failed to create new View3D");

        }

        string msg = "参数如下:";

        foreach (Parameter p in view3D.Parameters)

        {

            msg += "\n" + p.Definition.Name + " and value is " + p.AsValueString();

        }

        MessageBox.Show(msg);


        return Result.Succeeded;

    }

}

end