0

I am not having any issues making calls from the form instance to the Revit class. It's when I try to assign a List to the Revit class's function categoryList(), that I get a variable doesn't exist in the context error. I tried prefixing a reference to the instance of the form class "Form UF = new Form;" This doesn't work.

    //The Revit Class

    public Result Execute(ExternalCommandData commandData, ref string message,....)
    {
        User_Form UF = new User_Form(commandData);
        UF.ShowDialog();


    public List<BuiltInCategory> categoryList(Document doc, int intSwitch)
    {
        //list built in categories for built in filter_1
        builtInCats_List = new List<BuiltInCategory>();

        switch (intSwitch)
        {
            case (1):
            ...
            case (3):
            ...             
            case (4):
                {
                    builtInCats_List = newStateCb1;
                    return builtInCats_List;
                }
            default:
                {
                    builtInCats_List = newStateCb1;
                    return builtInCats_List;
                }
        }
    }



   using Form = System.Windows.Forms.Form;
   using WS = ModelAuditor_2014.WorksetSorter_2014;
   using ModelAuditor_2014;
   using System.Threading;









   //The Form
   namespace ModelAuditor_2014
    {
   public partial class User_Form : Form
     {

        //Constructor
       WorksetSorter_2014 WS = new WorksetSorter_2014();

    //Revit references
        public Autodesk.Revit.UI.UIApplication rvtUiApp;
        public Autodesk.Revit.UI.UIDocument rvtUiDoc;
        public Autodesk.Revit.ApplicationServices.Application rvtApp;



    //Global Variables
    public List<BuiltInCategory> Filter01_CategoryList;
    public List<BuiltInCategory> Filter02_CategoryList;
    public int intSwitch;
    public List<BuiltInCategory> newStateCb1;




    public User_Form(ExternalCommandData commandData)
    {
        //Revit references
        rvtUiApp = commandData.Application;
        rvtUiDoc = rvtUiApp.ActiveUIDocument;
        rvtApp = rvtUiApp.Application;
        InitializeComponent();
    }


    public void User_Form_Load(object sender, EventArgs e)
    {
        //use rvtDoc = Doc
        Autodesk.Revit.DB.Document rvtDoc = .....                         

        //CheckedListBox for filter01
        checkedListBox1.DataSource = WS.categoryList(rvtDoc, intSwitch = 1);

        Filter01_CategoryList = new List<BuiltInCategory>();
        Filter01_CategoryList = WS.RetrieveSchema(rvtDoc, false);


        foreach (BuiltInCategory ChkedB1 in Filter01_CategoryList)
       {
           for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.Items[i].ToString() == ChkedB1.ToString())
                 {
                     checkedListBox1.SetItemChecked(i, true);
                 }
             }
          }



        public List<BuiltInCategory> returnNewStateCB1()
          {
        newStateCb1 = checkedListBox1.CheckedItems.Cast
        <BuiltInCategory>().ToList<BuiltInCategory>();

        return newStateCb1;
          }
Bimtopian
  • 37
  • 1
  • 5

1 Answers1

0

I passed the list from the win form to another public function in the revit app, I was able to access the list returned by this function.

Bimtopian
  • 37
  • 1
  • 5