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
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Command">
<Assembly>AllViews.dll</Assembly>
<ClientId>a3ede8e2-477f-4ea6-b0b5-3ffd41963c9b</ClientId>
<FullClassName>Revit.SDK.Samples.AllViews.CS.Command</FullClassName>
<Text>All Views</Text>
<Description>Generate a new sheet for user selected views</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
</RevitAddIns>
+445
View File
@@ -0,0 +1,445 @@
//
// (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.Text;
using System.Windows.Forms;
using System.Collections;
using System.Xml;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.AllViews.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
{
#region IExternalCommand Members Implementation
/// <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 Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
ref string message, Autodesk.Revit.DB.ElementSet elements)
{
Transaction newTran = null;
try
{
if (null == commandData)
{
throw new ArgumentNullException("commandData");
}
Document doc = commandData.Application.ActiveUIDocument.Document;
ViewsMgr view = new ViewsMgr(doc);
newTran = new Transaction(doc);
newTran.Start("AllViews_Sample");
AllViewsForm dlg = new AllViewsForm(view);
if (dlg.ShowDialog() == DialogResult.OK)
{
view.GenerateSheet(doc);
}
newTran.Commit();
return Autodesk.Revit.UI.Result.Succeeded;
}
catch (Exception e)
{
message = e.Message;
if ((newTran != null) && newTran.HasStarted() && !newTran.HasEnded())
newTran.RollBack();
return Autodesk.Revit.UI.Result.Failed;
}
}
#endregion IExternalCommand Members Implementation
}
/// <summary>
/// Generating a new sheet that has all the selected views placed in.
/// </summary>
public class ViewsMgr
{
private TreeNode m_allViewsNames = new TreeNode("Views (all)");
private ViewSet m_allViews = new ViewSet();
private ViewSet m_selectedViews = new ViewSet();
private FamilySymbol m_titleBlock;
private IList<Element> m_allTitleBlocks = new List<Element>();
private ArrayList m_allTitleBlocksNames = new ArrayList();
private string m_sheetName;
private double m_rows;
private double TITLEBAR = 0.2;
private double GOLDENSECTION = 0.618;
/// <summary>
/// Tree node store all views' names.
/// </summary>
public TreeNode AllViewsNames
{
get
{
return m_allViewsNames;
}
}
/// <summary>
/// List of all title blocks' names.
/// </summary>
public ArrayList AllTitleBlocksNames
{
get
{
return m_allTitleBlocksNames;
}
}
/// <summary>
/// The selected sheet's name.
/// </summary>
public string SheetName
{
get
{
return m_sheetName;
}
set
{
m_sheetName = value;
}
}
/// <summary>
/// Constructor of views object.
/// </summary>
/// <param name="doc">the active document</param>
public ViewsMgr(Document doc)
{
GetAllViews(doc);
GetTitleBlocks(doc);
}
/// <summary>
/// Finds all the views in the active document.
/// </summary>
/// <param name="doc">the active document</param>
private void GetAllViews(Document doc)
{
FilteredElementCollector collector = new FilteredElementCollector(doc);
FilteredElementIterator itor = collector.OfClass(typeof(Autodesk.Revit.DB.View)).GetElementIterator();
itor.Reset();
while (itor.MoveNext())
{
Autodesk.Revit.DB.View view = itor.Current as Autodesk.Revit.DB.View;
// skip view templates because they're invisible in project browser
if (null == view || view.IsTemplate)
{
continue;
}
else
{
ElementType objType = doc.GetElement(view.GetTypeId()) as ElementType;
if (null == objType || objType.Name.Equals("Schedule")
|| objType.Name.Equals("Drawing Sheet"))
{
continue;
}
else
{
m_allViews.Insert(view);
AssortViews(view.Name, objType.Name);
}
}
}
}
/// <summary>
/// Assort all views for tree view displaying.
/// </summary>
/// <param name="view">The view assorting</param>
/// <param name="type">The type of view</param>
private void AssortViews(string view, string type)
{
foreach (TreeNode t in AllViewsNames.Nodes)
{
if (t.Tag.Equals(type))
{
t.Nodes.Add(new TreeNode(view));
return;
}
}
TreeNode categoryNode = new TreeNode(type);
categoryNode.Tag = type;
if (type.Equals("Building Elevation"))
{
categoryNode.Text = "Elevations [" + type + "]";
}
else
{
categoryNode.Text = type + "s";
}
categoryNode.Nodes.Add(new TreeNode(view));
AllViewsNames.Nodes.Add(categoryNode);
}
/// <summary>
/// Retrieve the checked view from tree view.
/// </summary>
public void SelectViews()
{
ArrayList names = new ArrayList();
foreach (TreeNode t in AllViewsNames.Nodes)
{
foreach (TreeNode n in t.Nodes)
{
if (n.Checked && 0 == n.Nodes.Count)
{
names.Add(n.Text);
}
}
}
foreach (Autodesk.Revit.DB.View v in m_allViews)
{
foreach (string s in names)
{
if (s.Equals(v.Name))
{
m_selectedViews.Insert(v);
break;
}
}
}
}
/// <summary>
/// Generate sheet in active document.
/// </summary>
/// <param name="doc">the currently active document</param>
public void GenerateSheet(Document doc)
{
if (null == doc)
{
throw new ArgumentNullException("doc");
}
if (0 == m_selectedViews.Size)
{
throw new InvalidOperationException("No view be selected, generate sheet be canceled.");
}
ViewSheet sheet = ViewSheet.Create(doc, m_titleBlock.Id);
sheet.Name = SheetName;
PlaceViews(m_selectedViews, sheet);
}
/// <summary>
/// Retrieve the title block to be generate by its name.
/// </summary>
/// <param name="name">The title block's name</param>
public void ChooseTitleBlock(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name");
}
foreach (FamilySymbol f in m_allTitleBlocks)
{
if (name.Equals(f.Family.Name + ":" + f.Name))
{
m_titleBlock = f;
return;
}
}
}
/// <summary>
/// Retrieve all available title blocks in the currently active document.
/// </summary>
/// <param name="doc">the currently active document</param>
private void GetTitleBlocks(Document doc)
{
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(doc);
filteredElementCollector.OfClass(typeof(FamilySymbol));
filteredElementCollector.OfCategory(BuiltInCategory.OST_TitleBlocks);
m_allTitleBlocks = filteredElementCollector.ToElements();
if (0 == m_allTitleBlocks.Count)
{
throw new InvalidOperationException("There is no title block to generate sheet.");
}
foreach (Element element in m_allTitleBlocks)
{
FamilySymbol f = element as FamilySymbol;
AllTitleBlocksNames.Add(f.Family.Name + ":" + f.Name);
if (null == m_titleBlock)
{
m_titleBlock = f;
}
}
}
/// <summary>
/// Place all selected views on this sheet's appropriate location.
/// </summary>
/// <param name="views">all selected views</param>
/// <param name="sheet">all views located sheet</param>
private void PlaceViews(ViewSet views, ViewSheet sheet)
{
double xDistance = 0;
double yDistance = 0;
CalculateDistance(sheet.Outline, views.Size, ref xDistance, ref yDistance);
Autodesk.Revit.DB.UV origin = GetOffSet(sheet.Outline, xDistance, yDistance);
//Autodesk.Revit.DB.UV temp = new Autodesk.Revit.DB.UV (origin.U, origin.V);
double tempU = origin.U;
double tempV = origin.V;
int n = 1;
foreach (Autodesk.Revit.DB.View v in views)
{
Autodesk.Revit.DB.UV location = new Autodesk.Revit.DB.UV(tempU, tempV);
Autodesk.Revit.DB.View view = v;
Rescale(view, xDistance, yDistance);
try
{
//sheet.AddView(view, location);
Viewport.Create(view.Document, sheet.Id, view.Id, new XYZ(location.U, location.V, 0));
}
catch (ArgumentException /*ae*/)
{
throw new InvalidOperationException("The view '" + view.Name +
"' can't be added, it may have already been placed in another sheet.");
}
if (0 != n++ % m_rows)
{
tempU = tempU + xDistance * (1 - TITLEBAR);
}
else
{
tempU = origin.U;
tempV = tempV + yDistance;
}
}
}
/// <summary>
/// Retrieve the appropriate origin.
/// </summary>
/// <param name="bBox"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
private Autodesk.Revit.DB.UV GetOffSet(BoundingBoxUV bBox, double x, double y)
{
return new Autodesk.Revit.DB.UV(bBox.Min.U + x * GOLDENSECTION, bBox.Min.V + y * GOLDENSECTION);
}
/// <summary>
/// Calculate the appropriate distance between the views lay on the sheet.
/// </summary>
/// <param name="bBox">The outline of sheet.</param>
/// <param name="amount">Amount of views.</param>
/// <param name="x">Distance in x axis between each view</param>
/// <param name="y">Distance in y axis between each view</param>
private void CalculateDistance(BoundingBoxUV bBox, int amount, ref double x, ref double y)
{
double xLength = (bBox.Max.U - bBox.Min.U) * (1 - TITLEBAR);
double yLength = (bBox.Max.V - bBox.Min.V);
//calculate appropriate rows numbers.
double result = Math.Sqrt(amount);
while (0 < (result - (int)result))
{
amount = amount + 1;
result = Math.Sqrt(amount);
}
m_rows = result;
double area = xLength * yLength / amount;
//calculate appropriate distance between the views.
if (bBox.Max.U > bBox.Max.V)
{
x = Math.Sqrt(area / GOLDENSECTION);
y = GOLDENSECTION * x;
}
else
{
y = Math.Sqrt(area / GOLDENSECTION);
x = GOLDENSECTION * y;
}
}
/// <summary>
/// Rescale the view's Scale value for suitable.
/// </summary>
/// <param name="view">The view to be located on sheet.</param>
/// <param name="x">Distance in x axis between each view</param>
/// <param name="y">Distance in y axis between each view</param>
static private void Rescale(Autodesk.Revit.DB.View view, double x, double y)
{
double Rescale = 2;
Autodesk.Revit.DB.UV outline = new Autodesk.Revit.DB.UV(view.Outline.Max.U - view.Outline.Min.U,
view.Outline.Max.V - view.Outline.Min.V);
if (outline.U > outline.V)
{
Rescale = outline.U / x * Rescale;
}
else
{
Rescale = outline.V / y * Rescale;
}
if (1 != view.Scale && 0 != Rescale)
{
view.Scale = (int)(view.Scale * Rescale);
}
}
}
}
+105
View File
@@ -0,0 +1,105 @@
<?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>{F749EB68-5DEE-4029-8669-49CE5C32CE20}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AllViews</RootNamespace>
<AssemblyName>AllViews</AssemblyName>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<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="AllViews.cs" />
<Compile Include="AllViewsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AllViewsForm.Designer.cs">
<DependentUpon>AllViewsForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="AllViewsForm.resx">
<SubType>Designer</SubType>
<DependentUpon>AllViewsForm.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>
+193
View File
@@ -0,0 +1,193 @@
//
// (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.AllViews.CS
{
partial class AllViewsForm
{
private ViewsMgr m_data;
/// <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.allViewsGroupBox = new System.Windows.Forms.GroupBox();
this.allViewsTreeView = new System.Windows.Forms.TreeView();
this.GenerateSheetGroupBox = new System.Windows.Forms.GroupBox();
this.titleBlocksListBox = new System.Windows.Forms.ListBox();
this.sheetNameLabel = new System.Windows.Forms.Label();
this.sheetNameTextBox = new System.Windows.Forms.TextBox();
this.titleBlocksLabel = new System.Windows.Forms.Label();
this.cancelButton = new System.Windows.Forms.Button();
this.oKButton = new System.Windows.Forms.Button();
this.allViewsGroupBox.SuspendLayout();
this.GenerateSheetGroupBox.SuspendLayout();
this.SuspendLayout();
//
// allViewsGroupBox
//
this.allViewsGroupBox.Controls.Add(this.allViewsTreeView);
this.allViewsGroupBox.Location = new System.Drawing.Point(12, 12);
this.allViewsGroupBox.Name = "allViewsGroupBox";
this.allViewsGroupBox.Size = new System.Drawing.Size(212, 242);
this.allViewsGroupBox.TabIndex = 0;
this.allViewsGroupBox.TabStop = false;
this.allViewsGroupBox.Text = "All Views";
//
// allViewsTreeView
//
this.allViewsTreeView.CheckBoxes = true;
this.allViewsTreeView.Location = new System.Drawing.Point(6, 19);
this.allViewsTreeView.Name = "allViewsTreeView";
this.allViewsTreeView.Size = new System.Drawing.Size(200, 217);
this.allViewsTreeView.TabIndex = 0;
this.allViewsTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.allViewsTreeView_AfterCheck);
//
// GenerateSheetGroupBox
//
this.GenerateSheetGroupBox.Controls.Add(this.titleBlocksListBox);
this.GenerateSheetGroupBox.Controls.Add(this.sheetNameLabel);
this.GenerateSheetGroupBox.Controls.Add(this.sheetNameTextBox);
this.GenerateSheetGroupBox.Controls.Add(this.titleBlocksLabel);
this.GenerateSheetGroupBox.Controls.Add(this.cancelButton);
this.GenerateSheetGroupBox.Controls.Add(this.oKButton);
this.GenerateSheetGroupBox.Location = new System.Drawing.Point(267, 12);
this.GenerateSheetGroupBox.Name = "GenerateSheetGroupBox";
this.GenerateSheetGroupBox.Size = new System.Drawing.Size(172, 236);
this.GenerateSheetGroupBox.TabIndex = 1;
this.GenerateSheetGroupBox.TabStop = false;
this.GenerateSheetGroupBox.Text = "Generate Sheet";
//
// titleBlocksListBox
//
this.titleBlocksListBox.FormattingEnabled = true;
this.titleBlocksListBox.Location = new System.Drawing.Point(9, 44);
this.titleBlocksListBox.Name = "titleBlocksListBox";
this.titleBlocksListBox.Size = new System.Drawing.Size(157, 108);
this.titleBlocksListBox.Sorted = true;
this.titleBlocksListBox.TabIndex = 6;
this.titleBlocksListBox.MouseClick += new System.Windows.Forms.MouseEventHandler(this.titleBlocksListBox_MouseClick);
//
// sheetNameLabel
//
this.sheetNameLabel.AutoSize = true;
this.sheetNameLabel.Location = new System.Drawing.Point(6, 170);
this.sheetNameLabel.Name = "sheetNameLabel";
this.sheetNameLabel.Size = new System.Drawing.Size(66, 13);
this.sheetNameLabel.TabIndex = 5;
this.sheetNameLabel.Text = "Sheet Name";
//
// sheetNameTextBox
//
this.sheetNameTextBox.Location = new System.Drawing.Point(78, 167);
this.sheetNameTextBox.Name = "sheetNameTextBox";
this.sheetNameTextBox.Size = new System.Drawing.Size(88, 20);
this.sheetNameTextBox.TabIndex = 2;
this.sheetNameTextBox.Text = "Unname";
//
// titleBlocksLabel
//
this.titleBlocksLabel.AutoSize = true;
this.titleBlocksLabel.Location = new System.Drawing.Point(6, 19);
this.titleBlocksLabel.Name = "titleBlocksLabel";
this.titleBlocksLabel.Size = new System.Drawing.Size(59, 13);
this.titleBlocksLabel.TabIndex = 3;
this.titleBlocksLabel.Text = "TitleBlocks";
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(91, 207);
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;
//
// oKButton
//
this.oKButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.oKButton.Location = new System.Drawing.Point(6, 207);
this.oKButton.Name = "oKButton";
this.oKButton.Size = new System.Drawing.Size(75, 23);
this.oKButton.TabIndex = 3;
this.oKButton.Text = "&OK";
this.oKButton.UseVisualStyleBackColor = true;
this.oKButton.Click += new System.EventHandler(this.oKButton_Click);
//
// AllViewsForm
//
this.AcceptButton = this.oKButton;
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(459, 266);
this.Controls.Add(this.GenerateSheetGroupBox);
this.Controls.Add(this.allViewsGroupBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "AllViewsForm";
this.ShowInTaskbar = false;
this.Text = "All Views";
this.Load += new System.EventHandler(this.AllViewsForm_Load);
this.allViewsGroupBox.ResumeLayout(false);
this.GenerateSheetGroupBox.ResumeLayout(false);
this.GenerateSheetGroupBox.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox allViewsGroupBox;
private System.Windows.Forms.GroupBox GenerateSheetGroupBox;
private System.Windows.Forms.Button oKButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.TreeView allViewsTreeView;
private System.Windows.Forms.Label titleBlocksLabel;
private System.Windows.Forms.TextBox sheetNameTextBox;
private System.Windows.Forms.Label sheetNameLabel;
private System.Windows.Forms.ListBox titleBlocksListBox;
}
}
+118
View File
@@ -0,0 +1,118 @@
//
// (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 System.Collections;
namespace Revit.SDK.Samples.AllViews.CS
{
/// <summary>
/// This is a dialog should appear that contains the following:
/// A tree view represents all the views' names.
/// A list of all title blocks.
/// An edit box for the sheet's name.
/// </summary>
public partial class AllViewsForm : System.Windows.Forms.Form
{
/// <summary>
/// constructor
/// </summary>
/// <param name="data"></param>
public AllViewsForm(ViewsMgr data)
{
m_data = data;
InitializeComponent();
}
private void AllViewsForm_Load(object sender, EventArgs e)
{
allViewsTreeView.Nodes.Add(m_data.AllViewsNames);
allViewsTreeView.TopNode.Expand();
foreach (string s in m_data.AllTitleBlocksNames)
{
titleBlocksListBox.Items.Add(s);
}
}
private void oKButton_Click(object sender, EventArgs e)
{
m_data.SelectViews();
m_data.SheetName = sheetNameTextBox.Text;
if (1 == titleBlocksListBox.SelectedItems.Count)
{
string titleBlock = titleBlocksListBox.SelectedItems[0].ToString();
m_data.ChooseTitleBlock(titleBlock);
}
}
#region CheckTreeNode
private void CheckNode(TreeNode node, bool check)
{
if (0 < node.Nodes.Count)
{
if (node.Checked)
{
node.Expand();
}
else
{
node.Collapse();
}
foreach (TreeNode t in node.Nodes)
{
t.Checked = check;
CheckNode(t, check);
}
}
}
private void allViewsTreeView_AfterCheck(object sender, TreeViewEventArgs e)
{
CheckNode(e.Node, e.Node.Checked);
}
#endregion
/// <summary>
/// Select title block to generate sheet.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void titleBlocksListBox_MouseClick(object sender, MouseEventArgs e)
{
int idx = titleBlocksListBox.SelectedIndex;
if (0 < idx)
{
titleBlocksListBox.SetSelected(idx, true);
}
}
}
}
+120
View File
@@ -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>
@@ -0,0 +1,57 @@
//
// (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.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("AllViews")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AllViews")]
[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("7ba20956-98fa-4f1b-9a58-6716332a7b88")]
// 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")]
Binary file not shown.