added Revit 2020 SDK files

This commit is contained in:
Jeremy Tammik
2019-09-11 14:43:53 +02:00
parent fbb29172ed
commit 8b8832b7be
2956 changed files with 938523 additions and 0 deletions
+105
View File
@@ -0,0 +1,105 @@
//
// (C) Copyright 2003-2019 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.VisibilityControl.CS
{
/// <summary>
/// Implements the Revit add-in interface IExternalCommand
/// </summary>
[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 Command : IExternalCommand
{
/// <summary>
/// Implement this method as an external command for Revit.
/// </summary>
/// <param name="commandData">An object that is passed to the external application
/// which contains data related to the command,
/// such as the application object and active view.</param>
/// <param name="message">A message that can be set by the external application
/// which will be displayed if a failure or cancellation is returned by
/// the external command.</param>
/// <param name="elements">A set of elements to which the external application
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
/// <returns>Return the status of the external command.
/// A result of Succeeded means that the API external method functioned as expected.
/// Cancelled can be used to signify that the user cancelled the external operation
/// at some point. Failure should be returned if the application is unable to proceed with
/// the operation.</returns>
public virtual Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData
, ref string message, Autodesk.Revit.DB.ElementSet elements)
{
Transaction trans = new Transaction(commandData.Application.ActiveUIDocument.Document, "Revit.SDK.Samples.VisibilityControl");
trans.Start();
try
{
if (null == commandData)
{
trans.RollBack();
throw new ArgumentNullException("commandData");
}
// create an instance of VisibilityCtrl
VisibilityCtrl visiController = new VisibilityCtrl(commandData.Application.ActiveUIDocument);
// create a user interface form
using (VisibilityCtrlForm dlg = new VisibilityCtrlForm(visiController))
{
// show dialog
System.Windows.Forms.DialogResult result = dlg.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
trans.Commit();
return Autodesk.Revit.UI.Result.Succeeded;
}
else if (result == System.Windows.Forms.DialogResult.Yes)
{
// isolate the selected element(s)
visiController.Isolate();
trans.Commit();
return Autodesk.Revit.UI.Result.Succeeded;
}
}
trans.RollBack();
return Autodesk.Revit.UI.Result.Cancelled;
}
catch (Exception ex)
{
message = ex.Message;
trans.RollBack();
return Autodesk.Revit.UI.Result.Failed;
}
}
}
}
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("VisibilityControl")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VisibilityControl")]
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6d7aa0dc-c660-4497-b87b-f3d48501c21e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Command">
<Assembly>VisibilityControl.dll</Assembly>
<ClientId>0cf4340c-e0d4-4e23-805b-12446414fa0d</ClientId>
<FullClassName>Revit.SDK.Samples.VisibilityControl.CS.Command</FullClassName>
<Text>Visibility Controller</Text>
<Description>Control element visibility by category.</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
</RevitAddIns>
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6F7D3FF8-39DF-4053-B5BA-71804A673F30}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VisibilityControl</RootNamespace>
<AssemblyName>VisibilityControl</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Command.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VisibilityCtrl.cs" />
<Compile Include="VisibilityCtrlForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="VisibilityCtrlForm.Designer.cs">
<DependentUpon>VisibilityCtrlForm.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="VisibilityCtrlForm.resx">
<SubType>Designer</SubType>
<DependentUpon>VisibilityCtrlForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
</Project>
@@ -0,0 +1,171 @@
//
// (C) Copyright 2003-2019 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections;
using Autodesk.Revit.DB;
namespace Revit.SDK.Samples.VisibilityControl.CS
{
/// <summary>
/// An enumerate type listing the types of element select mode.
/// </summary>
public enum IsolateMode
{
None,
PickOne,
WindowSelect
}
/// <summary>
/// An object control visibility by category
/// </summary>
public class VisibilityCtrl
{
private Autodesk.Revit.UI.UIDocument m_document; // the active document
private Hashtable m_allCategories; // all categories name with its visibility
private Hashtable m_categoriesWithName; // all categories with its name
private IsolateMode m_isolateMode; // the mode to select element(s)
/// <summary>
/// get all categories name with its visibility
/// </summary>
public Hashtable AllCategories
{
get
{
return m_allCategories;
}
}
/// <summary>
/// get and set the mode to select element(s)
/// </summary>
public IsolateMode IsolateMode
{
get
{
return m_isolateMode;
}
set
{
m_isolateMode = value;
}
}
/// <summary>
/// Default constructor
/// </summary>
/// <remarks>get all categories of this document. check its visibility for
/// the active document, and initialize a hashtable.</remarks>
public VisibilityCtrl(Autodesk.Revit.UI.UIDocument document)
{
if (null == document)
{
throw new ArgumentNullException("document");
}
else
{
m_document = document;
}
// initialize the two table
m_allCategories = new Hashtable();
m_categoriesWithName = new Hashtable();
// fill out the two table
foreach (Category category in m_document.Document.Settings.Categories)
{
if(category.get_AllowsVisibilityControl(m_document.Document.ActiveView))
{
m_allCategories.Add(category.Name, category.get_Visible(m_document.Document.ActiveView));
m_categoriesWithName.Add(category.Name, category);
}
}
}
/// <summary>
/// Set the visibility for the active view
/// </summary>
/// <returns>Return true if operation successed, or else, return false.</returns>
public bool SetVisibility(bool visible, string name)
{
try
{
Category cat = m_categoriesWithName[name] as Category;
m_document.Document.ActiveView.SetCategoryHidden(cat.Id, !visible);
//or cat.set_Visible(m_document.ActiveView, visible);
m_allCategories[cat.Name] = visible;
}
catch (Exception)
{
return false;
}
return true;
}
/// <summary>
/// Isolate elements with the same categories that the selected elements belong to
/// using PickOne or WindowSelect.
/// </summary>
public void Isolate()
{
//m_document.Selection.Elements.Clear();
System.Collections.Generic.ICollection<Reference> elements = null;
switch (m_isolateMode)
{
case IsolateMode.PickOne:
// One more element will be added to modscope
// if user really selects an element which differs from the elements in
// modscope before user's pick one operation.
elements.Add(m_document.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element));
break;
case IsolateMode.WindowSelect:
// Elements will be added to modscope if possilbe.
elements = m_document.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element);
break;
default:
break;
}
// ElementSet elements = m_document.Selection.Elements;
// hide all categories elements
foreach (Category cat in m_document.Document.Settings.Categories)
{
SetVisibility(false, cat.Name);
}
// set the visibility for the selection elements
foreach (Reference reference in elements)
{
Category cat = m_document.Document.GetElement(reference).Category;
if (null != cat && !string.IsNullOrEmpty(cat.Name))
{
SetVisibility(true, cat.Name);
}
}
}
}
}
@@ -0,0 +1,216 @@
//
// (C) Copyright 2003-2019 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
namespace Revit.SDK.Samples.VisibilityControl.CS
{
partial class VisibilityCtrlForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.visibilityCtrlGroupBox = new System.Windows.Forms.GroupBox();
this.allCategoriesListView = new System.Windows.Forms.ListView();
this.cancelButton = new System.Windows.Forms.Button();
this.okBotton = new System.Windows.Forms.Button();
this.pickOneRadioButton = new System.Windows.Forms.RadioButton();
this.isolategroupBox = new System.Windows.Forms.GroupBox();
this.windowSelectRadioButton = new System.Windows.Forms.RadioButton();
this.isolateButton = new System.Windows.Forms.Button();
this.checkAllButton = new System.Windows.Forms.Button();
this.checkNoneButton = new System.Windows.Forms.Button();
this.visibilityCtrlGroupBox.SuspendLayout();
this.isolategroupBox.SuspendLayout();
this.SuspendLayout();
//
// visibilityCtrlGroupBox
//
this.visibilityCtrlGroupBox.Controls.Add(this.checkNoneButton);
this.visibilityCtrlGroupBox.Controls.Add(this.checkAllButton);
this.visibilityCtrlGroupBox.Controls.Add(this.allCategoriesListView);
this.visibilityCtrlGroupBox.Controls.Add(this.cancelButton);
this.visibilityCtrlGroupBox.Controls.Add(this.okBotton);
this.visibilityCtrlGroupBox.Location = new System.Drawing.Point(12, 12);
this.visibilityCtrlGroupBox.Name = "visibilityCtrlGroupBox";
this.visibilityCtrlGroupBox.Size = new System.Drawing.Size(620, 339);
this.visibilityCtrlGroupBox.TabIndex = 3;
this.visibilityCtrlGroupBox.TabStop = false;
this.visibilityCtrlGroupBox.Text = "Category visibility";
//
// allCategoriesListView
//
this.allCategoriesListView.CheckBoxes = true;
this.allCategoriesListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.allCategoriesListView.Location = new System.Drawing.Point(6, 19);
this.allCategoriesListView.Name = "allCategoriesListView";
this.allCategoriesListView.Size = new System.Drawing.Size(527, 314);
this.allCategoriesListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.allCategoriesListView.TabIndex = 5;
this.allCategoriesListView.UseCompatibleStateImageBehavior = false;
this.allCategoriesListView.View = System.Windows.Forms.View.Details;
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(539, 310);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 4;
this.cancelButton.Text = "&Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
//
// okBotton
//
this.okBotton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okBotton.Location = new System.Drawing.Point(539, 281);
this.okBotton.Name = "okBotton";
this.okBotton.Size = new System.Drawing.Size(75, 23);
this.okBotton.TabIndex = 1;
this.okBotton.Text = "&OK";
this.okBotton.UseVisualStyleBackColor = true;
//
// pickOneRadioButton
//
this.pickOneRadioButton.AutoSize = true;
this.pickOneRadioButton.Checked = true;
this.pickOneRadioButton.Location = new System.Drawing.Point(6, 19);
this.pickOneRadioButton.Name = "pickOneRadioButton";
this.pickOneRadioButton.Size = new System.Drawing.Size(66, 17);
this.pickOneRadioButton.TabIndex = 2;
this.pickOneRadioButton.TabStop = true;
this.pickOneRadioButton.Text = "PickOne";
this.pickOneRadioButton.UseVisualStyleBackColor = true;
//
// isolategroupBox
//
this.isolategroupBox.Controls.Add(this.windowSelectRadioButton);
this.isolategroupBox.Controls.Add(this.pickOneRadioButton);
this.isolategroupBox.Controls.Add(this.isolateButton);
this.isolategroupBox.Location = new System.Drawing.Point(364, 357);
this.isolategroupBox.Name = "isolategroupBox";
this.isolategroupBox.Size = new System.Drawing.Size(268, 49);
this.isolategroupBox.TabIndex = 2;
this.isolategroupBox.TabStop = false;
this.isolategroupBox.Text = "Isolate element(s)";
//
// windowSelectRadioButton
//
this.windowSelectRadioButton.AutoSize = true;
this.windowSelectRadioButton.Location = new System.Drawing.Point(78, 19);
this.windowSelectRadioButton.Name = "windowSelectRadioButton";
this.windowSelectRadioButton.Size = new System.Drawing.Size(94, 17);
this.windowSelectRadioButton.TabIndex = 2;
this.windowSelectRadioButton.TabStop = true;
this.windowSelectRadioButton.Text = "WindowSelect";
this.windowSelectRadioButton.UseVisualStyleBackColor = true;
//
// isolateButton
//
this.isolateButton.DialogResult = System.Windows.Forms.DialogResult.Yes;
this.isolateButton.Location = new System.Drawing.Point(187, 16);
this.isolateButton.Name = "isolateButton";
this.isolateButton.Size = new System.Drawing.Size(75, 23);
this.isolateButton.TabIndex = 3;
this.isolateButton.Text = "&Isolate";
this.isolateButton.UseVisualStyleBackColor = true;
this.isolateButton.Click += new System.EventHandler(this.isolateButton_Click);
//
// checkAllButton
//
this.checkAllButton.Location = new System.Drawing.Point(539, 223);
this.checkAllButton.Name = "checkAllButton";
this.checkAllButton.Size = new System.Drawing.Size(75, 23);
this.checkAllButton.TabIndex = 6;
this.checkAllButton.Text = "Check All";
this.checkAllButton.UseVisualStyleBackColor = true;
this.checkAllButton.Click += new System.EventHandler(this.checkAllButton_Click);
//
// checkNoneButton
//
this.checkNoneButton.Location = new System.Drawing.Point(539, 252);
this.checkNoneButton.Name = "checkNoneButton";
this.checkNoneButton.Size = new System.Drawing.Size(75, 23);
this.checkNoneButton.TabIndex = 6;
this.checkNoneButton.Text = "Check None";
this.checkNoneButton.UseVisualStyleBackColor = true;
this.checkNoneButton.Click += new System.EventHandler(this.checkNoneButton_Click);
//
// VisibilityCtrlForm
//
this.AcceptButton = this.okBotton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(644, 418);
this.Controls.Add(this.visibilityCtrlGroupBox);
this.Controls.Add(this.isolategroupBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "VisibilityCtrlForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Visibility Controller";
this.Load += new System.EventHandler(this.VisibilityCtrlForm_Load);
this.visibilityCtrlGroupBox.ResumeLayout(false);
this.isolategroupBox.ResumeLayout(false);
this.isolategroupBox.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox visibilityCtrlGroupBox;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Button okBotton;
private System.Windows.Forms.RadioButton pickOneRadioButton;
private System.Windows.Forms.GroupBox isolategroupBox;
private System.Windows.Forms.RadioButton windowSelectRadioButton;
private System.Windows.Forms.Button isolateButton;
private System.Windows.Forms.ListView allCategoriesListView;
private System.Windows.Forms.Button checkNoneButton;
private System.Windows.Forms.Button checkAllButton;
}
}
@@ -0,0 +1,143 @@
//
// (C) Copyright 2003-2019 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Autodesk.Revit;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.VisibilityControl.CS
{
/// <summary>
/// the user interface form
/// </summary>
public partial class VisibilityCtrlForm : System.Windows.Forms.Form
{
// an object control visibility by category
private VisibilityCtrl m_visibilityCtrl;
/// <summary>
/// constructor
/// </summary>
/// <param name="visibilityCtrl">an object control visibility by category</param>
public VisibilityCtrlForm(VisibilityCtrl visibilityCtrl)
{
if (null == visibilityCtrl)
{
throw new ArgumentNullException("visibilityCtrl");
}
else
{
m_visibilityCtrl = visibilityCtrl;
}
InitializeComponent();
}
/// <summary>
/// initializes allCategoriesListView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void VisibilityCtrlForm_Load(object sender, EventArgs e)
{
// initialize the checked list box
allCategoriesListView.Columns.Add("name");
foreach (string name in m_visibilityCtrl.AllCategories.Keys)
{
bool check = m_visibilityCtrl.AllCategories[name].ToString().Equals("True") ? true : false;
ListViewItem item = new ListViewItem(name);
item.Checked = check;
allCategoriesListView.Items.Add(item);
}
allCategoriesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
// append the ItemCheck event handler method
allCategoriesListView.ItemCheck += new ItemCheckEventHandler(allCategoriesListView_ItemCheck);
}
/// <summary>
/// change the visibility of the category
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void allCategoriesListView_ItemCheck(object sender, ItemCheckEventArgs e)
{
bool visible = e.NewValue == CheckState.Checked ? true : false;
string name = allCategoriesListView.Items[e.Index].Text;
// change the visibility of the category
if (!m_visibilityCtrl.SetVisibility(visible, name))
{
TaskDialog.Show("Revit", "This category can not change visible in the active view.");
}
}
/// <summary>
/// isolate the selected elements
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void isolateButton_Click(object sender, EventArgs e)
{
// set the IsolateMode
if (pickOneRadioButton.Checked)
{
m_visibilityCtrl.IsolateMode = IsolateMode.PickOne;
}
else if (windowSelectRadioButton.Checked)
{
m_visibilityCtrl.IsolateMode = IsolateMode.WindowSelect;
}
else
{
m_visibilityCtrl.IsolateMode = IsolateMode.None;
}
// close the form
this.Close();
}
private void checkAllButton_Click(object sender, EventArgs e)
{
foreach (ListViewItem item in allCategoriesListView.Items)
{
item.Checked = true;
}
}
private void checkNoneButton_Click(object sender, EventArgs e)
{
foreach (ListViewItem item in allCategoriesListView.Items)
{
item.Checked = false;
}
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>