My statement may have been unclear ... I meant to suggest that you COULD use the same access method as you use for docUI and doc.
ie:
Code:
namespace Projects.QuickVisibility_4.CS
{
public partial class VisibilityForm : System.Windows.Forms.Form
{
UIDocument docUI;
Document doc;
Category catSections;
Category catGrids;
Category catRefplanes;
//Check category visibility in the view and populate the checkbox
public VisibilityForm(ExternalCommandData commandData)
{
docUI = commandData.Application.ActiveUIDocument;
doc = commandData.Application.ActiveUIDocument.Document;
RvtView curView = doc.ActiveView;
catSections = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Sections);
catGrids = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Grids);
catRefplanes = doc.Settings.Categories.get_Item(BuiltInCategory.OST_CLines);
InitializeComponent();
bool sectionVis = curView.getVisibility(catSections);
checkBox1.Checked = sectionVis == true ? true : false;
bool gridVis = curView.getVisibility(catGrids);
checkBox2.Checked = gridVis == true ? true : false;
bool refplaneVis = curView.getVisibility(catRefplanes);
checkBox3.Checked = refplaneVis == true ? true : false;
}
//Get checkbox value and set visibilty in the view
private void button1_Click(object sender, EventArgs e)
{
RvtView curView = doc.ActiveView;
Transaction trans = new Transaction(doc);
trans.Start("Hide or Unhide");
bool sTorF = checkBox1.Checked == true ? true : false;
curView.setVisibility(catSections, sTorF);
bool gTorF = checkBox2.Checked == true ? true : false;
curView.setVisibility(catGrids, gTorF);
bool rTorF = checkBox3.Checked == true ? true : false;
curView.setVisibility(catRefplanes, rTorF);
trans.Commit();
}
}
}
I don't play with Revit so not sure of some of it's pecularities regarding Categories and InitializeComponent();
also;
could this
Code:
bool sTorF = checkBox1.Checked == true ? true : false;
curView.setVisibility(catSections, sTorF);
become this ;
Code:
curView.setVisibility(catSections, checkBox1.Checked == true ? true : false);
Regards