mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-25 12:25:30 +00:00
integrate Revit 2025 SDK
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"ms-dotnettools.csharp",
|
||||
]
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Attach to Revit",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processName": "revit.exe",
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
]
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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 Autodesk;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.CapitalizeText.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// automatically replaces all text in text notes with capitalized text.
|
||||
/// </summary>
|
||||
public class CapitalizeText
|
||||
{
|
||||
private Document? m_doc = null;
|
||||
|
||||
/// <summary>
|
||||
/// Automatic print of all of a certain view type, to the default printer .
|
||||
/// </summary>
|
||||
private CapitalizeText()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor wit parameter used to call this sample.
|
||||
/// </summary>
|
||||
/// <param name="doc"></param>
|
||||
public CapitalizeText(ThisApplication hostDoc)
|
||||
{
|
||||
m_doc = hostDoc.ActiveUIDocument.Document;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// run this sample now
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
TextElement? text = null;
|
||||
|
||||
// filtrate the TextElment from the element set
|
||||
ElementClassFilter gridFilter = new ElementClassFilter(typeof(TextElement));
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_doc);
|
||||
collector.WherePasses(gridFilter);
|
||||
IList<Element> arrayText = collector.ToElements();
|
||||
|
||||
// matching and capitalizing
|
||||
int capitalizednum = 0;
|
||||
foreach (Element ee in arrayText)
|
||||
{
|
||||
text = ee as TextElement;
|
||||
if (text == null)
|
||||
continue;
|
||||
text.Text = text.Text.ToUpper();
|
||||
capitalizednum++;
|
||||
|
||||
}
|
||||
|
||||
// Show the number of notes modified.
|
||||
MessageBox.Show("Revit has completed its search and has made " + capitalizednum + " modifications.", "CapitalizeText");
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
MessageBox.Show(ee.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+523
@@ -0,0 +1,523 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
using ELEMENT = Autodesk.Revit.DB.Element;
|
||||
using STRUCTURALTYPE = Autodesk.Revit.DB.Structure.StructuralType;
|
||||
using System.Diagnostics;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.CreateBeamsColumnsBraces.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Create Beams, Columns and Braces according to user's input information
|
||||
/// </summary>
|
||||
public class CreateBeamsColumnsBraces
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor without parameter is not allowed
|
||||
/// </summary>
|
||||
private CreateBeamsColumnsBraces() { }
|
||||
|
||||
/// <summary>
|
||||
/// ctor wit parameter used to call this sample
|
||||
/// </summary>
|
||||
/// <param name="hostApp"></param>
|
||||
public CreateBeamsColumnsBraces(ThisApplication? App)
|
||||
{
|
||||
m_app = App;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// run this sample now
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
//if initialize failed return Result.Failed
|
||||
bool initializeOK = Initialize();
|
||||
if (!initializeOK)
|
||||
{
|
||||
MessageBox.Show("Failed to start this sample!");
|
||||
return;
|
||||
}
|
||||
|
||||
using (CreateBeamsColumnsBracesForm displayForm = new CreateBeamsColumnsBracesForm(this))
|
||||
{
|
||||
displayForm.ShowDialog();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Class Members Variables
|
||||
ThisApplication? m_app = null;
|
||||
|
||||
ArrayList m_columnMaps = new ArrayList(); //list of columns' type
|
||||
ArrayList m_beamMaps = new ArrayList(); //list of beams' type
|
||||
ArrayList m_braceMaps = new ArrayList(); //list of braces' type
|
||||
SortedList levels = new SortedList(); //list of list sorted by their elevations
|
||||
|
||||
UV[,]? m_matrixUV; //2D coordinates of matrix
|
||||
#endregion
|
||||
|
||||
#region Class Properties and Methods
|
||||
/// <summary>
|
||||
/// list of all type of columns
|
||||
/// </summary>
|
||||
public ArrayList ColumnMaps
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_columnMaps;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// list of all type of beams
|
||||
/// </summary>
|
||||
public ArrayList BeamMaps
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_beamMaps;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// list of all type of braces
|
||||
/// </summary>
|
||||
public ArrayList BraceMaps
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_braceMaps;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// check the number of floors is less than the number of levels
|
||||
/// create beams, columns and braces according to selected types
|
||||
/// </summary>
|
||||
/// <param name="columnObject">type of column</param>
|
||||
/// <param name="beamObject">type of beam</param>
|
||||
/// <param name="braceObject">type of brace</param>
|
||||
/// <param name="floorNumber">number of floor</param>
|
||||
/// <returns>number of floors is less than the number of levels and create successfully then return true</returns>
|
||||
public bool AddInstance(object columnObject, object beamObject, object braceObject, int floorNumber)
|
||||
{
|
||||
//whether floor number less than levels number
|
||||
if (floorNumber >= levels.Count)
|
||||
{
|
||||
MessageBox.Show("The number of levels must be added.", "Revit");
|
||||
return false;
|
||||
}
|
||||
|
||||
FamilySymbol? columnSymbol = columnObject as FamilySymbol;
|
||||
FamilySymbol? beamSymbol = beamObject as FamilySymbol;
|
||||
FamilySymbol? braceSymbol = braceObject as FamilySymbol;
|
||||
|
||||
//any symbol is null then the command failed
|
||||
if (null == columnSymbol || null == beamSymbol || null == braceSymbol)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (m_matrixUV == null)
|
||||
return false;
|
||||
for (int k = 0; k < floorNumber; k++) //iterate levels from lower one to higher
|
||||
{
|
||||
Level? baseLevel = levels.GetByIndex(k) as Level;
|
||||
Level? topLevel = levels.GetByIndex(k + 1) as Level;
|
||||
|
||||
int matrixXSize = m_matrixUV.GetLength(0); //length of matrix's x range
|
||||
int matrixYSize = m_matrixUV.GetLength(1); //length of matrix's y range
|
||||
|
||||
//iterate coordinate both in x direction and y direction and create beams and braces
|
||||
for (int j = 0; j < matrixYSize; j++)
|
||||
{
|
||||
for (int i = 0; i < matrixXSize; i++)
|
||||
{
|
||||
//create beams and braces in x direction
|
||||
if (i != (matrixXSize - 1) && baseLevel != null && topLevel != null)
|
||||
{
|
||||
PlaceBrace(m_matrixUV[i, j], m_matrixUV[i + 1, j], baseLevel, topLevel, braceSymbol, true);
|
||||
}
|
||||
//create beams and braces in y direction
|
||||
if (j != (matrixYSize - 1) && baseLevel != null && topLevel != null)
|
||||
{
|
||||
PlaceBrace(m_matrixUV[i, j], m_matrixUV[i, j + 1], baseLevel, topLevel, braceSymbol, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < matrixYSize; j++)
|
||||
{
|
||||
for (int i = 0; i < matrixXSize; i++)
|
||||
{
|
||||
//create beams and braces in x direction
|
||||
if (i != (matrixXSize - 1) && baseLevel != null && topLevel != null)
|
||||
{
|
||||
PlaceBeam(m_matrixUV[i, j], m_matrixUV[i + 1, j], baseLevel, topLevel, beamSymbol);
|
||||
}
|
||||
//create beams and braces in y direction
|
||||
if (j != (matrixYSize - 1) && baseLevel != null && topLevel != null)
|
||||
{
|
||||
PlaceBeam(m_matrixUV[i, j], m_matrixUV[i, j + 1], baseLevel, topLevel, beamSymbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
//place column of this level
|
||||
foreach (UV point2D in m_matrixUV)
|
||||
{
|
||||
if (baseLevel != null && topLevel != null)
|
||||
PlaceColumn(point2D, columnSymbol, baseLevel, topLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// generate 2D coordinates of matrix according to parameters
|
||||
/// </summary>
|
||||
/// <param name="xNumber">Number of Columns in the X direction</param>
|
||||
/// <param name="yNumber">Number of Columns in the Y direction</param>
|
||||
/// <param name="distance">Distance between columns</param>
|
||||
public void CreateMatrix(int xNumber, int yNumber, double distance)
|
||||
{
|
||||
m_matrixUV = new UV[xNumber, yNumber];
|
||||
if (m_app != null)
|
||||
{
|
||||
for (int i = 0; i < xNumber; i++)
|
||||
{
|
||||
for (int j = 0; j < yNumber; j++)
|
||||
{
|
||||
object[] param = { i * distance, j * distance };
|
||||
m_matrixUV[i, j] = m_app.ActiveUIDocument.Document.Application.Create.NewUV(i * distance, j * distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// iterate all the symbols of levels, columns, beams and braces
|
||||
/// </summary>
|
||||
/// <returns>A value that signifies if the initialization was successful for true or failed for false</returns>
|
||||
private bool Initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_app == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ElementClassFilter levelFilter = new ElementClassFilter(typeof(Level));
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_app.ActiveUIDocument.Document);
|
||||
collector.WherePasses(levelFilter);
|
||||
IList<Element> arrayLevel = collector.ToElements();
|
||||
|
||||
foreach (Autodesk.Revit.DB.Element ee in arrayLevel)
|
||||
{
|
||||
Level? level = ee as Level;
|
||||
if (null != level)
|
||||
{
|
||||
levels.Add(level.Elevation, level);
|
||||
}
|
||||
}
|
||||
|
||||
ElementClassFilter filterFamily = new ElementClassFilter(typeof(Family));
|
||||
collector = new FilteredElementCollector(m_app.ActiveUIDocument.Document);
|
||||
collector.WherePasses(filterFamily);
|
||||
IList<Element> arrayFamily = collector.ToElements();
|
||||
|
||||
foreach (Autodesk.Revit.DB.Element ee in arrayFamily)
|
||||
{
|
||||
Family? f = ee as Family;
|
||||
if (null != f)
|
||||
{
|
||||
foreach (ElementId symbolId in f.GetFamilySymbolIds())
|
||||
{
|
||||
FamilySymbol? familyType = m_app.ActiveUIDocument.Document.GetElement(symbolId) as FamilySymbol;
|
||||
if (null == familyType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (null == familyType.Category)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//add symbols of beams and braces to lists
|
||||
string categoryName = familyType.Category.Name;
|
||||
if ("Structural Framing" == categoryName)
|
||||
{
|
||||
m_beamMaps.Add(new SymbolMap(familyType));
|
||||
m_braceMaps.Add(new SymbolMap(familyType));
|
||||
}
|
||||
else if ("Structural Columns" == categoryName)
|
||||
{
|
||||
m_columnMaps.Add(new SymbolMap(familyType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create column of certain type in certain position
|
||||
/// </summary>
|
||||
/// <param name="point2D">2D coordinate of the column</param>
|
||||
/// <param name="columnType">type of column</param>
|
||||
/// <param name="baseLevel">the base level of the column</param>
|
||||
/// <param name="topLevel">the top level of the colunm</param>
|
||||
private void PlaceColumn(UV point2D, FamilySymbol columnType, Level baseLevel, Level topLevel)
|
||||
{
|
||||
//create column of certain type in certain level and start point
|
||||
object[] xyzParam = { point2D.U, point2D.V, 0 };
|
||||
if (m_app == null)
|
||||
return;
|
||||
XYZ point = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D.U, point2D.V, 0);
|
||||
|
||||
//
|
||||
// create family instance now
|
||||
STRUCTURALTYPE structuralType;
|
||||
structuralType = Autodesk.Revit.DB.Structure.StructuralType.Column;
|
||||
FamilyInstance column = m_app.ActiveUIDocument.Document.Create.NewFamilyInstance(point, columnType, topLevel, structuralType);
|
||||
|
||||
//set baselevel & toplevel of the column
|
||||
if (null != column)
|
||||
{
|
||||
Parameter baseLevelParameter = column.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.FAMILY_BASE_LEVEL_PARAM);
|
||||
Parameter topLevelParameter = column.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.FAMILY_TOP_LEVEL_PARAM);
|
||||
Parameter topOffsetParameter = column.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM);
|
||||
Parameter baseOffsetParameter = column.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM);
|
||||
|
||||
if (null != baseLevelParameter)
|
||||
{
|
||||
Autodesk.Revit.DB.ElementId baseLevelId;
|
||||
baseLevelId = baseLevel.Id;
|
||||
baseLevelParameter.Set(baseLevelId);
|
||||
}
|
||||
|
||||
if (null != topLevelParameter)
|
||||
{
|
||||
Autodesk.Revit.DB.ElementId topLevelId;
|
||||
topLevelId = topLevel.Id;
|
||||
topLevelParameter.Set(topLevelId);
|
||||
}
|
||||
|
||||
if (null != topOffsetParameter)
|
||||
{
|
||||
topOffsetParameter.Set(0.0);
|
||||
}
|
||||
|
||||
if (null != baseOffsetParameter)
|
||||
{
|
||||
baseOffsetParameter.Set(0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create beam of certain type in certain position
|
||||
/// </summary>
|
||||
/// <param name="point2D1">one point of the location line in 2D</param>
|
||||
/// <param name="point2D2">another point of the location line in 2D</param>
|
||||
/// <param name="baseLevel">the base level of the beam</param>
|
||||
/// <param name="topLevel">the top level of the beam</param>
|
||||
/// <param name="beamType">type of beam</param>
|
||||
/// <returns>nothing</returns>
|
||||
private void PlaceBeam(UV point2D1, UV point2D2, Level baseLevel, Level topLevel, FamilySymbol beamType)
|
||||
{
|
||||
// create start and end points for beam
|
||||
if (m_app == null)
|
||||
return;
|
||||
double height = topLevel.Elevation;
|
||||
XYZ startPoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D1.U, point2D1.V, height);
|
||||
XYZ endPoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D2.U, point2D2.V, height);
|
||||
ElementId topLevelId = topLevel.Id;
|
||||
|
||||
STRUCTURALTYPE structuralType = Autodesk.Revit.DB.Structure.StructuralType.Beam;
|
||||
FamilyInstance beam = m_app.ActiveUIDocument.Document.Create.NewFamilyInstance(startPoint, beamType, topLevel, structuralType);
|
||||
|
||||
LocationCurve? beamCurve = beam.Location as LocationCurve;
|
||||
if (null != beamCurve)
|
||||
{
|
||||
Line line = Line.CreateBound(startPoint, endPoint);
|
||||
beamCurve.Curve = line;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create brace of certain type in certain position between two adjacent columns
|
||||
/// </summary>
|
||||
/// <param name="point2D1">one point of the location line in 2D</param>
|
||||
/// <param name="point2D2">another point of the location line in 2D</param>
|
||||
/// <param name="baseLevel">the base level of the brace</param>
|
||||
/// <param name="topLevel">the top level of the brace</param>
|
||||
/// <param name="braceType">type of beam</param>
|
||||
/// <param name="isXDirection">whether the location line is in x direction</param>
|
||||
private void PlaceBrace(UV point2D1, UV point2D2, Level baseLevel, Level topLevel, FamilySymbol braceType, bool isXDirection)
|
||||
{
|
||||
//get the start points and end points of location lines of two braces
|
||||
if (m_app == null)
|
||||
return;
|
||||
double topHeight = topLevel.Elevation;
|
||||
double baseHeight = baseLevel.Elevation;
|
||||
double middleElevation = (topHeight + baseHeight) / 2;
|
||||
double middleHeight = (topHeight - baseHeight) / 2;
|
||||
|
||||
XYZ startPoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D1.U, point2D1.V, middleElevation);
|
||||
XYZ endPoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D2.U, point2D2.V, middleElevation);
|
||||
XYZ middlePoint;
|
||||
|
||||
if (isXDirection)
|
||||
{
|
||||
middlePoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ((point2D1.U + point2D2.U) / 2, point2D2.V, topHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
middlePoint = middlePoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(point2D2.U, (point2D1.V + point2D2.V) / 2, topHeight);
|
||||
}
|
||||
|
||||
//create two brace and set their location line
|
||||
STRUCTURALTYPE structuralType = Autodesk.Revit.DB.Structure.StructuralType.Brace;
|
||||
ElementId levelId = topLevel.Id;
|
||||
ElementId startLevelId = baseLevel.Id;
|
||||
ElementId endLevelId = topLevel.Id;
|
||||
|
||||
FamilyInstance firstBrace = m_app.ActiveUIDocument.Document.Create.NewFamilyInstance(startPoint, braceType, structuralType);
|
||||
LocationCurve? braceCurve1 = firstBrace.Location as LocationCurve;
|
||||
if (null != braceCurve1)
|
||||
{
|
||||
Line line = Line.CreateBound(startPoint, middlePoint);
|
||||
braceCurve1.Curve = line;
|
||||
}
|
||||
|
||||
Parameter referenceLevel1 = firstBrace.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM);
|
||||
if (null != referenceLevel1)
|
||||
{
|
||||
referenceLevel1.Set(levelId);
|
||||
}
|
||||
|
||||
FamilyInstance secondBrace = m_app.ActiveUIDocument.Document.Create.NewFamilyInstance(endPoint, braceType, baseLevel, structuralType);
|
||||
LocationCurve? braceCurve2 = secondBrace.Location as LocationCurve;
|
||||
if (null != braceCurve2)
|
||||
{
|
||||
Line line = Line.CreateBound(endPoint, middlePoint);
|
||||
braceCurve2.Curve = line;
|
||||
}
|
||||
|
||||
Parameter referenceLevel2 = secondBrace.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM);
|
||||
if (null != referenceLevel2)
|
||||
{
|
||||
referenceLevel2.Set(levelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// assistant class contains symbol and it's name
|
||||
/// </summary>
|
||||
public class SymbolMap
|
||||
{
|
||||
string m_symbolName = "";
|
||||
FamilySymbol? m_symbol = null;
|
||||
|
||||
/// <summary>
|
||||
/// constructor without parameter is forbidden
|
||||
/// </summary>
|
||||
private SymbolMap()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="symbol">family symbol</param>
|
||||
public SymbolMap(FamilySymbol symbol)
|
||||
{
|
||||
m_symbol = symbol;
|
||||
string familyName = "";
|
||||
if (null != symbol.Family)
|
||||
{
|
||||
familyName = symbol.Family.Name;
|
||||
}
|
||||
m_symbolName = familyName + " : " + symbol.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SymbolName property
|
||||
/// </summary>
|
||||
public string SymbolName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_symbolName;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// ElementType property
|
||||
/// </summary>
|
||||
public FamilySymbol? ElementType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_symbol;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+506
@@ -0,0 +1,506 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Revit.SDK.Samples.CreateBeamsColumnsBraces.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// UI
|
||||
/// </summary>
|
||||
public class CreateBeamsColumnsBracesForm : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container? components = null;
|
||||
private System.Windows.Forms.Button? OKButton;
|
||||
private System.Windows.Forms.TextBox? XTextBox;
|
||||
private System.Windows.Forms.TextBox? DistanceTextBox;
|
||||
private System.Windows.Forms.TextBox? YTextBox;
|
||||
private System.Windows.Forms.ComboBox? columnComboBox;
|
||||
private System.Windows.Forms.ComboBox? beamComboBox;
|
||||
private System.Windows.Forms.ComboBox? braceComboBox;
|
||||
private System.Windows.Forms.Button? cancelButton;
|
||||
private System.Windows.Forms.TextBox? floornumberTextBox;
|
||||
private System.Windows.Forms.Label? columnLabel;
|
||||
private System.Windows.Forms.Label? beamLabel;
|
||||
private System.Windows.Forms.Label? braceLabel;
|
||||
private System.Windows.Forms.Label? DistanceLabel;
|
||||
private System.Windows.Forms.Label? YLabel;
|
||||
private System.Windows.Forms.Label? XLabel;
|
||||
private System.Windows.Forms.Label? floornumberLabel;
|
||||
private System.Windows.Forms.Label? unitLabel;
|
||||
|
||||
// To store the datas
|
||||
CreateBeamsColumnsBraces? m_dataBuffer = null;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="dataBuffer">the revit datas</param>
|
||||
public CreateBeamsColumnsBracesForm(CreateBeamsColumnsBraces? dataBuffer)
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
m_dataBuffer = dataBuffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (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()
|
||||
{
|
||||
OKButton = new System.Windows.Forms.Button();
|
||||
XTextBox = new System.Windows.Forms.TextBox();
|
||||
YTextBox = new System.Windows.Forms.TextBox();
|
||||
DistanceTextBox = new System.Windows.Forms.TextBox();
|
||||
columnComboBox = new System.Windows.Forms.ComboBox();
|
||||
beamComboBox = new System.Windows.Forms.ComboBox();
|
||||
braceComboBox = new System.Windows.Forms.ComboBox();
|
||||
columnLabel = new System.Windows.Forms.Label();
|
||||
beamLabel = new System.Windows.Forms.Label();
|
||||
braceLabel = new System.Windows.Forms.Label();
|
||||
floornumberTextBox = new System.Windows.Forms.TextBox();
|
||||
DistanceLabel = new System.Windows.Forms.Label();
|
||||
YLabel = new System.Windows.Forms.Label();
|
||||
XLabel = new System.Windows.Forms.Label();
|
||||
floornumberLabel = new System.Windows.Forms.Label();
|
||||
cancelButton = new System.Windows.Forms.Button();
|
||||
unitLabel = new System.Windows.Forms.Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// OKButton
|
||||
//
|
||||
OKButton.Location = new System.Drawing.Point(296, 208);
|
||||
OKButton.Name = "OKButton";
|
||||
OKButton.Size = new System.Drawing.Size(75, 23);
|
||||
OKButton.TabIndex = 8;
|
||||
OKButton.Text = "&OK";
|
||||
OKButton.Click += new System.EventHandler(OKButton_Click);
|
||||
//
|
||||
// XTextBox
|
||||
//
|
||||
XTextBox.Location = new System.Drawing.Point(16, 96);
|
||||
XTextBox.Name = "XTextBox";
|
||||
XTextBox.Size = new System.Drawing.Size(136, 20);
|
||||
XTextBox.TabIndex = 2;
|
||||
XTextBox.Validating += new System.ComponentModel.CancelEventHandler(XTextBox_Validating);
|
||||
//
|
||||
// YTextBox
|
||||
//
|
||||
YTextBox.Location = new System.Drawing.Point(16, 152);
|
||||
YTextBox.Name = "YTextBox";
|
||||
YTextBox.Size = new System.Drawing.Size(136, 20);
|
||||
YTextBox.TabIndex = 3;
|
||||
YTextBox.Validating += new System.ComponentModel.CancelEventHandler(YTextBox_Validating);
|
||||
//
|
||||
// DistanceTextBox
|
||||
//
|
||||
DistanceTextBox.Location = new System.Drawing.Point(16, 40);
|
||||
DistanceTextBox.Name = "DistanceTextBox";
|
||||
DistanceTextBox.Size = new System.Drawing.Size(112, 20);
|
||||
DistanceTextBox.TabIndex = 1;
|
||||
DistanceTextBox.Validating += new System.ComponentModel.CancelEventHandler(DistanceTextBox_Validating);
|
||||
//
|
||||
// columnComboBox
|
||||
//
|
||||
columnComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
columnComboBox.Location = new System.Drawing.Point(240, 40);
|
||||
columnComboBox.Name = "columnComboBox";
|
||||
columnComboBox.Size = new System.Drawing.Size(288, 21);
|
||||
columnComboBox.TabIndex = 5;
|
||||
//
|
||||
// beamComboBox
|
||||
//
|
||||
beamComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
beamComboBox.Location = new System.Drawing.Point(240, 96);
|
||||
beamComboBox.Name = "beamComboBox";
|
||||
beamComboBox.Size = new System.Drawing.Size(288, 21);
|
||||
beamComboBox.TabIndex = 6;
|
||||
//
|
||||
// braceComboBox
|
||||
//
|
||||
braceComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
braceComboBox.Location = new System.Drawing.Point(240, 152);
|
||||
braceComboBox.Name = "braceComboBox";
|
||||
braceComboBox.Size = new System.Drawing.Size(288, 21);
|
||||
braceComboBox.TabIndex = 7;
|
||||
//
|
||||
// columnLabel
|
||||
//
|
||||
columnLabel.Location = new System.Drawing.Point(240, 16);
|
||||
columnLabel.Name = "columnLabel";
|
||||
columnLabel.Size = new System.Drawing.Size(120, 23);
|
||||
columnLabel.TabIndex = 10;
|
||||
columnLabel.Text = "Type of Columns:";
|
||||
//
|
||||
// beamLabel
|
||||
//
|
||||
beamLabel.Location = new System.Drawing.Point(240, 72);
|
||||
beamLabel.Name = "beamLabel";
|
||||
beamLabel.Size = new System.Drawing.Size(120, 23);
|
||||
beamLabel.TabIndex = 11;
|
||||
beamLabel.Text = "Type of Beams:";
|
||||
//
|
||||
// braceLabel
|
||||
//
|
||||
braceLabel.Location = new System.Drawing.Point(240, 128);
|
||||
braceLabel.Name = "braceLabel";
|
||||
braceLabel.Size = new System.Drawing.Size(120, 23);
|
||||
braceLabel.TabIndex = 12;
|
||||
braceLabel.Text = "Type of Braces:";
|
||||
//
|
||||
// floornumberTextBox
|
||||
//
|
||||
floornumberTextBox.Location = new System.Drawing.Point(16, 208);
|
||||
floornumberTextBox.Name = "floornumberTextBox";
|
||||
floornumberTextBox.Size = new System.Drawing.Size(112, 20);
|
||||
floornumberTextBox.TabIndex = 4;
|
||||
floornumberTextBox.Validating += new System.ComponentModel.CancelEventHandler(floornumberTextBox_Validating);
|
||||
//
|
||||
// DistanceLabel
|
||||
//
|
||||
DistanceLabel.Location = new System.Drawing.Point(16, 16);
|
||||
DistanceLabel.Name = "DistanceLabel";
|
||||
DistanceLabel.Size = new System.Drawing.Size(152, 23);
|
||||
DistanceLabel.TabIndex = 14;
|
||||
DistanceLabel.Text = "Distance between Columns:";
|
||||
//
|
||||
// YLabel
|
||||
//
|
||||
YLabel.Location = new System.Drawing.Point(16, 128);
|
||||
YLabel.Name = "YLabel";
|
||||
YLabel.Size = new System.Drawing.Size(200, 23);
|
||||
YLabel.TabIndex = 15;
|
||||
YLabel.Text = "Number of Columns in the Y Direction:";
|
||||
//
|
||||
// XLabel
|
||||
//
|
||||
XLabel.Location = new System.Drawing.Point(16, 72);
|
||||
XLabel.Name = "XLabel";
|
||||
XLabel.Size = new System.Drawing.Size(200, 23);
|
||||
XLabel.TabIndex = 16;
|
||||
XLabel.Text = "Number of Columns in the X Direction:";
|
||||
//
|
||||
// floornumberLabel
|
||||
//
|
||||
floornumberLabel.Location = new System.Drawing.Point(16, 184);
|
||||
floornumberLabel.Name = "floornumberLabel";
|
||||
floornumberLabel.Size = new System.Drawing.Size(144, 23);
|
||||
floornumberLabel.TabIndex = 17;
|
||||
floornumberLabel.Text = "Number of Floors:";
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
cancelButton.Location = new System.Drawing.Point(392, 208);
|
||||
cancelButton.Name = "cancelButton";
|
||||
cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
cancelButton.TabIndex = 9;
|
||||
cancelButton.Text = "&Cancel";
|
||||
cancelButton.Click += new System.EventHandler(cancelButton_Click);
|
||||
//
|
||||
// unitLabel
|
||||
//
|
||||
unitLabel.Location = new System.Drawing.Point(136, 42);
|
||||
unitLabel.Name = "unitLabel";
|
||||
unitLabel.Size = new System.Drawing.Size(32, 23);
|
||||
unitLabel.TabIndex = 18;
|
||||
unitLabel.Text = "feet";
|
||||
//
|
||||
// CreateBeamsColumnsBracesForm
|
||||
//
|
||||
AcceptButton = OKButton;
|
||||
AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
||||
CancelButton = cancelButton;
|
||||
ClientSize = new System.Drawing.Size(546, 246);
|
||||
Controls.Add(unitLabel);
|
||||
Controls.Add(cancelButton);
|
||||
Controls.Add(floornumberLabel);
|
||||
Controls.Add(XLabel);
|
||||
Controls.Add(YLabel);
|
||||
Controls.Add(DistanceLabel);
|
||||
Controls.Add(floornumberTextBox);
|
||||
Controls.Add(DistanceTextBox);
|
||||
Controls.Add(YTextBox);
|
||||
Controls.Add(XTextBox);
|
||||
Controls.Add(braceLabel);
|
||||
Controls.Add(beamLabel);
|
||||
Controls.Add(columnLabel);
|
||||
Controls.Add(braceComboBox);
|
||||
Controls.Add(beamComboBox);
|
||||
Controls.Add(columnComboBox);
|
||||
Controls.Add(OKButton);
|
||||
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "CreateBeamsColumnsBracesForm";
|
||||
ShowInTaskbar = false;
|
||||
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
Text = "Create Beams Columns and Braces";
|
||||
Load += new System.EventHandler(CreateBeamsColumnsBracesForm_Load);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Refresh the text box for the default datas
|
||||
/// </summary>
|
||||
private void TextBoxRefresh()
|
||||
{
|
||||
if (XTextBox != null && YTextBox != null && DistanceTextBox != null && floornumberTextBox != null)
|
||||
{
|
||||
XTextBox.Text = "2";
|
||||
YTextBox.Text = "2";
|
||||
DistanceTextBox.Text = "20.0";
|
||||
floornumberTextBox.Text = "1";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CreateBeamsColumnsBracesForm_Load(object? sender, System.EventArgs e)
|
||||
{
|
||||
TextBoxRefresh();
|
||||
if (columnComboBox == null || beamComboBox == null || braceComboBox == null)
|
||||
return;
|
||||
bool notLoadSymbol = false;
|
||||
if (0 == m_dataBuffer?.ColumnMaps.Count)
|
||||
{
|
||||
MessageBox.Show("No Structural Columns family is loaded in the project, please load one firstly.", "Revit");
|
||||
notLoadSymbol = true;
|
||||
}
|
||||
if (0 == m_dataBuffer?.BeamMaps.Count)
|
||||
{
|
||||
MessageBox.Show("No Structural Framing family is loaded in the project, please load one firstly.", "Revit");
|
||||
notLoadSymbol = true;
|
||||
}
|
||||
|
||||
if (notLoadSymbol)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
columnComboBox.DataSource = m_dataBuffer?.ColumnMaps;
|
||||
columnComboBox.DisplayMember = "SymbolName";
|
||||
columnComboBox.ValueMember = "ElementType";
|
||||
|
||||
beamComboBox.DataSource = m_dataBuffer?.BeamMaps;
|
||||
beamComboBox.DisplayMember = "SymbolName";
|
||||
beamComboBox.ValueMember = "ElementType";
|
||||
|
||||
braceComboBox.DataSource = m_dataBuffer?.BraceMaps;
|
||||
braceComboBox.DisplayMember = "SymbolName";
|
||||
braceComboBox.ValueMember = "ElementType";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// accept use's inpurt and create columns, beams and braces
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OKButton_Click(object? sender, System.EventArgs e)
|
||||
{
|
||||
//check whether the input is correct and create elements
|
||||
try
|
||||
{
|
||||
if (XTextBox == null || YTextBox == null || DistanceTextBox == null || columnComboBox == null || beamComboBox == null || braceComboBox == null || floornumberTextBox == null)
|
||||
return;
|
||||
int xNumber = int.Parse(XTextBox.Text);
|
||||
int yNumber = int.Parse(YTextBox.Text);
|
||||
double distance = double.Parse(DistanceTextBox.Text);
|
||||
object? columnType = columnComboBox.SelectedValue;
|
||||
object? beamType = beamComboBox.SelectedValue;
|
||||
object? braceType = braceComboBox.SelectedValue;
|
||||
int floorNumber = int.Parse(floornumberTextBox.Text);
|
||||
if (columnType != null && beamType != null && braceType != null)
|
||||
{
|
||||
m_dataBuffer?.CreateMatrix(xNumber, yNumber, distance);
|
||||
m_dataBuffer?.AddInstance(columnType, beamType, braceType, floorNumber);
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Please input datas correctly.", "Revit");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// cancel the command
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void cancelButton_Click(object? sender, System.EventArgs? e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the distance
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DistanceTextBox_Validating(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (DistanceTextBox == null)
|
||||
return;
|
||||
double distance = 0.1;
|
||||
try
|
||||
{
|
||||
distance = double.Parse(DistanceTextBox.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Please enter a value larger than 5 and less than 30000.", "Revit");
|
||||
DistanceTextBox.Text = "";
|
||||
DistanceTextBox.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (distance <= 5)
|
||||
{
|
||||
MessageBox.Show("Please enter a value larger than 5.", "Revit");
|
||||
DistanceTextBox.Text = "";
|
||||
DistanceTextBox.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (distance > 30000)
|
||||
{
|
||||
MessageBox.Show("Please enter a value less than 30000.", "Revit");
|
||||
DistanceTextBox.Text = "";
|
||||
DistanceTextBox.Focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the number of X direction
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void XTextBox_Validating(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (XTextBox == null)
|
||||
return;
|
||||
int xNumber = 1;
|
||||
try
|
||||
{
|
||||
xNumber = int.Parse(XTextBox.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for X direction between 1 to 20.", "Revit");
|
||||
XTextBox.Text = "";
|
||||
}
|
||||
if (xNumber < 1 || xNumber > 20)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for X direction between 1 to 20.", "Revit");
|
||||
XTextBox.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the number of Y direction
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void YTextBox_Validating(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (YTextBox == null)
|
||||
return;
|
||||
int yNumber = 1;
|
||||
try
|
||||
{
|
||||
yNumber = int.Parse(YTextBox.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for Y direction between 1 to 20.", "Revit");
|
||||
YTextBox.Text = "";
|
||||
}
|
||||
if (yNumber < 1 || yNumber > 20)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for Y direction between 1 to 20.", "Revit");
|
||||
YTextBox.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the number of floors
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void floornumberTextBox_Validating(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (floornumberTextBox == null)
|
||||
return;
|
||||
int floorNumber = 1;
|
||||
try
|
||||
{
|
||||
floorNumber = int.Parse(floornumberTextBox.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for the number of floors between 1 to 10.", "Revit");
|
||||
floornumberTextBox.Text = "";
|
||||
}
|
||||
if (floorNumber < 1 || floorNumber > 10)
|
||||
{
|
||||
MessageBox.Show("Please input an integer for the number of floors between 1 to 10.", "Revit");
|
||||
floornumberTextBox.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -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>
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.Windows.Forms;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.DeleteObject.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Delete the elements that were selected
|
||||
/// </summary>
|
||||
public class DeleteObject
|
||||
{
|
||||
ThisApplication? m_app; //ThisDocument data for Macro
|
||||
|
||||
/// <summary>
|
||||
/// Ctro without parameter is not allowed
|
||||
/// </summary>
|
||||
private DeleteObject()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ctor with ThisDocument as
|
||||
/// </summary>
|
||||
/// <param name="hostApp">ThisDocument handler</param>
|
||||
public DeleteObject(ThisApplication App)
|
||||
{
|
||||
m_app = App;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run this sample
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
if (m_app == null)
|
||||
return;
|
||||
ICollection<ElementId> collection = m_app.ActiveUIDocument.Selection.GetElementIds();
|
||||
// check user selection
|
||||
if (collection.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Please select an object to delete.", "DeleteObject");
|
||||
return;
|
||||
}
|
||||
|
||||
bool error = true;
|
||||
try
|
||||
{
|
||||
error = true;
|
||||
|
||||
// delete selection
|
||||
IEnumerator e = collection.GetEnumerator();
|
||||
bool MoreValue = e.MoveNext();
|
||||
while (MoreValue)
|
||||
{
|
||||
m_app.ActiveUIDocument.Document.Delete(e.Current as ElementId);
|
||||
MoreValue = e.MoveNext();
|
||||
}
|
||||
|
||||
error = false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// if revit threw an exception, try to catch it
|
||||
foreach (ElementId id in collection)
|
||||
{
|
||||
m_app.ActiveUIDocument.Selection.GetElementIds().Add(id);
|
||||
}
|
||||
MessageBox.Show("Element(s) can't be deleted.", "DeleteObject");
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// if revit threw an exception, display error and return failed
|
||||
if (error)
|
||||
{
|
||||
MessageBox.Show("Deletion failed.");
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
+455
@@ -0,0 +1,455 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
|
||||
using Application = Autodesk.Revit.ApplicationServices.Application;
|
||||
|
||||
using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Data class which stores information for creating orthogonal grids
|
||||
/// </summary>
|
||||
public class CreateOrthogonalGridsData
|
||||
{
|
||||
#region Fields
|
||||
// X coordinate of origin
|
||||
private double m_xOrigin;
|
||||
// Y coordinate of origin
|
||||
private double m_yOrigin;
|
||||
// Spacing between horizontal grids
|
||||
private double m_xSpacing;
|
||||
// Spacing between vertical grids
|
||||
private double m_ySpacing;
|
||||
// Number of horizontal grids
|
||||
private uint m_xNumber;
|
||||
// Number of vertical grids
|
||||
private uint m_yNumber;
|
||||
// Bubble location of horizontal grids
|
||||
private BubbleLocation m_xBubbleLoc;
|
||||
// Bubble location of vertical grids
|
||||
private BubbleLocation m_yBubbleLoc;
|
||||
// Label of first horizontal grid
|
||||
private String? m_xFirstLabel;
|
||||
// Label of first vertical grid
|
||||
private String? m_yFirstLabel;
|
||||
// Array list contains all grid labels in current document
|
||||
private ArrayList m_labelsList;
|
||||
// Revit application
|
||||
private ThisApplication? m_thisApp;
|
||||
// Current display unit type
|
||||
ForgeTypeId? m_unit;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// X coordinate of origin
|
||||
/// </summary>
|
||||
public double XOrigin
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xOrigin;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xOrigin = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y coordinate of origin
|
||||
/// </summary>
|
||||
public double YOrigin
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_yOrigin;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_yOrigin = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spacing between horizontal grids
|
||||
/// </summary>
|
||||
public double XSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xSpacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xSpacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spacing between vertical grids
|
||||
/// </summary>
|
||||
public double YSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ySpacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_ySpacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of horizontal grids
|
||||
/// </summary>
|
||||
public uint XNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of vertical grids
|
||||
/// </summary>
|
||||
public uint YNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_yNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_yNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bubble location of horizontal grids
|
||||
/// </summary>
|
||||
public BubbleLocation XBubbleLoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xBubbleLoc;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xBubbleLoc = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bubble location of vertical grids
|
||||
/// </summary>
|
||||
public BubbleLocation YBubbleLoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_yBubbleLoc;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_yBubbleLoc = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Label of first horizontal grid
|
||||
/// </summary>
|
||||
public String XFirstLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xFirstLabel == null ? string.Empty : m_xFirstLabel;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xFirstLabel = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Label of first vertical grid
|
||||
/// </summary>
|
||||
public String YFirstLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_yFirstLabel == null ? string.Empty : m_yFirstLabel;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_yFirstLabel = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get array list contains all grid labels in current document
|
||||
/// </summary>
|
||||
public ArrayList LabelsList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_labelsList;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current display unit type
|
||||
/// </summary>
|
||||
public ForgeTypeId? Unit
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_unit;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="application">Application object</param>
|
||||
/// <param name="unit">Current length display unit type</param>
|
||||
/// <param name="labels">All existing labels in Revit's document</param>
|
||||
public CreateOrthogonalGridsData(ThisApplication? thisApp, ForgeTypeId? unit, ArrayList labels)
|
||||
{
|
||||
m_thisApp = thisApp;
|
||||
m_labelsList = labels;
|
||||
m_unit = unit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create grids
|
||||
/// </summary>
|
||||
public void CreateGrids()
|
||||
{
|
||||
ArrayList failureReasons = new ArrayList();
|
||||
if (CreateXGrids(ref failureReasons) + CreateYGrids(ref failureReasons) != 0)
|
||||
{
|
||||
String? failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToCreateGrids");
|
||||
if (failureReasons.Count != 0)
|
||||
{
|
||||
failureReason += SamplePropertis.GridCreationResources.ResourceManager.GetString("Reasons") + "\r";
|
||||
failureReason += "\r";
|
||||
foreach (String reason in failureReasons)
|
||||
{
|
||||
failureReason += reason + "\r";
|
||||
}
|
||||
}
|
||||
|
||||
failureReason += "\r" + SamplePropertis.GridCreationResources.ResourceManager.GetString("AjustValues");
|
||||
|
||||
MessageBox.Show(failureReason,
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionCreateGrids"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create horizontal grids
|
||||
/// </summary>
|
||||
/// <param name="failureReasons">ArrayList contains failure reasons</param>
|
||||
/// <returns>Number of grids failed to create</returns>
|
||||
private int CreateXGrids(ref ArrayList failureReasons)
|
||||
{
|
||||
int errorCount = 0;
|
||||
|
||||
for (int i = 0; i < m_xNumber; ++i)
|
||||
{
|
||||
XYZ? startPoint;
|
||||
XYZ? endPoint;
|
||||
Line line;
|
||||
Grid grid;
|
||||
|
||||
try
|
||||
{
|
||||
if (m_yNumber != 0)
|
||||
{
|
||||
// Grids will have an extension distance of m_ySpacing / 2
|
||||
startPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin - m_ySpacing / 2, m_yOrigin + i * m_xSpacing, 0);
|
||||
endPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + (m_yNumber - 1) * m_ySpacing + m_ySpacing / 2, m_yOrigin + i * m_xSpacing, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
startPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin, m_yOrigin + i * m_xSpacing, 0);
|
||||
endPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + m_xSpacing / 2, m_yOrigin + i * m_xSpacing, 0);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Create a line according to the bubble location
|
||||
if (m_xBubbleLoc == BubbleLocation.StartPoint)
|
||||
{
|
||||
line = Line.CreateBound(startPoint, endPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
line = Line.CreateBound(endPoint, startPoint);
|
||||
}
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
String? failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("SpacingsTooSmall");
|
||||
if (!failureReasons.Contains(failureReason))
|
||||
{
|
||||
failureReasons.Add(failureReason);
|
||||
}
|
||||
errorCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create grid with line
|
||||
grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, line);
|
||||
|
||||
// Set label of first horizontal grid
|
||||
if (grid != null && i == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
grid.Name = m_xFirstLabel;
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_xFirstLabel + "!",
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
++errorCount;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return errorCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create vertical grids
|
||||
/// </summary>
|
||||
/// <param name="failureReasons">ArrayList contains failure reasons</param>
|
||||
/// <returns>Number of grids failed to create</returns>
|
||||
private int CreateYGrids(ref ArrayList failureReasons)
|
||||
{
|
||||
int errorCount = 0;
|
||||
|
||||
for (int j = 0; j < m_yNumber; ++j)
|
||||
{
|
||||
XYZ? startPoint;
|
||||
XYZ? endPoint;
|
||||
Line line;
|
||||
Grid grid;
|
||||
|
||||
try
|
||||
{
|
||||
if (m_xNumber != 0)
|
||||
{
|
||||
startPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + j * m_ySpacing, m_yOrigin - m_xSpacing / 2, 0);
|
||||
endPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + j * m_ySpacing, m_yOrigin + (m_xNumber - 1) * m_xSpacing + m_xSpacing / 2, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
startPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + j * m_ySpacing, m_yOrigin, 0);
|
||||
endPoint = m_thisApp?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + j * m_ySpacing, m_yOrigin + m_ySpacing / 2, 0);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Create a line according to the bubble location
|
||||
if (m_yBubbleLoc == BubbleLocation.StartPoint)
|
||||
{
|
||||
line = Line.CreateBound(startPoint, endPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
line = Line.CreateBound(endPoint, startPoint);
|
||||
}
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
String? failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("SpacingsTooSmall");
|
||||
if (!failureReasons.Contains(failureReason))
|
||||
{
|
||||
failureReasons.Add(failureReason);
|
||||
}
|
||||
errorCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create grid with line
|
||||
grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, line);
|
||||
|
||||
// Set label of first vertical grid
|
||||
if (grid != null && j == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
grid.Name = m_yFirstLabel;
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_yFirstLabel + "!",
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
++errorCount;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return errorCount;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+425
@@ -0,0 +1,425 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.GridCreation.CS
|
||||
{
|
||||
partial class CreateOrthogonalGridsForm
|
||||
{
|
||||
/// <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.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.labelYCoordUnit = new System.Windows.Forms.Label();
|
||||
this.labelXCoordUnit = new System.Windows.Forms.Label();
|
||||
this.textBoxYCoord = new System.Windows.Forms.TextBox();
|
||||
this.textBoxXCoord = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.textBoxYNumber = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.textBoxXNumber = new System.Windows.Forms.TextBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.labelUnitY = new System.Windows.Forms.Label();
|
||||
this.textBoxYSpacing = new System.Windows.Forms.TextBox();
|
||||
this.textBoxYFirstLabel = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxYBubbleLocation = new System.Windows.Forms.ComboBox();
|
||||
this.label10 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label9 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.labelUnitX = new System.Windows.Forms.Label();
|
||||
this.textBoxXSpacing = new System.Windows.Forms.TextBox();
|
||||
this.textBoxXFirstLabel = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxXBubbleLocation = new System.Windows.Forms.ComboBox();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.labelYCoordUnit);
|
||||
this.groupBox1.Controls.Add(this.labelXCoordUnit);
|
||||
this.groupBox1.Controls.Add(this.textBoxYCoord);
|
||||
this.groupBox1.Controls.Add(this.textBoxXCoord);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(13, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(520, 55);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Origin of the Grids";
|
||||
//
|
||||
// labelYCoordUnit
|
||||
//
|
||||
this.labelYCoordUnit.Location = new System.Drawing.Point(484, 23);
|
||||
this.labelYCoordUnit.Name = "labelYCoordUnit";
|
||||
this.labelYCoordUnit.Size = new System.Drawing.Size(23, 13);
|
||||
this.labelYCoordUnit.TabIndex = 7;
|
||||
//
|
||||
// labelXCoordUnit
|
||||
//
|
||||
this.labelXCoordUnit.Location = new System.Drawing.Point(227, 23);
|
||||
this.labelXCoordUnit.Name = "labelXCoordUnit";
|
||||
this.labelXCoordUnit.Size = new System.Drawing.Size(23, 13);
|
||||
this.labelXCoordUnit.TabIndex = 7;
|
||||
//
|
||||
// textBoxYCoord
|
||||
//
|
||||
this.textBoxYCoord.Location = new System.Drawing.Point(385, 20);
|
||||
this.textBoxYCoord.Name = "textBoxYCoord";
|
||||
this.textBoxYCoord.Size = new System.Drawing.Size(98, 20);
|
||||
this.textBoxYCoord.TabIndex = 1;
|
||||
this.textBoxYCoord.Tag = "0";
|
||||
this.textBoxYCoord.Text = "0";
|
||||
//
|
||||
// textBoxXCoord
|
||||
//
|
||||
this.textBoxXCoord.Location = new System.Drawing.Point(109, 20);
|
||||
this.textBoxXCoord.Name = "textBoxXCoord";
|
||||
this.textBoxXCoord.Size = new System.Drawing.Size(112, 20);
|
||||
this.textBoxXCoord.TabIndex = 0;
|
||||
this.textBoxXCoord.Tag = "0";
|
||||
this.textBoxXCoord.Text = "0";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.Location = new System.Drawing.Point(261, 24);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(122, 13);
|
||||
this.label2.TabIndex = 0;
|
||||
this.label2.Text = "Y coordinate:";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Location = new System.Drawing.Point(7, 24);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(95, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "X coordinate:";
|
||||
//
|
||||
// textBoxYNumber
|
||||
//
|
||||
this.textBoxYNumber.Location = new System.Drawing.Point(385, 24);
|
||||
this.textBoxYNumber.Name = "textBoxYNumber";
|
||||
this.textBoxYNumber.Size = new System.Drawing.Size(120, 20);
|
||||
this.textBoxYNumber.TabIndex = 1;
|
||||
this.textBoxYNumber.Tag = "3";
|
||||
this.textBoxYNumber.Text = "3";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.Location = new System.Drawing.Point(261, 27);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(122, 13);
|
||||
this.label3.TabIndex = 7;
|
||||
this.label3.Text = "Number:";
|
||||
//
|
||||
// textBoxXNumber
|
||||
//
|
||||
this.textBoxXNumber.Location = new System.Drawing.Point(385, 23);
|
||||
this.textBoxXNumber.Name = "textBoxXNumber";
|
||||
this.textBoxXNumber.Size = new System.Drawing.Size(120, 20);
|
||||
this.textBoxXNumber.TabIndex = 1;
|
||||
this.textBoxXNumber.Tag = "3";
|
||||
this.textBoxXNumber.Text = "3";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.labelUnitY);
|
||||
this.groupBox2.Controls.Add(this.textBoxYNumber);
|
||||
this.groupBox2.Controls.Add(this.textBoxYSpacing);
|
||||
this.groupBox2.Controls.Add(this.textBoxYFirstLabel);
|
||||
this.groupBox2.Controls.Add(this.label3);
|
||||
this.groupBox2.Controls.Add(this.comboBoxYBubbleLocation);
|
||||
this.groupBox2.Controls.Add(this.label10);
|
||||
this.groupBox2.Controls.Add(this.label5);
|
||||
this.groupBox2.Controls.Add(this.label9);
|
||||
this.groupBox2.Location = new System.Drawing.Point(14, 165);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(519, 85);
|
||||
this.groupBox2.TabIndex = 2;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Y direction Grids";
|
||||
//
|
||||
// labelUnitY
|
||||
//
|
||||
this.labelUnitY.Location = new System.Drawing.Point(227, 26);
|
||||
this.labelUnitY.Name = "labelUnitY";
|
||||
this.labelUnitY.Size = new System.Drawing.Size(23, 13);
|
||||
this.labelUnitY.TabIndex = 7;
|
||||
//
|
||||
// textBoxYSpacing
|
||||
//
|
||||
this.textBoxYSpacing.Location = new System.Drawing.Point(110, 24);
|
||||
this.textBoxYSpacing.Name = "textBoxYSpacing";
|
||||
this.textBoxYSpacing.Size = new System.Drawing.Size(112, 20);
|
||||
this.textBoxYSpacing.TabIndex = 0;
|
||||
this.textBoxYSpacing.Tag = "10.0";
|
||||
this.textBoxYSpacing.Text = "10.0";
|
||||
//
|
||||
// textBoxYFirstLabel
|
||||
//
|
||||
this.textBoxYFirstLabel.Location = new System.Drawing.Point(385, 53);
|
||||
this.textBoxYFirstLabel.Name = "textBoxYFirstLabel";
|
||||
this.textBoxYFirstLabel.Size = new System.Drawing.Size(120, 20);
|
||||
this.textBoxYFirstLabel.TabIndex = 3;
|
||||
this.textBoxYFirstLabel.Tag = "A";
|
||||
this.textBoxYFirstLabel.Text = "A";
|
||||
//
|
||||
// comboBoxYBubbleLocation
|
||||
//
|
||||
this.comboBoxYBubbleLocation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxYBubbleLocation.FormattingEnabled = true;
|
||||
this.comboBoxYBubbleLocation.Items.AddRange(new object[] {
|
||||
"At start point of lines",
|
||||
"At end point of lines"});
|
||||
this.comboBoxYBubbleLocation.Location = new System.Drawing.Point(108, 53);
|
||||
this.comboBoxYBubbleLocation.Name = "comboBoxYBubbleLocation";
|
||||
this.comboBoxYBubbleLocation.Size = new System.Drawing.Size(146, 21);
|
||||
this.comboBoxYBubbleLocation.TabIndex = 2;
|
||||
//
|
||||
// label10
|
||||
//
|
||||
this.label10.Location = new System.Drawing.Point(7, 55);
|
||||
this.label10.Name = "label10";
|
||||
this.label10.Size = new System.Drawing.Size(95, 13);
|
||||
this.label10.TabIndex = 6;
|
||||
this.label10.Text = "Bubble location:";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.Location = new System.Drawing.Point(6, 26);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(95, 13);
|
||||
this.label5.TabIndex = 7;
|
||||
this.label5.Text = "Spacing:";
|
||||
//
|
||||
// label9
|
||||
//
|
||||
this.label9.Location = new System.Drawing.Point(261, 55);
|
||||
this.label9.Name = "label9";
|
||||
this.label9.Size = new System.Drawing.Size(122, 13);
|
||||
this.label9.TabIndex = 6;
|
||||
this.label9.Text = "Label of first grid:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.Location = new System.Drawing.Point(261, 26);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(122, 13);
|
||||
this.label4.TabIndex = 6;
|
||||
this.label4.Text = "Number:";
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.labelUnitX);
|
||||
this.groupBox3.Controls.Add(this.textBoxXNumber);
|
||||
this.groupBox3.Controls.Add(this.textBoxXSpacing);
|
||||
this.groupBox3.Controls.Add(this.textBoxXFirstLabel);
|
||||
this.groupBox3.Controls.Add(this.comboBoxXBubbleLocation);
|
||||
this.groupBox3.Controls.Add(this.label6);
|
||||
this.groupBox3.Controls.Add(this.label7);
|
||||
this.groupBox3.Controls.Add(this.label4);
|
||||
this.groupBox3.Controls.Add(this.label8);
|
||||
this.groupBox3.Location = new System.Drawing.Point(13, 73);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(520, 86);
|
||||
this.groupBox3.TabIndex = 1;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "X direction Grids";
|
||||
//
|
||||
// labelUnitX
|
||||
//
|
||||
this.labelUnitX.Location = new System.Drawing.Point(227, 25);
|
||||
this.labelUnitX.Name = "labelUnitX";
|
||||
this.labelUnitX.Size = new System.Drawing.Size(23, 13);
|
||||
this.labelUnitX.TabIndex = 7;
|
||||
//
|
||||
// textBoxXSpacing
|
||||
//
|
||||
this.textBoxXSpacing.Location = new System.Drawing.Point(109, 23);
|
||||
this.textBoxXSpacing.Name = "textBoxXSpacing";
|
||||
this.textBoxXSpacing.Size = new System.Drawing.Size(112, 20);
|
||||
this.textBoxXSpacing.TabIndex = 0;
|
||||
this.textBoxXSpacing.Tag = "10.0";
|
||||
this.textBoxXSpacing.Text = "10.0";
|
||||
//
|
||||
// textBoxXFirstLabel
|
||||
//
|
||||
this.textBoxXFirstLabel.Location = new System.Drawing.Point(385, 53);
|
||||
this.textBoxXFirstLabel.Name = "textBoxXFirstLabel";
|
||||
this.textBoxXFirstLabel.Size = new System.Drawing.Size(120, 20);
|
||||
this.textBoxXFirstLabel.TabIndex = 3;
|
||||
this.textBoxXFirstLabel.Tag = "";
|
||||
this.textBoxXFirstLabel.Text = "1";
|
||||
//
|
||||
// comboBoxXBubbleLocation
|
||||
//
|
||||
this.comboBoxXBubbleLocation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxXBubbleLocation.FormattingEnabled = true;
|
||||
this.comboBoxXBubbleLocation.Items.AddRange(new object[] {
|
||||
"At start point of lines",
|
||||
"At end point of lines"});
|
||||
this.comboBoxXBubbleLocation.Location = new System.Drawing.Point(108, 53);
|
||||
this.comboBoxXBubbleLocation.Name = "comboBoxXBubbleLocation";
|
||||
this.comboBoxXBubbleLocation.Size = new System.Drawing.Size(147, 21);
|
||||
this.comboBoxXBubbleLocation.TabIndex = 2;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.Location = new System.Drawing.Point(7, 25);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(95, 13);
|
||||
this.label6.TabIndex = 6;
|
||||
this.label6.Text = "Spacing:";
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.Location = new System.Drawing.Point(7, 55);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(95, 13);
|
||||
this.label7.TabIndex = 6;
|
||||
this.label7.Text = "Bubble location:";
|
||||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.Location = new System.Drawing.Point(261, 55);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(122, 13);
|
||||
this.label8.TabIndex = 6;
|
||||
this.label8.Text = "Label of first grid:";
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.buttonCreate.Location = new System.Drawing.Point(327, 269);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(94, 23);
|
||||
this.buttonCreate.TabIndex = 3;
|
||||
this.buttonCreate.Text = "Create &Grids";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(439, 269);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(94, 23);
|
||||
this.buttonCancel.TabIndex = 4;
|
||||
this.buttonCancel.Text = "&Cancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// CreateOrthogonalGridsForm
|
||||
//
|
||||
this.AcceptButton = this.buttonCreate;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.buttonCancel;
|
||||
this.ClientSize = new System.Drawing.Size(545, 304);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "CreateOrthogonalGridsForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Create Orthogonal Grids";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.groupBox3.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.TextBox textBoxYCoord;
|
||||
private System.Windows.Forms.TextBox textBoxXCoord;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox textBoxYNumber;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox textBoxXNumber;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
private System.Windows.Forms.TextBox textBoxXSpacing;
|
||||
private System.Windows.Forms.TextBox textBoxYSpacing;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.Label label8;
|
||||
private System.Windows.Forms.TextBox textBoxXFirstLabel;
|
||||
private System.Windows.Forms.ComboBox comboBoxXBubbleLocation;
|
||||
private System.Windows.Forms.Button buttonCreate;
|
||||
private System.Windows.Forms.Button buttonCancel;
|
||||
private System.Windows.Forms.TextBox textBoxYFirstLabel;
|
||||
private System.Windows.Forms.ComboBox comboBoxYBubbleLocation;
|
||||
private System.Windows.Forms.Label label10;
|
||||
private System.Windows.Forms.Label label9;
|
||||
private System.Windows.Forms.Label labelUnitY;
|
||||
private System.Windows.Forms.Label labelUnitX;
|
||||
private System.Windows.Forms.Label labelYCoordUnit;
|
||||
private System.Windows.Forms.Label labelXCoordUnit;
|
||||
}
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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 SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which provides the options of creating orthogonal grids
|
||||
/// </summary>
|
||||
public partial class CreateOrthogonalGridsForm : Form
|
||||
{
|
||||
// data class object
|
||||
private CreateOrthogonalGridsData m_data;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="data">Data class object</param>
|
||||
public CreateOrthogonalGridsForm(CreateOrthogonalGridsData data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
InitializeComponent();
|
||||
// Set state of controls
|
||||
InitializeControls();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set state of controls
|
||||
/// </summary>
|
||||
private void InitializeControls()
|
||||
{
|
||||
// Set length unit related labels
|
||||
if (m_data.Unit != null)
|
||||
{
|
||||
string? tmp = m_data.Unit.ToString();
|
||||
string tmp2 = string.Empty;
|
||||
if (tmp != null)
|
||||
tmp2 = tmp;
|
||||
String? unit = SamplePropertis.GridCreationResources.ResourceManager.GetString(tmp2);
|
||||
labelUnitX.Text = unit;
|
||||
labelUnitY.Text = unit;
|
||||
labelXCoordUnit.Text = unit;
|
||||
labelYCoordUnit.Text = unit;
|
||||
|
||||
|
||||
// Set spacing values
|
||||
textBoxXSpacing.Text = Unit.CovertFromAPI(m_data.Unit, 10).ToString();
|
||||
textBoxYSpacing.Text = textBoxXSpacing.Text;
|
||||
|
||||
// Set bubble locations to end point
|
||||
comboBoxXBubbleLocation.SelectedIndex = 1;
|
||||
comboBoxYBubbleLocation.SelectedIndex = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Check if input are validated
|
||||
if (ValidateValues())
|
||||
{
|
||||
// Transfer data back into data class
|
||||
SetData();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DialogResult = DialogResult.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transfer data back into data class
|
||||
/// </summary>
|
||||
private void SetData()
|
||||
{
|
||||
if (m_data.Unit != null)
|
||||
{
|
||||
m_data.XOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxXCoord.Text), m_data.Unit);
|
||||
m_data.YOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxYCoord.Text), m_data.Unit);
|
||||
m_data.XNumber = Convert.ToUInt32(textBoxXNumber.Text);
|
||||
m_data.YNumber = Convert.ToUInt32(textBoxYNumber.Text);
|
||||
|
||||
if (Convert.ToUInt32(textBoxXNumber.Text) != 0)
|
||||
{
|
||||
m_data.XSpacing = Unit.CovertToAPI(Convert.ToDouble(textBoxXSpacing.Text), m_data.Unit);
|
||||
m_data.XBubbleLoc = (BubbleLocation)comboBoxXBubbleLocation.SelectedIndex;
|
||||
m_data.XFirstLabel = textBoxXFirstLabel.Text;
|
||||
}
|
||||
|
||||
if (Convert.ToUInt32(textBoxYNumber.Text) != 0)
|
||||
{
|
||||
m_data.YSpacing = Unit.CovertToAPI(Convert.ToDouble(textBoxYSpacing.Text), m_data.Unit);
|
||||
m_data.YBubbleLoc = (BubbleLocation)comboBoxYBubbleLocation.SelectedIndex;
|
||||
m_data.YFirstLabel = textBoxYFirstLabel.Text;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if input are validated
|
||||
/// </summary>
|
||||
/// <returns>Whether input is validated</returns>
|
||||
private bool ValidateValues()
|
||||
{
|
||||
if (!Validation.ValidateNumbers(textBoxXNumber, textBoxYNumber))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Validation.ValidateCoord(textBoxXCoord) || !Validation.ValidateCoord(textBoxYCoord))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Convert.ToUInt32(textBoxXNumber.Text) != 0)
|
||||
{
|
||||
if (!Validation.ValidateLength(textBoxXSpacing, "Spacing", false) ||
|
||||
!Validation.ValidateLabel(textBoxXFirstLabel, m_data.LabelsList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Convert.ToUInt32(textBoxYNumber.Text) != 0)
|
||||
{
|
||||
if (!Validation.ValidateLength(textBoxYSpacing, "Spacing", false) ||
|
||||
!Validation.ValidateLabel(textBoxYFirstLabel, m_data.LabelsList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Convert.ToUInt32(textBoxXNumber.Text) != 0 && Convert.ToUInt32(textBoxYNumber.Text) != 0)
|
||||
{
|
||||
if (!Validation.ValidateLabels(textBoxXFirstLabel, textBoxYFirstLabel))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -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>
|
||||
+598
@@ -0,0 +1,598 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
|
||||
using Application = Autodesk.Revit.ApplicationServices.Application;
|
||||
|
||||
using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which provides the options of creating radial and arc grids
|
||||
/// </summary>
|
||||
public class CreateRadialAndArcGridsData
|
||||
{
|
||||
#region Fields
|
||||
// X coordinate of origin
|
||||
private double m_xOrigin;
|
||||
// Y coordinate of origin
|
||||
private double m_yOrigin;
|
||||
// Start degree of arc grids and radial grids
|
||||
private double m_startDegree;
|
||||
// End degree of arc grids and radial grids
|
||||
private double m_endDegree;
|
||||
// Spacing between arc grids
|
||||
private double m_arcSpacing;
|
||||
// Number of arc grids
|
||||
private uint m_arcNumber = 0;
|
||||
// Number of radial grids
|
||||
private uint m_lineNumber = 0;
|
||||
// Radius of first arc grid
|
||||
private double m_arcFirstRadius;
|
||||
// Distance from origin to start point
|
||||
private double m_LineFirstDistance;
|
||||
// Bubble location of arc grids
|
||||
private BubbleLocation m_arcFirstBubbleLoc;
|
||||
// Bubble location of radial grids
|
||||
private BubbleLocation m_lineFirstBubbleLoc;
|
||||
// Label of first arc grid
|
||||
private String m_arcFirstLabel = string.Empty;
|
||||
// Label of first radial grid
|
||||
private String m_lineFirstLabel = string.Empty;
|
||||
// Array list contains all grid labels in current document
|
||||
private ArrayList m_labelsList;
|
||||
// Revit application
|
||||
private ThisApplication? m_app;
|
||||
// Current display unit type
|
||||
ForgeTypeId? m_unit;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// X coordinate of origin
|
||||
/// </summary>
|
||||
public double XOrigin
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_xOrigin;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_xOrigin = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y coordinate of origin
|
||||
/// </summary>
|
||||
public double YOrigin
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_yOrigin;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_yOrigin = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start degree of arc grids and radial grids
|
||||
/// </summary>
|
||||
public double StartDegree
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_startDegree;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_startDegree = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// End degree of arc grids and radial grids
|
||||
/// </summary>
|
||||
public double EndDegree
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_endDegree;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_endDegree = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spacing between arc grids
|
||||
/// </summary>
|
||||
public double ArcSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_arcSpacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_arcSpacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of arc grids
|
||||
/// </summary>
|
||||
public uint ArcNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_arcNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_arcNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of radial grids
|
||||
/// </summary>
|
||||
public uint LineNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_lineNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_lineNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Radius of first arc grid
|
||||
/// </summary>
|
||||
public double ArcFirstRadius
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_arcFirstRadius;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_arcFirstRadius = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Distance from origin to start point
|
||||
/// </summary>
|
||||
public double LineFirstDistance
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LineFirstDistance;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_LineFirstDistance = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bubble location of arc grids
|
||||
/// </summary>
|
||||
public BubbleLocation ArcFirstBubbleLoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_arcFirstBubbleLoc;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_arcFirstBubbleLoc = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bubble location of radial grids
|
||||
/// </summary>
|
||||
public BubbleLocation LineFirstBubbleLoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_lineFirstBubbleLoc;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_lineFirstBubbleLoc = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Label of first arc grid
|
||||
/// </summary>
|
||||
public String ArcFirstLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_arcFirstLabel;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_arcFirstLabel = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Label of first radial grid
|
||||
/// </summary>
|
||||
public String LineFirstLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_lineFirstLabel;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_lineFirstLabel = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get array list contains all grid labels in current document
|
||||
/// </summary>
|
||||
public ArrayList LabelsList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_labelsList;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current display unit type
|
||||
/// </summary>
|
||||
public ForgeTypeId? Unit
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_unit;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="application">Application object</param>
|
||||
/// <param name="unit">Current length display unit type</param>
|
||||
/// <param name="labels">All existing labels in Revit's document</param>
|
||||
public CreateRadialAndArcGridsData(ThisApplication? app, ForgeTypeId? unit, ArrayList labels)
|
||||
{
|
||||
m_app = app;
|
||||
m_labelsList = labels;
|
||||
m_unit = unit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create grids
|
||||
/// </summary>
|
||||
public void CreateGrids()
|
||||
{
|
||||
if (CreateRadialGrids() != 0)
|
||||
{
|
||||
String failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToCreateRadialGrids") + "\r";
|
||||
failureReason += SamplePropertis.GridCreationResources.ResourceManager.GetString("AjustValues");
|
||||
|
||||
MessageBox.Show(failureReason,
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionCreateGrids"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
ArrayList failureReasons = new ArrayList();
|
||||
if (CreateArcGrids(ref failureReasons) != 0)
|
||||
{
|
||||
String failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToCreateArcGrids") +
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("Reasons") + "\r";
|
||||
if (failureReasons.Count != 0)
|
||||
{
|
||||
failureReason += "\r";
|
||||
foreach (String reason in failureReasons)
|
||||
{
|
||||
failureReason += reason + "\r";
|
||||
}
|
||||
}
|
||||
failureReason += "\r" + SamplePropertis.GridCreationResources.ResourceManager.GetString("AjustValues");
|
||||
|
||||
MessageBox.Show(failureReason,
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionCreateGrids"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create radial grids
|
||||
/// </summary>
|
||||
/// <returns>Number of grids failed to create</returns>
|
||||
private int CreateRadialGrids()
|
||||
{
|
||||
int errorCount = 0;
|
||||
|
||||
for (int i = 0; i < m_lineNumber; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
double angel;
|
||||
if (m_lineNumber == 1)
|
||||
{
|
||||
angel = (m_startDegree + m_endDegree) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The number of space between radial grids will be m_lineNumber if arc is a circle
|
||||
if (m_endDegree - m_startDegree == 2 * Values.PI)
|
||||
{
|
||||
angel = m_startDegree + i * (m_endDegree - m_startDegree) / m_lineNumber;
|
||||
}
|
||||
// The number of space between radial grids will be m_lineNumber-1 if arc is not a circle
|
||||
else
|
||||
{
|
||||
angel = m_startDegree + i * (m_endDegree - m_startDegree) / (m_lineNumber - 1);
|
||||
}
|
||||
}
|
||||
|
||||
XYZ? startPoint;
|
||||
XYZ? endPoint;
|
||||
double cos = Math.Cos(angel);
|
||||
double sin = Math.Sin(angel);
|
||||
|
||||
if (m_arcNumber != 0)
|
||||
{
|
||||
// Grids will have an extension distance of m_ySpacing / 2
|
||||
startPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + m_LineFirstDistance * cos, m_yOrigin + m_LineFirstDistance * sin, 0);
|
||||
endPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + (m_arcFirstRadius + (m_arcNumber - 1) * m_arcSpacing + m_arcSpacing / 2) * cos,
|
||||
m_yOrigin + (m_arcFirstRadius + (m_arcNumber - 1) * m_arcSpacing + m_arcSpacing / 2) * sin, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
startPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + m_LineFirstDistance * cos, m_yOrigin + m_LineFirstDistance * sin, 0);
|
||||
endPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin + (m_arcFirstRadius + 5) * cos, m_yOrigin + (m_arcFirstRadius + 5) * sin, 0);
|
||||
}
|
||||
|
||||
Line line;
|
||||
// Create a line according to the bubble location
|
||||
if (m_lineFirstBubbleLoc == BubbleLocation.StartPoint)
|
||||
{
|
||||
line = Line.CreateBound(startPoint, endPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
line = Line.CreateBound(endPoint, startPoint);
|
||||
}
|
||||
|
||||
// Create grid with line
|
||||
Grid grid = Grid.Create(m_app?.ActiveUIDocument.Document, line);
|
||||
|
||||
// Set label of first radial grid
|
||||
if (grid != null && i == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
grid.Name = m_lineFirstLabel;
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_lineFirstLabel + "!",
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
++errorCount;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return errorCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create Arc Grids
|
||||
/// </summary>
|
||||
/// <param name="failureReasons">ArrayList contains failure reasons</param>
|
||||
/// <returns>Number of grids failed to create</returns>
|
||||
private int CreateArcGrids(ref ArrayList failureReasons)
|
||||
{
|
||||
int errorCount = 0;
|
||||
|
||||
for (int i = 0; i < m_arcNumber; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
XYZ? origin = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(m_xOrigin, m_yOrigin, 0);
|
||||
double radius = m_arcFirstRadius + i * m_arcSpacing;
|
||||
|
||||
// In Revit UI user can select a circle to create a grid, but actually two grids
|
||||
// (One from 0 to 180 degree and the other from 180 degree to 360) will be created.
|
||||
// In RevitAPI using NewGrid method with a circle as its argument will raise an exception.
|
||||
// Therefore in this sample we will create two arcs from the upper and lower parts of the
|
||||
// circle, and then create two grids on the base of the two arcs to accord with UI.
|
||||
if (m_endDegree - m_startDegree == 2 * Values.PI) // Create circular grids
|
||||
{
|
||||
Grid? gridUpper = CreateArcGrid(origin, radius, 0, Values.PI, m_arcFirstBubbleLoc);
|
||||
if (gridUpper != null && i == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
gridUpper.Name = m_arcFirstLabel;
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_arcFirstLabel + "!",
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
CreateArcGrid(origin, radius, Values.PI, 2 * Values.PI, m_arcFirstBubbleLoc);
|
||||
}
|
||||
else // Create arc grids
|
||||
{
|
||||
// Each arc grid will has extension degree of 15 degree
|
||||
double extensionDegree = 15 * Values.DEGTORAD;
|
||||
Grid? grid;
|
||||
|
||||
if (m_lineNumber != 0)
|
||||
{
|
||||
// If the range of arc degree is too close to a circle, the arc grids will not have
|
||||
// extension degrees.
|
||||
// Also the room for bubble should be considered, so a room size of 3 * extensionDegree
|
||||
// is reserved here
|
||||
if (m_endDegree - m_startDegree < 2 * Values.PI - 3 * extensionDegree)
|
||||
{
|
||||
double startDegreeWithExtension = m_startDegree - extensionDegree;
|
||||
double endDegreeWithExtension = m_endDegree + extensionDegree;
|
||||
grid = CreateArcGrid(origin, radius, startDegreeWithExtension, endDegreeWithExtension, m_arcFirstBubbleLoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
grid = CreateArcGrid(origin, radius, m_startDegree, m_endDegree, m_arcFirstBubbleLoc);
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
String? failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("EndPointsTooClose");
|
||||
if (!failureReasons.Contains(failureReason))
|
||||
{
|
||||
failureReasons.Add(failureReason);
|
||||
}
|
||||
errorCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
grid = CreateArcGrid(origin, radius, m_startDegree, m_endDegree, m_arcFirstBubbleLoc);
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
String? failureReason = SamplePropertis.GridCreationResources.ResourceManager.GetString("EndPointsTooClose");
|
||||
if (!failureReasons.Contains(failureReason))
|
||||
{
|
||||
failureReasons.Add(failureReason);
|
||||
}
|
||||
errorCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (grid != null && i == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
grid.Name = m_arcFirstLabel;
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_arcFirstLabel + "!",
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
++errorCount;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return errorCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an arc grid with its origin, radius, start degree, end degree and bubble location
|
||||
/// </summary>
|
||||
/// <param name="origin">Arc grid's origin</param>
|
||||
/// <param name="radius">Arc grid's radius</param>
|
||||
/// <param name="startDegree">Arc grid's start degree</param>
|
||||
/// <param name="endDegree">Arc grid's end degree</param>
|
||||
/// <param name="bubLoc">Arc grid's Bubble location</param>
|
||||
/// <returns>The newly created grid</returns>
|
||||
private Grid? CreateArcGrid(XYZ? origin, double radius, double startDegree, double endDegree, BubbleLocation bubLoc)
|
||||
{
|
||||
// Get start point and end point of the arc and the middle point on the arc
|
||||
if (origin == null)
|
||||
return null;
|
||||
XYZ? startPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(origin.X + radius * Math.Cos(startDegree),
|
||||
origin.Y + radius * Math.Sin(startDegree), origin.Z);
|
||||
XYZ? midPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(origin.X + radius * Math.Cos((startDegree + endDegree) / 2),
|
||||
origin.Y + radius * Math.Sin((startDegree + endDegree) / 2), origin.Z);
|
||||
XYZ? endPoint = m_app?.ActiveUIDocument.Document.Application.Create.NewXYZ(origin.X + radius * Math.Cos(endDegree),
|
||||
origin.Y + radius * Math.Sin(endDegree), origin.Z);
|
||||
|
||||
Arc arc;
|
||||
|
||||
if (bubLoc == BubbleLocation.StartPoint)
|
||||
{
|
||||
arc = Arc.Create(startPoint, endPoint, midPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
arc = Arc.Create(endPoint, startPoint, midPoint);
|
||||
}
|
||||
|
||||
return Grid.Create(m_app?.ActiveUIDocument.Document, arc);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+546
@@ -0,0 +1,546 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which provides the options of creating radial and arc grids
|
||||
/// </summary>
|
||||
partial class CreateRadialAndArcGridsForm
|
||||
{
|
||||
/// <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.textBoxArcSpacing = new System.Windows.Forms.TextBox();
|
||||
this.labelspace = new System.Windows.Forms.Label();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.labelUnitFirstRadius = new System.Windows.Forms.Label();
|
||||
this.labelUnitX = new System.Windows.Forms.Label();
|
||||
this.textBoxArcFirstRadius = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxArcBubbleLocation = new System.Windows.Forms.ComboBox();
|
||||
this.labelradius = new System.Windows.Forms.Label();
|
||||
this.textBoxArcFirstLabel = new System.Windows.Forms.TextBox();
|
||||
this.textBoxArcNumber = new System.Windows.Forms.TextBox();
|
||||
this.labelfirstgrid = new System.Windows.Forms.Label();
|
||||
this.labelbubble = new System.Windows.Forms.Label();
|
||||
this.labelnumber = new System.Windows.Forms.Label();
|
||||
this.labelr_number = new System.Windows.Forms.Label();
|
||||
this.textBoxYCoord = new System.Windows.Forms.TextBox();
|
||||
this.textBoxXCoord = new System.Windows.Forms.TextBox();
|
||||
this.labely = new System.Windows.Forms.Label();
|
||||
this.labelx = new System.Windows.Forms.Label();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.labelUnitY = new System.Windows.Forms.Label();
|
||||
this.textBoxLineFirstDistance = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxLineBubbleLocation = new System.Windows.Forms.ComboBox();
|
||||
this.label1r_distance = new System.Windows.Forms.Label();
|
||||
this.textBoxLineNumber = new System.Windows.Forms.TextBox();
|
||||
this.textBoxLineFirstLabel = new System.Windows.Forms.TextBox();
|
||||
this.label1r_firstgrid = new System.Windows.Forms.Label();
|
||||
this.labelr_bubble = new System.Windows.Forms.Label();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.labelYCoordUnit = new System.Windows.Forms.Label();
|
||||
this.labelXCoordUnit = new System.Windows.Forms.Label();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.groupBox4 = new System.Windows.Forms.GroupBox();
|
||||
this.textBoxEndDegree = new System.Windows.Forms.TextBox();
|
||||
this.textBoxStartDegree = new System.Windows.Forms.TextBox();
|
||||
this.labelEndDegree = new System.Windows.Forms.Label();
|
||||
this.labelStartDegree = new System.Windows.Forms.Label();
|
||||
this.radioButtonCustomize = new System.Windows.Forms.RadioButton();
|
||||
this.radioButton360 = new System.Windows.Forms.RadioButton();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox4.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxArcSpacing
|
||||
//
|
||||
this.textBoxArcSpacing.Location = new System.Drawing.Point(132, 17);
|
||||
this.textBoxArcSpacing.Name = "textBoxArcSpacing";
|
||||
this.textBoxArcSpacing.Size = new System.Drawing.Size(108, 20);
|
||||
this.textBoxArcSpacing.TabIndex = 0;
|
||||
this.textBoxArcSpacing.Tag = "10.0";
|
||||
this.textBoxArcSpacing.Text = "10.0";
|
||||
//
|
||||
// labelspace
|
||||
//
|
||||
this.labelspace.Location = new System.Drawing.Point(13, 20);
|
||||
this.labelspace.Name = "labelspace";
|
||||
this.labelspace.Size = new System.Drawing.Size(113, 18);
|
||||
this.labelspace.TabIndex = 6;
|
||||
this.labelspace.Text = "Spacing:";
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.labelUnitFirstRadius);
|
||||
this.groupBox3.Controls.Add(this.labelUnitX);
|
||||
this.groupBox3.Controls.Add(this.textBoxArcFirstRadius);
|
||||
this.groupBox3.Controls.Add(this.comboBoxArcBubbleLocation);
|
||||
this.groupBox3.Controls.Add(this.labelradius);
|
||||
this.groupBox3.Controls.Add(this.textBoxArcFirstLabel);
|
||||
this.groupBox3.Controls.Add(this.textBoxArcNumber);
|
||||
this.groupBox3.Controls.Add(this.labelfirstgrid);
|
||||
this.groupBox3.Controls.Add(this.textBoxArcSpacing);
|
||||
this.groupBox3.Controls.Add(this.labelbubble);
|
||||
this.groupBox3.Controls.Add(this.labelnumber);
|
||||
this.groupBox3.Controls.Add(this.labelspace);
|
||||
this.groupBox3.Location = new System.Drawing.Point(12, 175);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(544, 116);
|
||||
this.groupBox3.TabIndex = 2;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "Arc Grids";
|
||||
//
|
||||
// labelUnitFirstRadius
|
||||
//
|
||||
this.labelUnitFirstRadius.Location = new System.Drawing.Point(240, 52);
|
||||
this.labelUnitFirstRadius.Name = "labelUnitFirstRadius";
|
||||
this.labelUnitFirstRadius.Size = new System.Drawing.Size(23, 23);
|
||||
this.labelUnitFirstRadius.TabIndex = 31;
|
||||
//
|
||||
// labelUnitX
|
||||
//
|
||||
this.labelUnitX.Location = new System.Drawing.Point(240, 20);
|
||||
this.labelUnitX.Name = "labelUnitX";
|
||||
this.labelUnitX.Size = new System.Drawing.Size(23, 23);
|
||||
this.labelUnitX.TabIndex = 13;
|
||||
//
|
||||
// textBoxArcFirstRadius
|
||||
//
|
||||
this.textBoxArcFirstRadius.Location = new System.Drawing.Point(132, 50);
|
||||
this.textBoxArcFirstRadius.Name = "textBoxArcFirstRadius";
|
||||
this.textBoxArcFirstRadius.Size = new System.Drawing.Size(108, 20);
|
||||
this.textBoxArcFirstRadius.TabIndex = 2;
|
||||
this.textBoxArcFirstRadius.Text = "10.0";
|
||||
//
|
||||
// comboBoxArcBubbleLocation
|
||||
//
|
||||
this.comboBoxArcBubbleLocation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxArcBubbleLocation.FormattingEnabled = true;
|
||||
this.comboBoxArcBubbleLocation.Items.AddRange(new object[] {
|
||||
"At start point of arcs",
|
||||
"At end point of arcs"});
|
||||
this.comboBoxArcBubbleLocation.Location = new System.Drawing.Point(133, 83);
|
||||
this.comboBoxArcBubbleLocation.Name = "comboBoxArcBubbleLocation";
|
||||
this.comboBoxArcBubbleLocation.Size = new System.Drawing.Size(373, 21);
|
||||
this.comboBoxArcBubbleLocation.TabIndex = 4;
|
||||
//
|
||||
// labelradius
|
||||
//
|
||||
this.labelradius.Location = new System.Drawing.Point(13, 52);
|
||||
this.labelradius.Name = "labelradius";
|
||||
this.labelradius.Size = new System.Drawing.Size(113, 18);
|
||||
this.labelradius.TabIndex = 7;
|
||||
this.labelradius.Text = "Radius of first grid:";
|
||||
//
|
||||
// textBoxArcFirstLabel
|
||||
//
|
||||
this.textBoxArcFirstLabel.Location = new System.Drawing.Point(398, 50);
|
||||
this.textBoxArcFirstLabel.Name = "textBoxArcFirstLabel";
|
||||
this.textBoxArcFirstLabel.Size = new System.Drawing.Size(108, 20);
|
||||
this.textBoxArcFirstLabel.TabIndex = 3;
|
||||
this.textBoxArcFirstLabel.Tag = "";
|
||||
this.textBoxArcFirstLabel.Text = "1";
|
||||
//
|
||||
// textBoxArcNumber
|
||||
//
|
||||
this.textBoxArcNumber.Location = new System.Drawing.Point(398, 17);
|
||||
this.textBoxArcNumber.Name = "textBoxArcNumber";
|
||||
this.textBoxArcNumber.Size = new System.Drawing.Size(108, 20);
|
||||
this.textBoxArcNumber.TabIndex = 1;
|
||||
this.textBoxArcNumber.Text = "3";
|
||||
//
|
||||
// labelfirstgrid
|
||||
//
|
||||
this.labelfirstgrid.Location = new System.Drawing.Point(279, 52);
|
||||
this.labelfirstgrid.Name = "labelfirstgrid";
|
||||
this.labelfirstgrid.Size = new System.Drawing.Size(113, 18);
|
||||
this.labelfirstgrid.TabIndex = 30;
|
||||
this.labelfirstgrid.Text = "Label of first grid:";
|
||||
//
|
||||
// labelbubble
|
||||
//
|
||||
this.labelbubble.Location = new System.Drawing.Point(13, 85);
|
||||
this.labelbubble.Name = "labelbubble";
|
||||
this.labelbubble.Size = new System.Drawing.Size(113, 18);
|
||||
this.labelbubble.TabIndex = 29;
|
||||
this.labelbubble.Text = "Bubble location:";
|
||||
//
|
||||
// labelnumber
|
||||
//
|
||||
this.labelnumber.Location = new System.Drawing.Point(279, 20);
|
||||
this.labelnumber.Name = "labelnumber";
|
||||
this.labelnumber.Size = new System.Drawing.Size(113, 18);
|
||||
this.labelnumber.TabIndex = 6;
|
||||
this.labelnumber.Text = "Number:";
|
||||
//
|
||||
// labelr_number
|
||||
//
|
||||
this.labelr_number.Location = new System.Drawing.Point(279, 23);
|
||||
this.labelr_number.Name = "labelr_number";
|
||||
this.labelr_number.Size = new System.Drawing.Size(113, 18);
|
||||
this.labelr_number.TabIndex = 6;
|
||||
this.labelr_number.Text = "Number:";
|
||||
//
|
||||
// textBoxYCoord
|
||||
//
|
||||
this.textBoxYCoord.Location = new System.Drawing.Point(398, 22);
|
||||
this.textBoxYCoord.Name = "textBoxYCoord";
|
||||
this.textBoxYCoord.Size = new System.Drawing.Size(108, 20);
|
||||
this.textBoxYCoord.TabIndex = 1;
|
||||
this.textBoxYCoord.Text = "0";
|
||||
//
|
||||
// textBoxXCoord
|
||||
//
|
||||
this.textBoxXCoord.Location = new System.Drawing.Point(132, 21);
|
||||
this.textBoxXCoord.Name = "textBoxXCoord";
|
||||
this.textBoxXCoord.Size = new System.Drawing.Size(108, 20);
|
||||
this.textBoxXCoord.TabIndex = 0;
|
||||
this.textBoxXCoord.Text = "0";
|
||||
//
|
||||
// labely
|
||||
//
|
||||
this.labely.Location = new System.Drawing.Point(279, 25);
|
||||
this.labely.Name = "labely";
|
||||
this.labely.Size = new System.Drawing.Size(113, 18);
|
||||
this.labely.TabIndex = 0;
|
||||
this.labely.Text = "Y coordinate:";
|
||||
//
|
||||
// labelx
|
||||
//
|
||||
this.labelx.Location = new System.Drawing.Point(13, 25);
|
||||
this.labelx.Name = "labelx";
|
||||
this.labelx.Size = new System.Drawing.Size(112, 18);
|
||||
this.labelx.TabIndex = 0;
|
||||
this.labelx.Text = "X coordinate:";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.labelUnitY);
|
||||
this.groupBox2.Controls.Add(this.textBoxLineFirstDistance);
|
||||
this.groupBox2.Controls.Add(this.comboBoxLineBubbleLocation);
|
||||
this.groupBox2.Controls.Add(this.label1r_distance);
|
||||
this.groupBox2.Controls.Add(this.textBoxLineNumber);
|
||||
this.groupBox2.Controls.Add(this.textBoxLineFirstLabel);
|
||||
this.groupBox2.Controls.Add(this.label1r_firstgrid);
|
||||
this.groupBox2.Controls.Add(this.labelr_number);
|
||||
this.groupBox2.Controls.Add(this.labelr_bubble);
|
||||
this.groupBox2.Location = new System.Drawing.Point(13, 297);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(543, 119);
|
||||
this.groupBox2.TabIndex = 3;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Radial Grids";
|
||||
//
|
||||
// labelUnitY
|
||||
//
|
||||
this.labelUnitY.Location = new System.Drawing.Point(508, 88);
|
||||
this.labelUnitY.Name = "labelUnitY";
|
||||
this.labelUnitY.Size = new System.Drawing.Size(23, 23);
|
||||
this.labelUnitY.TabIndex = 13;
|
||||
//
|
||||
// textBoxLineFirstDistance
|
||||
//
|
||||
this.textBoxLineFirstDistance.Location = new System.Drawing.Point(236, 86);
|
||||
this.textBoxLineFirstDistance.Name = "textBoxLineFirstDistance";
|
||||
this.textBoxLineFirstDistance.Size = new System.Drawing.Size(270, 20);
|
||||
this.textBoxLineFirstDistance.TabIndex = 3;
|
||||
this.textBoxLineFirstDistance.Text = "8.0";
|
||||
//
|
||||
// comboBoxLineBubbleLocation
|
||||
//
|
||||
this.comboBoxLineBubbleLocation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxLineBubbleLocation.FormattingEnabled = true;
|
||||
this.comboBoxLineBubbleLocation.Items.AddRange(new object[] {
|
||||
"At start point of lines",
|
||||
"At end point of lines"});
|
||||
this.comboBoxLineBubbleLocation.Location = new System.Drawing.Point(131, 54);
|
||||
this.comboBoxLineBubbleLocation.Name = "comboBoxLineBubbleLocation";
|
||||
this.comboBoxLineBubbleLocation.Size = new System.Drawing.Size(374, 21);
|
||||
this.comboBoxLineBubbleLocation.TabIndex = 2;
|
||||
//
|
||||
// label1r_distance
|
||||
//
|
||||
this.label1r_distance.Location = new System.Drawing.Point(6, 88);
|
||||
this.label1r_distance.Name = "label1r_distance";
|
||||
this.label1r_distance.Size = new System.Drawing.Size(224, 18);
|
||||
this.label1r_distance.TabIndex = 7;
|
||||
this.label1r_distance.Text = "Distance from origin to start point:";
|
||||
//
|
||||
// textBoxLineNumber
|
||||
//
|
||||
this.textBoxLineNumber.Location = new System.Drawing.Point(398, 23);
|
||||
this.textBoxLineNumber.Name = "textBoxLineNumber";
|
||||
this.textBoxLineNumber.Size = new System.Drawing.Size(108, 20);
|
||||
this.textBoxLineNumber.TabIndex = 1;
|
||||
this.textBoxLineNumber.Tag = "3";
|
||||
this.textBoxLineNumber.Text = "3";
|
||||
//
|
||||
// textBoxLineFirstLabel
|
||||
//
|
||||
this.textBoxLineFirstLabel.Location = new System.Drawing.Point(131, 20);
|
||||
this.textBoxLineFirstLabel.Name = "textBoxLineFirstLabel";
|
||||
this.textBoxLineFirstLabel.Size = new System.Drawing.Size(108, 20);
|
||||
this.textBoxLineFirstLabel.TabIndex = 0;
|
||||
this.textBoxLineFirstLabel.Tag = "A";
|
||||
this.textBoxLineFirstLabel.Text = "A";
|
||||
//
|
||||
// label1r_firstgrid
|
||||
//
|
||||
this.label1r_firstgrid.Location = new System.Drawing.Point(6, 23);
|
||||
this.label1r_firstgrid.Name = "label1r_firstgrid";
|
||||
this.label1r_firstgrid.Size = new System.Drawing.Size(119, 18);
|
||||
this.label1r_firstgrid.TabIndex = 30;
|
||||
this.label1r_firstgrid.Text = "Label of first grid:";
|
||||
//
|
||||
// labelr_bubble
|
||||
//
|
||||
this.labelr_bubble.Location = new System.Drawing.Point(6, 57);
|
||||
this.labelr_bubble.Name = "labelr_bubble";
|
||||
this.labelr_bubble.Size = new System.Drawing.Size(119, 18);
|
||||
this.labelr_bubble.TabIndex = 29;
|
||||
this.labelr_bubble.Text = "Bubble location:";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.textBoxYCoord);
|
||||
this.groupBox1.Controls.Add(this.labelYCoordUnit);
|
||||
this.groupBox1.Controls.Add(this.labelXCoordUnit);
|
||||
this.groupBox1.Controls.Add(this.textBoxXCoord);
|
||||
this.groupBox1.Controls.Add(this.labely);
|
||||
this.groupBox1.Controls.Add(this.labelx);
|
||||
this.groupBox1.Location = new System.Drawing.Point(13, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(543, 55);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Center of Arc Grids";
|
||||
//
|
||||
// labelYCoordUnit
|
||||
//
|
||||
this.labelYCoordUnit.Location = new System.Drawing.Point(508, 22);
|
||||
this.labelYCoordUnit.Name = "labelYCoordUnit";
|
||||
this.labelYCoordUnit.Size = new System.Drawing.Size(23, 23);
|
||||
this.labelYCoordUnit.TabIndex = 13;
|
||||
//
|
||||
// labelXCoordUnit
|
||||
//
|
||||
this.labelXCoordUnit.Location = new System.Drawing.Point(240, 24);
|
||||
this.labelXCoordUnit.Name = "labelXCoordUnit";
|
||||
this.labelXCoordUnit.Size = new System.Drawing.Size(23, 23);
|
||||
this.labelXCoordUnit.TabIndex = 13;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(463, 436);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(94, 23);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "&Cancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.buttonCreate.Location = new System.Drawing.Point(356, 436);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(94, 23);
|
||||
this.buttonCreate.TabIndex = 4;
|
||||
this.buttonCreate.Text = "Create &Grids";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
||||
//
|
||||
// groupBox4
|
||||
//
|
||||
this.groupBox4.Controls.Add(this.textBoxEndDegree);
|
||||
this.groupBox4.Controls.Add(this.textBoxStartDegree);
|
||||
this.groupBox4.Controls.Add(this.labelEndDegree);
|
||||
this.groupBox4.Controls.Add(this.labelStartDegree);
|
||||
this.groupBox4.Controls.Add(this.radioButtonCustomize);
|
||||
this.groupBox4.Controls.Add(this.radioButton360);
|
||||
this.groupBox4.Location = new System.Drawing.Point(13, 74);
|
||||
this.groupBox4.Name = "groupBox4";
|
||||
this.groupBox4.Size = new System.Drawing.Size(543, 95);
|
||||
this.groupBox4.TabIndex = 1;
|
||||
this.groupBox4.TabStop = false;
|
||||
this.groupBox4.Text = "Span of Grids";
|
||||
//
|
||||
// textBoxEndDegree
|
||||
//
|
||||
this.textBoxEndDegree.Location = new System.Drawing.Point(397, 62);
|
||||
this.textBoxEndDegree.Name = "textBoxEndDegree";
|
||||
this.textBoxEndDegree.Size = new System.Drawing.Size(108, 20);
|
||||
this.textBoxEndDegree.TabIndex = 3;
|
||||
this.textBoxEndDegree.Text = "360";
|
||||
//
|
||||
// textBoxStartDegree
|
||||
//
|
||||
this.textBoxStartDegree.Location = new System.Drawing.Point(131, 62);
|
||||
this.textBoxStartDegree.Name = "textBoxStartDegree";
|
||||
this.textBoxStartDegree.Size = new System.Drawing.Size(108, 20);
|
||||
this.textBoxStartDegree.TabIndex = 2;
|
||||
this.textBoxStartDegree.Text = "0";
|
||||
//
|
||||
// labelEndDegree
|
||||
//
|
||||
this.labelEndDegree.Location = new System.Drawing.Point(279, 64);
|
||||
this.labelEndDegree.Name = "labelEndDegree";
|
||||
this.labelEndDegree.Size = new System.Drawing.Size(113, 18);
|
||||
this.labelEndDegree.TabIndex = 2;
|
||||
this.labelEndDegree.Text = "End degree:";
|
||||
//
|
||||
// labelStartDegree
|
||||
//
|
||||
this.labelStartDegree.Location = new System.Drawing.Point(24, 64);
|
||||
this.labelStartDegree.Name = "labelStartDegree";
|
||||
this.labelStartDegree.Size = new System.Drawing.Size(101, 18);
|
||||
this.labelStartDegree.TabIndex = 2;
|
||||
this.labelStartDegree.Text = "Start degree:";
|
||||
//
|
||||
// radioButtonCustomize
|
||||
//
|
||||
this.radioButtonCustomize.Location = new System.Drawing.Point(9, 41);
|
||||
this.radioButtonCustomize.Name = "radioButtonCustomize";
|
||||
this.radioButtonCustomize.Size = new System.Drawing.Size(104, 24);
|
||||
this.radioButtonCustomize.TabIndex = 1;
|
||||
this.radioButtonCustomize.Text = "Customize";
|
||||
this.radioButtonCustomize.UseVisualStyleBackColor = true;
|
||||
this.radioButtonCustomize.CheckedChanged += new System.EventHandler(this.radioButtonCustomize_CheckedChanged);
|
||||
//
|
||||
// radioButton360
|
||||
//
|
||||
this.radioButton360.AutoSize = true;
|
||||
this.radioButton360.Checked = true;
|
||||
this.radioButton360.Location = new System.Drawing.Point(9, 20);
|
||||
this.radioButton360.Name = "radioButton360";
|
||||
this.radioButton360.Size = new System.Drawing.Size(79, 17);
|
||||
this.radioButton360.TabIndex = 0;
|
||||
this.radioButton360.TabStop = true;
|
||||
this.radioButton360.Text = "360 degree";
|
||||
this.radioButton360.UseVisualStyleBackColor = true;
|
||||
this.radioButton360.MouseClick += new System.Windows.Forms.MouseEventHandler(this.radioButton360_MouseClick);
|
||||
//
|
||||
// CreateRadialAndArcGridsForm
|
||||
//
|
||||
this.AcceptButton = this.buttonCreate;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.buttonCancel;
|
||||
this.ClientSize = new System.Drawing.Size(568, 466);
|
||||
this.Controls.Add(this.groupBox4);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "CreateRadialAndArcGridsForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Create Radial and Arc Grids";
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.groupBox3.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBox4.ResumeLayout(false);
|
||||
this.groupBox4.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox textBoxArcSpacing;
|
||||
private System.Windows.Forms.Label labelspace;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
private System.Windows.Forms.Label labelr_number;
|
||||
private System.Windows.Forms.TextBox textBoxYCoord;
|
||||
private System.Windows.Forms.TextBox textBoxXCoord;
|
||||
private System.Windows.Forms.Label labely;
|
||||
private System.Windows.Forms.Label labelx;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.TextBox textBoxLineNumber;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.TextBox textBoxArcNumber;
|
||||
private System.Windows.Forms.Button buttonCancel;
|
||||
private System.Windows.Forms.Button buttonCreate;
|
||||
private System.Windows.Forms.Label labelnumber;
|
||||
private System.Windows.Forms.GroupBox groupBox4;
|
||||
private System.Windows.Forms.TextBox textBoxEndDegree;
|
||||
private System.Windows.Forms.TextBox textBoxStartDegree;
|
||||
private System.Windows.Forms.Label labelEndDegree;
|
||||
private System.Windows.Forms.Label labelStartDegree;
|
||||
private System.Windows.Forms.RadioButton radioButtonCustomize;
|
||||
private System.Windows.Forms.RadioButton radioButton360;
|
||||
private System.Windows.Forms.TextBox textBoxArcFirstRadius;
|
||||
private System.Windows.Forms.Label labelradius;
|
||||
private System.Windows.Forms.TextBox textBoxLineFirstDistance;
|
||||
private System.Windows.Forms.Label label1r_distance;
|
||||
private System.Windows.Forms.ComboBox comboBoxArcBubbleLocation;
|
||||
private System.Windows.Forms.TextBox textBoxArcFirstLabel;
|
||||
private System.Windows.Forms.Label labelfirstgrid;
|
||||
private System.Windows.Forms.Label labelbubble;
|
||||
private System.Windows.Forms.ComboBox comboBoxLineBubbleLocation;
|
||||
private System.Windows.Forms.TextBox textBoxLineFirstLabel;
|
||||
private System.Windows.Forms.Label label1r_firstgrid;
|
||||
private System.Windows.Forms.Label labelr_bubble;
|
||||
private System.Windows.Forms.Label labelUnitX;
|
||||
private System.Windows.Forms.Label labelUnitY;
|
||||
private System.Windows.Forms.Label labelUnitFirstRadius;
|
||||
private System.Windows.Forms.Label labelYCoordUnit;
|
||||
private System.Windows.Forms.Label labelXCoordUnit;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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 SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
public partial class CreateRadialAndArcGridsForm : Form
|
||||
{
|
||||
// data class object
|
||||
private CreateRadialAndArcGridsData m_data;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="data">Data class object</param>
|
||||
public CreateRadialAndArcGridsForm(CreateRadialAndArcGridsData data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
InitializeComponent();
|
||||
// Set state of controls
|
||||
InitializeControls();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set state of controls
|
||||
/// </summary>
|
||||
private void InitializeControls()
|
||||
{
|
||||
// Set length unit related labels
|
||||
if (m_data.Unit != null)
|
||||
{
|
||||
string? tmp = m_data.Unit.ToString();
|
||||
string tmp2 = string.Empty;
|
||||
if (tmp != null)
|
||||
tmp2 = tmp;
|
||||
String? unit = SamplePropertis.GridCreationResources.ResourceManager.GetString(tmp2);
|
||||
labelUnitX.Text = unit;
|
||||
labelUnitY.Text = unit;
|
||||
labelUnitFirstRadius.Text = unit;
|
||||
labelXCoordUnit.Text = unit;
|
||||
labelYCoordUnit.Text = unit;
|
||||
|
||||
|
||||
// Set length values
|
||||
textBoxArcSpacing.Text = Unit.CovertFromAPI(m_data.Unit, 10).ToString();
|
||||
textBoxArcFirstRadius.Text = textBoxArcSpacing.Text;
|
||||
textBoxLineFirstDistance.Text = Unit.CovertFromAPI(m_data.Unit, 8).ToString();
|
||||
|
||||
radioButton360.Checked = true;
|
||||
radioButtonCustomize.Checked = false;
|
||||
labelStartDegree.Enabled = false;
|
||||
textBoxStartDegree.Enabled = false;
|
||||
labelEndDegree.Enabled = false;
|
||||
textBoxEndDegree.Enabled = false;
|
||||
comboBoxArcBubbleLocation.SelectedIndex = 1;
|
||||
comboBoxLineBubbleLocation.SelectedIndex = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void radioButtonCustomize_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
bool IsCustomize = radioButtonCustomize.Checked;
|
||||
labelStartDegree.Enabled = IsCustomize;
|
||||
textBoxStartDegree.Enabled = IsCustomize;
|
||||
labelEndDegree.Enabled = IsCustomize;
|
||||
textBoxEndDegree.Enabled = IsCustomize;
|
||||
}
|
||||
|
||||
private void radioButton360_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
radioButtonCustomize.Checked = !radioButton360.Checked;
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Check if input are validated
|
||||
if (ValidateValues())
|
||||
{
|
||||
// Transfer data back into data class
|
||||
SetData();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DialogResult = DialogResult.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transfer data back into data class
|
||||
/// </summary>
|
||||
private void SetData()
|
||||
{
|
||||
if (m_data.Unit != null)
|
||||
{
|
||||
m_data.XOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxXCoord.Text), m_data.Unit);
|
||||
m_data.YOrigin = Unit.CovertToAPI(Convert.ToDouble(textBoxYCoord.Text), m_data.Unit);
|
||||
|
||||
if (radioButton360.Checked)
|
||||
{
|
||||
m_data.StartDegree = 0;
|
||||
m_data.EndDegree = 2 * Values.PI;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data.StartDegree = Convert.ToDouble(textBoxStartDegree.Text) * Values.DEGTORAD;
|
||||
m_data.EndDegree = Convert.ToDouble(textBoxEndDegree.Text) * Values.DEGTORAD;
|
||||
}
|
||||
|
||||
m_data.ArcNumber = Convert.ToUInt32(textBoxArcNumber.Text);
|
||||
m_data.LineNumber = Convert.ToUInt32(textBoxLineNumber.Text);
|
||||
|
||||
|
||||
if (Convert.ToUInt32(textBoxArcNumber.Text) != 0)
|
||||
{
|
||||
m_data.ArcSpacing = Unit.CovertToAPI(Convert.ToDouble(textBoxArcSpacing.Text), m_data.Unit);
|
||||
m_data.ArcFirstRadius = Unit.CovertToAPI(Convert.ToDouble(textBoxArcFirstRadius.Text), m_data.Unit);
|
||||
m_data.ArcFirstBubbleLoc = (BubbleLocation)comboBoxArcBubbleLocation.SelectedIndex;
|
||||
m_data.ArcFirstLabel = textBoxArcFirstLabel.Text;
|
||||
}
|
||||
|
||||
if (Convert.ToUInt32(textBoxLineNumber.Text) != 0)
|
||||
{
|
||||
m_data.LineFirstDistance = Unit.CovertToAPI(Convert.ToDouble(textBoxLineFirstDistance.Text), m_data.Unit);
|
||||
m_data.LineFirstBubbleLoc = (BubbleLocation)comboBoxLineBubbleLocation.SelectedIndex;
|
||||
m_data.LineFirstLabel = textBoxLineFirstLabel.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if input are validated
|
||||
/// </summary>
|
||||
/// <returns>Whether input is validated</returns>
|
||||
private bool ValidateValues()
|
||||
{
|
||||
if (!Validation.ValidateNumbers(textBoxArcNumber, textBoxLineNumber))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Validation.ValidateCoord(textBoxXCoord) || !Validation.ValidateCoord(textBoxYCoord))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Convert.ToUInt32(textBoxArcNumber.Text) != 0)
|
||||
{
|
||||
if (!Validation.ValidateLength(textBoxArcSpacing, "Spacing", false) ||
|
||||
!Validation.ValidateLength(textBoxArcFirstRadius, "Radius", false) ||
|
||||
!Validation.ValidateLabel(textBoxArcFirstLabel, m_data.LabelsList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Convert.ToUInt32(textBoxLineNumber.Text) != 0)
|
||||
{
|
||||
if (!Validation.ValidateLength(textBoxLineFirstDistance, "Distance", true) ||
|
||||
!Validation.ValidateLabel(textBoxLineFirstLabel, m_data.LabelsList))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Convert.ToUInt32(textBoxArcNumber.Text) != 0 && Convert.ToUInt32(textBoxLineNumber.Text) != 0)
|
||||
{
|
||||
if (!Validation.ValidateLabels(textBoxArcFirstLabel, textBoxLineFirstLabel))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (radioButtonCustomize.Checked)
|
||||
{
|
||||
if (!Validation.ValidateDegrees(textBoxStartDegree, textBoxEndDegree))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -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>
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.GridCreation.CS
|
||||
{
|
||||
partial class CreateWithSelectedCurvesForm
|
||||
{
|
||||
/// <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.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.textBoxFirstLabel = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxBubbleLocation = new System.Windows.Forms.ComboBox();
|
||||
this.labelBubbleLocation = new System.Windows.Forms.Label();
|
||||
this.labelFirstLabel = new System.Windows.Forms.Label();
|
||||
this.groupBoxGridSettings = new System.Windows.Forms.GroupBox();
|
||||
this.checkBoxDeleteElements = new System.Windows.Forms.CheckBox();
|
||||
this.groupBoxGridSettings.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(232, 144);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(90, 23);
|
||||
this.buttonCancel.TabIndex = 1;
|
||||
this.buttonCancel.Text = "&Cancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.buttonOK.Location = new System.Drawing.Point(126, 144);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(90, 23);
|
||||
this.buttonOK.TabIndex = 0;
|
||||
this.buttonOK.Text = "Create &Grids";
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
|
||||
//
|
||||
// textBoxFirstLabel
|
||||
//
|
||||
this.textBoxFirstLabel.Location = new System.Drawing.Point(124, 53);
|
||||
this.textBoxFirstLabel.Name = "textBoxFirstLabel";
|
||||
this.textBoxFirstLabel.Size = new System.Drawing.Size(171, 20);
|
||||
this.textBoxFirstLabel.TabIndex = 1;
|
||||
this.textBoxFirstLabel.Tag = "";
|
||||
this.textBoxFirstLabel.Text = "1";
|
||||
//
|
||||
// comboBoxBubbleLocation
|
||||
//
|
||||
this.comboBoxBubbleLocation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxBubbleLocation.FormattingEnabled = true;
|
||||
this.comboBoxBubbleLocation.Items.AddRange(new object[] {
|
||||
"At start point of lines/arcs",
|
||||
"At end point of lines/arcs"});
|
||||
this.comboBoxBubbleLocation.Location = new System.Drawing.Point(124, 19);
|
||||
this.comboBoxBubbleLocation.Name = "comboBoxBubbleLocation";
|
||||
this.comboBoxBubbleLocation.Size = new System.Drawing.Size(171, 21);
|
||||
this.comboBoxBubbleLocation.TabIndex = 0;
|
||||
//
|
||||
// labelBubbleLocation
|
||||
//
|
||||
this.labelBubbleLocation.Location = new System.Drawing.Point(6, 21);
|
||||
this.labelBubbleLocation.Name = "labelBubbleLocation";
|
||||
this.labelBubbleLocation.Size = new System.Drawing.Size(112, 19);
|
||||
this.labelBubbleLocation.TabIndex = 16;
|
||||
this.labelBubbleLocation.Text = "Bubble location:";
|
||||
//
|
||||
// labelFirstLabel
|
||||
//
|
||||
this.labelFirstLabel.Location = new System.Drawing.Point(6, 56);
|
||||
this.labelFirstLabel.Name = "labelFirstLabel";
|
||||
this.labelFirstLabel.Size = new System.Drawing.Size(112, 19);
|
||||
this.labelFirstLabel.TabIndex = 15;
|
||||
this.labelFirstLabel.Text = "Label of first grid:";
|
||||
//
|
||||
// groupBoxGridSettings
|
||||
//
|
||||
this.groupBoxGridSettings.Controls.Add(this.checkBoxDeleteElements);
|
||||
this.groupBoxGridSettings.Controls.Add(this.labelBubbleLocation);
|
||||
this.groupBoxGridSettings.Controls.Add(this.textBoxFirstLabel);
|
||||
this.groupBoxGridSettings.Controls.Add(this.labelFirstLabel);
|
||||
this.groupBoxGridSettings.Controls.Add(this.comboBoxBubbleLocation);
|
||||
this.groupBoxGridSettings.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBoxGridSettings.Name = "groupBoxGridSettings";
|
||||
this.groupBoxGridSettings.Size = new System.Drawing.Size(310, 113);
|
||||
this.groupBoxGridSettings.TabIndex = 18;
|
||||
this.groupBoxGridSettings.TabStop = false;
|
||||
this.groupBoxGridSettings.Text = "Settings";
|
||||
//
|
||||
// checkBoxDeleteElements
|
||||
//
|
||||
this.checkBoxDeleteElements.AutoSize = true;
|
||||
this.checkBoxDeleteElements.Checked = true;
|
||||
this.checkBoxDeleteElements.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.checkBoxDeleteElements.Location = new System.Drawing.Point(9, 87);
|
||||
this.checkBoxDeleteElements.Name = "checkBoxDeleteElements";
|
||||
this.checkBoxDeleteElements.Size = new System.Drawing.Size(232, 17);
|
||||
this.checkBoxDeleteElements.TabIndex = 2;
|
||||
this.checkBoxDeleteElements.Text = "Delete the selected lines/arcs after creation";
|
||||
this.checkBoxDeleteElements.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// CreateWithSelectedCurvesForm
|
||||
//
|
||||
this.AcceptButton = this.buttonOK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.buttonCancel;
|
||||
this.ClientSize = new System.Drawing.Size(334, 177);
|
||||
this.Controls.Add(this.groupBoxGridSettings);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOK);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "CreateWithSelectedCurvesForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Create Grids with Lines/Arcs";
|
||||
this.groupBoxGridSettings.ResumeLayout(false);
|
||||
this.groupBoxGridSettings.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button buttonCancel;
|
||||
private System.Windows.Forms.Button buttonOK;
|
||||
private System.Windows.Forms.TextBox textBoxFirstLabel;
|
||||
private System.Windows.Forms.ComboBox comboBoxBubbleLocation;
|
||||
private System.Windows.Forms.Label labelBubbleLocation;
|
||||
private System.Windows.Forms.Label labelFirstLabel;
|
||||
private System.Windows.Forms.GroupBox groupBoxGridSettings;
|
||||
private System.Windows.Forms.CheckBox checkBoxDeleteElements;
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which provides the options of creating grids with selected lines/arcs
|
||||
/// </summary>
|
||||
public partial class CreateWithSelectedCurvesForm : Form
|
||||
{
|
||||
// data class object
|
||||
private CreateWithSelectedCurvesData m_data;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="data">Data class object</param>
|
||||
public CreateWithSelectedCurvesForm(CreateWithSelectedCurvesData data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
InitializeComponent();
|
||||
// Set state of controls
|
||||
InitializeControls();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set state of controls
|
||||
/// </summary>
|
||||
private void InitializeControls()
|
||||
{
|
||||
comboBoxBubbleLocation.SelectedIndex = 1;
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Check if input are validated
|
||||
if (ValidateValues())
|
||||
{
|
||||
// Transfer data back into data class
|
||||
SetData();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DialogResult = DialogResult.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if input are validated
|
||||
/// </summary>
|
||||
/// <returns>Whether input is validated</returns>
|
||||
private bool ValidateValues()
|
||||
{
|
||||
return Validation.ValidateLabel(textBoxFirstLabel, m_data.LabelsList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transfer data back into data class
|
||||
/// </summary>
|
||||
private void SetData()
|
||||
{
|
||||
m_data.BubbleLocation = (BubbleLocation)comboBoxBubbleLocation.SelectedIndex;
|
||||
m_data.FirstLabel = textBoxFirstLabel.Text;
|
||||
m_data.DeleteSelectedElements = checkBoxDeleteElements.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -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>
|
||||
+386
@@ -0,0 +1,386 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Macros;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using Application = Autodesk.Revit.ApplicationServices.Application;
|
||||
using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which provides the options of creating grids with selected lines/arcs
|
||||
/// </summary>
|
||||
public class CreateWithSelectedCurvesData
|
||||
{
|
||||
#region Fields
|
||||
// Selected curves in current document
|
||||
private CurveArray? m_selectedCurves;
|
||||
// Whether to delete selected lines/arc after creation
|
||||
private bool m_deleteSelectedElements;
|
||||
// Label of first grid
|
||||
private String m_firstLabel = string.Empty;
|
||||
// Bubble location of grids
|
||||
private BubbleLocation m_bubbleLocation;
|
||||
// Array list contains all grid labels in current document
|
||||
private ArrayList m_labelsList;
|
||||
// Revit application
|
||||
private ThisApplication? m_thisApp;
|
||||
private Application? m_revit;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Whether to delete selected lines/arc after creation
|
||||
/// </summary>
|
||||
public bool DeleteSelectedElements
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_deleteSelectedElements;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_deleteSelectedElements = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bubble location of grids
|
||||
/// </summary>
|
||||
public BubbleLocation BubbleLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bubbleLocation;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bubbleLocation = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Label of first grid
|
||||
/// </summary>
|
||||
public String FirstLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_firstLabel;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_firstLabel = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get array list contains all grid labels in current document
|
||||
/// </summary>
|
||||
public ArrayList LabelsList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_labelsList;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="application">Revit application</param>
|
||||
/// <param name="selectedCurves">Array contains geometry curves of selected lines or arcs </param>
|
||||
/// <param name="labels">List contains all existing labels in Revit document</param>
|
||||
public CreateWithSelectedCurvesData(ThisApplication? thisApp, CurveArray? selectedCurves, ArrayList labels)
|
||||
{
|
||||
m_thisApp = thisApp;
|
||||
m_revit = thisApp?.ActiveUIDocument.Document.Application;
|
||||
|
||||
m_selectedCurves = selectedCurves;
|
||||
m_labelsList = labels;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create grids
|
||||
/// </summary>
|
||||
public void CreateGrids()
|
||||
{
|
||||
int errorCount = 0;
|
||||
|
||||
int i = 0;
|
||||
if (m_selectedCurves != null)
|
||||
{
|
||||
foreach (Curve curve in m_selectedCurves)
|
||||
{
|
||||
try
|
||||
{
|
||||
Line? line = curve as Line;
|
||||
if (line != null) // Selected curve is a line
|
||||
{
|
||||
Grid grid;
|
||||
// Create linear grid
|
||||
grid = CreateLinearGrid(line);
|
||||
|
||||
// Set label of first grid
|
||||
if (i == 0 && grid != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
grid.Name = m_firstLabel;
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_firstLabel + "!",
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Selected curve is an arc
|
||||
{
|
||||
Arc? arc = curve as Arc;
|
||||
if (arc != null)
|
||||
{
|
||||
if (arc.IsBound) // Part of a circle
|
||||
{
|
||||
Grid grid;
|
||||
// Create arc grid
|
||||
grid = CreateArcGrid(arc);
|
||||
|
||||
// Set label of first grid
|
||||
if (i == 0 && grid != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
grid.Name = m_firstLabel;
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_firstLabel + "!",
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Arc is a circle
|
||||
{
|
||||
// In Revit UI user can select a circle to create a grid, but actually two grids
|
||||
// (One from 0 to 180 degree and the other from 180 degree to 360) will be created.
|
||||
// In RevitAPI using NewGrid method with a circle as its argument will raise an exception.
|
||||
// Therefore in this sample we will create two arcs from the upper and lower parts of the
|
||||
// circle, and then create two grids on the base of the two arcs to accord with UI.
|
||||
Grid? gridUpper = null;
|
||||
Grid? gridLower = null;
|
||||
bool isFirstGrid = (i == 0);
|
||||
// Create grids
|
||||
CreateGridsForCircle(arc, ref gridUpper, ref gridLower, isFirstGrid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
++errorCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (m_deleteSelectedElements)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_thisApp?.ActiveUIDocument.Document.Delete(GridCreation.GetSelectedModelLinesAndArcs(m_thisApp));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToDeletedLinesOrArcs"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionDeletedLinesOrArcs"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
if (errorCount != 0)
|
||||
{
|
||||
MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToCreateGrids"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionCreateGrids"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create two grids if the selected curve is a circle
|
||||
/// </summary>
|
||||
/// <param name="arc">The circular curve to be transferred to grid</param>
|
||||
/// <param name="gridUpper">The grid to be created base on the upper part of the circular curve</param>
|
||||
/// <param name="gridLower">The grid to be created base on the lower part of the circular curve</param>
|
||||
/// <param name="isFirst">Whether the circular curve is the first curve to be transferred</param>
|
||||
private void CreateGridsForCircle(Arc arc, ref Grid? gridUpper, ref Grid? gridLower, bool isFirst)
|
||||
{
|
||||
XYZ center = arc.Center;
|
||||
double radius = arc.Radius;
|
||||
|
||||
XYZ? XRightPoint = m_revit?.Create.NewXYZ(center.X + radius, center.Y, 0);
|
||||
XYZ? XLeftPoint = m_revit?.Create.NewXYZ(center.X - radius, center.Y, 0);
|
||||
XYZ? YUpperPoint = m_revit?.Create.NewXYZ(center.X, center.Y + radius, 0);
|
||||
XYZ? YLowerPoint = m_revit?.Create.NewXYZ(center.X, center.Y - radius, 0);
|
||||
Arc upperArc;
|
||||
Arc lowerArc;
|
||||
if (m_bubbleLocation == BubbleLocation.StartPoint)
|
||||
{
|
||||
upperArc = Arc.Create(XRightPoint, XLeftPoint, YUpperPoint);
|
||||
lowerArc = Arc.Create(XLeftPoint, XRightPoint, YLowerPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
upperArc = Arc.Create(XLeftPoint, XRightPoint, YUpperPoint);
|
||||
lowerArc = Arc.Create(XRightPoint, XLeftPoint, YLowerPoint);
|
||||
}
|
||||
|
||||
// Create arc grids
|
||||
gridUpper = Grid.Create(m_thisApp?.ActiveUIDocument.Document, upperArc);
|
||||
gridLower = Grid.Create(m_thisApp?.ActiveUIDocument.Document, lowerArc);
|
||||
|
||||
if (gridUpper != null && isFirst)
|
||||
{
|
||||
try
|
||||
{
|
||||
gridUpper.Name = m_firstLabel;
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
MessageBox.Show(SamplePropertis.GridCreationResources.ResourceManager.GetString("FailedToSetLabel") + m_firstLabel + "!",
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionSetLabel"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create arc grid
|
||||
/// </summary>
|
||||
/// <param name="arc">The arc curve to be transferred to grid</param>
|
||||
/// <returns>The newly created grid</returns>
|
||||
private Grid CreateArcGrid(Arc arc)
|
||||
{
|
||||
Grid grid;
|
||||
|
||||
if (m_bubbleLocation == BubbleLocation.StartPoint)
|
||||
{
|
||||
grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, arc);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get start point, end point of the arc and the middle point on it
|
||||
XYZ startPoint = arc.GetEndPoint(0);
|
||||
XYZ endPoint = arc.GetEndPoint(1);
|
||||
bool clockwise = (arc.Normal.Z == -1);
|
||||
|
||||
// Get start angel and end angel of arc
|
||||
double startDegree = arc.GetEndParameter(0);
|
||||
double endDegree = arc.GetEndParameter(1);
|
||||
|
||||
// Handle the case that the arc is clockwise
|
||||
if (clockwise && startDegree > 0 && endDegree > 0)
|
||||
{
|
||||
startDegree = 2 * Values.PI - startDegree;
|
||||
endDegree = 2 * Values.PI - endDegree;
|
||||
}
|
||||
else if (clockwise && startDegree < 0)
|
||||
{
|
||||
double temp = endDegree;
|
||||
endDegree = -1 * startDegree;
|
||||
startDegree = -1 * temp;
|
||||
}
|
||||
|
||||
double sumDegree = (startDegree + endDegree) / 2;
|
||||
while (sumDegree > 2 * Values.PI)
|
||||
{
|
||||
sumDegree -= 2 * Values.PI;
|
||||
}
|
||||
|
||||
while (sumDegree < -2 * Values.PI)
|
||||
{
|
||||
sumDegree += 2 * Values.PI;
|
||||
}
|
||||
|
||||
XYZ? midPoint = m_revit?.Create.NewXYZ(arc.Center.X + arc.Radius * Math.Cos(sumDegree),
|
||||
arc.Center.Y + arc.Radius * Math.Sin(sumDegree), 0);
|
||||
Arc reversedArc = Arc.Create(endPoint, startPoint, midPoint);
|
||||
|
||||
//Create grid
|
||||
grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, reversedArc);
|
||||
}
|
||||
|
||||
return grid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create linear grid
|
||||
/// </summary>
|
||||
/// <param name="line">The linear curve to be transferred to grid</param>
|
||||
/// <returns>The newly created grid</returns>
|
||||
private Grid CreateLinearGrid(Line line)
|
||||
{
|
||||
Grid grid;
|
||||
|
||||
// Create grid according to the bubble location
|
||||
if (m_bubbleLocation == BubbleLocation.StartPoint)
|
||||
{
|
||||
grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, line);
|
||||
}
|
||||
else
|
||||
{
|
||||
XYZ startPoint = line.GetEndPoint(1);
|
||||
XYZ endPoint = line.GetEndPoint(0);
|
||||
Line reversedLine = Line.CreateBound(startPoint, endPoint);
|
||||
grid = Grid.Create(m_thisApp?.ActiveUIDocument.Document, reversedLine);
|
||||
}
|
||||
|
||||
return grid;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// An enumerate type listing the ways to create grids.
|
||||
/// </summary>
|
||||
public enum CreateMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Create grids with selected lines/arcs
|
||||
/// </summary>
|
||||
Select,
|
||||
/// <summary>
|
||||
/// Create orthogonal grids
|
||||
/// </summary>
|
||||
Orthogonal,
|
||||
/// <summary>
|
||||
/// Create radial and arc grids
|
||||
/// </summary>
|
||||
RadialAndArc
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An enumerate type listing bubble locations of grids.
|
||||
/// </summary>
|
||||
public enum BubbleLocation
|
||||
{
|
||||
/// <summary>
|
||||
/// Place bubble at the start point
|
||||
/// </summary>
|
||||
StartPoint,
|
||||
/// <summary>
|
||||
/// Place bubble at the end point
|
||||
/// </summary>
|
||||
EndPoint
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class contains common const values
|
||||
/// </summary>
|
||||
static class Values
|
||||
{
|
||||
public const double PI = 3.1415926535897900;
|
||||
// ratio from degree to radian
|
||||
public const double DEGTORAD = PI / 180;
|
||||
}
|
||||
}
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.Windows.Forms;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using Application = Autodesk.Revit.ApplicationServices.Application;
|
||||
using Element = Autodesk.Revit.DB.Element;
|
||||
|
||||
using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using System.Diagnostics;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the Revit add-in interface IExternalCommand
|
||||
/// </summary>
|
||||
public class GridCreation
|
||||
{
|
||||
#region
|
||||
ThisApplication? m_app;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor without parameter is not allowed
|
||||
/// </summary>
|
||||
private GridCreation()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GridCreation init
|
||||
/// </summary>
|
||||
/// <param name="hostApp"></param>
|
||||
public GridCreation(ThisApplication App)
|
||||
{
|
||||
m_app = App;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run this sample now
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
Document? document = m_app?.ActiveUIDocument.Document;
|
||||
|
||||
// Get all selected lines and arcs
|
||||
CurveArray? selectedCurves = GetSelectedCurves(m_app);
|
||||
|
||||
// Show UI
|
||||
GridCreationOptionData? gridCreationOption = new GridCreationOptionData(selectedCurves == null || selectedCurves.IsEmpty);
|
||||
using (GridCreationOptionForm gridCreationOptForm = new GridCreationOptionForm(gridCreationOption))
|
||||
{
|
||||
DialogResult result = gridCreationOptForm.ShowDialog();
|
||||
if (result == DialogResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList labels = GetAllLabelsOfGrids(document);
|
||||
ForgeTypeId? dut = GetLengthUnitType(document);
|
||||
switch (gridCreationOption.CreateGridsMode)
|
||||
{
|
||||
case CreateMode.Select: // Create grids with selected lines/arcs
|
||||
CreateWithSelectedCurvesData data = new CreateWithSelectedCurvesData(m_app, selectedCurves, labels);
|
||||
using (CreateWithSelectedCurvesForm createWithSelected = new CreateWithSelectedCurvesForm(data))
|
||||
{
|
||||
result = createWithSelected.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
// Create grids
|
||||
data.CreateGrids();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CreateMode.Orthogonal: // Create orthogonal grids
|
||||
CreateOrthogonalGridsData orthogonalData = new CreateOrthogonalGridsData(m_app, dut, labels);
|
||||
using (CreateOrthogonalGridsForm orthogonalGridForm = new CreateOrthogonalGridsForm(orthogonalData))
|
||||
{
|
||||
result = orthogonalGridForm.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
// Create grids
|
||||
orthogonalData.CreateGrids();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CreateMode.RadialAndArc: // Create radial and arc grids
|
||||
CreateRadialAndArcGridsData radArcData = new CreateRadialAndArcGridsData(m_app, dut, labels);
|
||||
using (CreateRadialAndArcGridsForm radArcForm = new CreateRadialAndArcGridsForm(radArcData))
|
||||
{
|
||||
result = radArcForm.ShowDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
// Create grids
|
||||
radArcData.CreateGrids();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all selected lines and arcs
|
||||
/// </summary>
|
||||
/// <param name="document">Revit's document</param>
|
||||
/// <returns>CurveArray contains all selected lines and arcs</returns>
|
||||
private CurveArray? GetSelectedCurves(ThisApplication? document)
|
||||
{
|
||||
CurveArray? selectedCurves = m_app?.ActiveUIDocument.Document.Application.Create.NewCurveArray();
|
||||
ICollection<ElementId>? elements = document?.ActiveUIDocument.Selection.GetElementIds();
|
||||
if (elements == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (Autodesk.Revit.DB.ElementId elementId in elements)
|
||||
{
|
||||
Element? element = document?.ActiveUIDocument.Document.GetElement(elementId);
|
||||
if ((element is ModelLine) || (element is ModelArc))
|
||||
{
|
||||
ModelCurve? modelCurve = element as ModelCurve;
|
||||
Curve? curve = modelCurve?.GeometryCurve;
|
||||
if (curve != null)
|
||||
{
|
||||
selectedCurves?.Append(curve);
|
||||
}
|
||||
}
|
||||
else if ((element is DetailLine) || (element is DetailArc))
|
||||
{
|
||||
DetailCurve? detailCurve = element as DetailCurve;
|
||||
Curve? curve = detailCurve?.GeometryCurve;
|
||||
if (curve != null)
|
||||
{
|
||||
selectedCurves?.Append(curve);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return selectedCurves;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all model and detail lines/arcs within selected elements
|
||||
/// </summary>
|
||||
/// <param name="document">Revit's document</param>
|
||||
/// <returns>ElementSet contains all model and detail lines/arcs within selected elements </returns>
|
||||
public static ICollection<ElementId> GetSelectedModelLinesAndArcs(ThisApplication thisDocument)
|
||||
{
|
||||
var tmpIds = new List<ElementId>();
|
||||
ICollection<ElementId> elements = thisDocument.ActiveUIDocument.Selection.GetElementIds();
|
||||
foreach (ElementId id in elements)
|
||||
{
|
||||
Element element = thisDocument.ActiveUIDocument.Document.GetElement(id);
|
||||
if ((element is ModelLine) || (element is ModelArc) || (element is DetailLine) || (element is DetailArc))
|
||||
{
|
||||
tmpIds.Add(element.Id);
|
||||
}
|
||||
}
|
||||
|
||||
return tmpIds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get current length display unit type
|
||||
/// </summary>
|
||||
/// <param name="document">Revit's document</param>
|
||||
/// <returns>Current length display unit type</returns>
|
||||
private static ForgeTypeId? GetLengthUnitType(Document? document)
|
||||
{
|
||||
ForgeTypeId specTypeId = SpecTypeId.Length;
|
||||
Units? projectUnit = document?.GetUnits();
|
||||
try
|
||||
{
|
||||
Autodesk.Revit.DB.FormatOptions? formatOption = projectUnit?.GetFormatOptions(specTypeId);
|
||||
return formatOption?.GetUnitTypeId();
|
||||
}
|
||||
catch (System.Exception /*e*/)
|
||||
{
|
||||
return UnitTypeId.Feet;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all grid labels in current document
|
||||
/// </summary>
|
||||
/// <param name="document">Revit's document</param>
|
||||
/// <returns>ArrayList contains all grid labels in current document</returns>
|
||||
private static ArrayList GetAllLabelsOfGrids(Document? document)
|
||||
{
|
||||
ArrayList labels = new ArrayList();
|
||||
|
||||
ElementClassFilter gridFilter = new ElementClassFilter(typeof(Grid));
|
||||
FilteredElementCollector collector = new FilteredElementCollector(document);
|
||||
collector.WherePasses(gridFilter);
|
||||
FilteredElementIterator iter = collector.GetElementIterator();
|
||||
|
||||
iter.Reset();
|
||||
while (iter.MoveNext())
|
||||
{
|
||||
Grid? grid = iter.Current as Grid;
|
||||
if (null != grid)
|
||||
{
|
||||
labels.Add(grid.Name);
|
||||
}
|
||||
}
|
||||
return labels;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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 Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Data class which stores the information of the way to create grids
|
||||
/// </summary>
|
||||
public class GridCreationOptionData
|
||||
{
|
||||
#region Fields
|
||||
// The way to create grids
|
||||
private CreateMode m_createGridsMode;
|
||||
// If lines/arcs have been selected
|
||||
private bool m_hasSelectedLinesOrArcs;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Creating mode
|
||||
/// </summary>
|
||||
public CreateMode CreateGridsMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_createGridsMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_createGridsMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// State whether lines/arcs have been selected
|
||||
/// </summary>
|
||||
public bool HasSelectedLinesOrArcs
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_hasSelectedLinesOrArcs;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="hasSelectedLinesOrArcs">Whether lines or arcs have been selected</param>
|
||||
public GridCreationOptionData(bool hasSelectedLinesOrArcs)
|
||||
{
|
||||
m_hasSelectedLinesOrArcs = hasSelectedLinesOrArcs;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.GridCreation.CS
|
||||
{
|
||||
partial class GridCreationOptionForm
|
||||
{
|
||||
/// <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.radioButtonSelect = new System.Windows.Forms.RadioButton();
|
||||
this.radioButtonRadialAndCircularGrids = new System.Windows.Forms.RadioButton();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.groupBoxCreateOptions = new System.Windows.Forms.GroupBox();
|
||||
this.radioButtonOrthogonalGrids = new System.Windows.Forms.RadioButton();
|
||||
this.groupBoxCreateOptions.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// radioButtonSelect
|
||||
//
|
||||
this.radioButtonSelect.AutoSize = true;
|
||||
this.radioButtonSelect.Checked = true;
|
||||
this.radioButtonSelect.Location = new System.Drawing.Point(6, 19);
|
||||
this.radioButtonSelect.Name = "radioButtonSelect";
|
||||
this.radioButtonSelect.Size = new System.Drawing.Size(205, 17);
|
||||
this.radioButtonSelect.TabIndex = 0;
|
||||
this.radioButtonSelect.TabStop = true;
|
||||
this.radioButtonSelect.Text = "Create grids with selected lines or arcs";
|
||||
this.radioButtonSelect.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// radioButtonRadialAndCircularGrids
|
||||
//
|
||||
this.radioButtonRadialAndCircularGrids.AutoSize = true;
|
||||
this.radioButtonRadialAndCircularGrids.Location = new System.Drawing.Point(6, 69);
|
||||
this.radioButtonRadialAndCircularGrids.Name = "radioButtonRadialAndCircularGrids";
|
||||
this.radioButtonRadialAndCircularGrids.Size = new System.Drawing.Size(199, 17);
|
||||
this.radioButtonRadialAndCircularGrids.TabIndex = 2;
|
||||
this.radioButtonRadialAndCircularGrids.Text = "Create a batch of radial and arc grids";
|
||||
this.radioButtonRadialAndCircularGrids.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(159, 129);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(90, 23);
|
||||
this.buttonCancel.TabIndex = 1;
|
||||
this.buttonCancel.Text = "&Cancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.buttonOK.Location = new System.Drawing.Point(58, 129);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(90, 23);
|
||||
this.buttonOK.TabIndex = 0;
|
||||
this.buttonOK.Text = "&OK";
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
|
||||
//
|
||||
// groupBoxCreateOptions
|
||||
//
|
||||
this.groupBoxCreateOptions.Controls.Add(this.radioButtonSelect);
|
||||
this.groupBoxCreateOptions.Controls.Add(this.radioButtonOrthogonalGrids);
|
||||
this.groupBoxCreateOptions.Controls.Add(this.radioButtonRadialAndCircularGrids);
|
||||
this.groupBoxCreateOptions.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBoxCreateOptions.Name = "groupBoxCreateOptions";
|
||||
this.groupBoxCreateOptions.Size = new System.Drawing.Size(237, 96);
|
||||
this.groupBoxCreateOptions.TabIndex = 13;
|
||||
this.groupBoxCreateOptions.TabStop = false;
|
||||
this.groupBoxCreateOptions.Text = "Choose the way to create grids";
|
||||
//
|
||||
// radioButtonOrthogonalGrids
|
||||
//
|
||||
this.radioButtonOrthogonalGrids.AutoSize = true;
|
||||
this.radioButtonOrthogonalGrids.Location = new System.Drawing.Point(6, 44);
|
||||
this.radioButtonOrthogonalGrids.Name = "radioButtonOrthogonalGrids";
|
||||
this.radioButtonOrthogonalGrids.Size = new System.Drawing.Size(185, 17);
|
||||
this.radioButtonOrthogonalGrids.TabIndex = 1;
|
||||
this.radioButtonOrthogonalGrids.Text = "Create a batch of orthogonal grids";
|
||||
this.radioButtonOrthogonalGrids.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// GridCreationOptionForm
|
||||
//
|
||||
this.AcceptButton = this.buttonOK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.buttonCancel;
|
||||
this.ClientSize = new System.Drawing.Size(265, 164);
|
||||
this.Controls.Add(this.groupBoxCreateOptions);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOK);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "GridCreationOptionForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Grid Creation";
|
||||
this.groupBoxCreateOptions.ResumeLayout(false);
|
||||
this.groupBoxCreateOptions.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.RadioButton radioButtonSelect;
|
||||
private System.Windows.Forms.RadioButton radioButtonRadialAndCircularGrids;
|
||||
private System.Windows.Forms.Button buttonCancel;
|
||||
private System.Windows.Forms.Button buttonOK;
|
||||
private System.Windows.Forms.GroupBox groupBoxCreateOptions;
|
||||
private System.Windows.Forms.RadioButton radioButtonOrthogonalGrids;
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog which lets user choose the way to create grids
|
||||
/// </summary>
|
||||
public partial class GridCreationOptionForm : Form
|
||||
{
|
||||
// data class object
|
||||
private GridCreationOptionData m_gridCreationOption;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="opt">Data class object</param>
|
||||
public GridCreationOptionForm(GridCreationOptionData opt)
|
||||
{
|
||||
m_gridCreationOption = opt;
|
||||
|
||||
InitializeComponent();
|
||||
// Set state of controls
|
||||
InitializeControls();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set state of controls
|
||||
/// </summary>
|
||||
private void InitializeControls()
|
||||
{
|
||||
if (!m_gridCreationOption.HasSelectedLinesOrArcs)
|
||||
{
|
||||
radioButtonSelect.Enabled = false;
|
||||
radioButtonOrthogonalGrids.Checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Transfer data back into data class
|
||||
SetData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transfer data back into data class
|
||||
/// </summary>
|
||||
private void SetData()
|
||||
{
|
||||
m_gridCreationOption.CreateGridsMode = radioButtonSelect.Checked ? CreateMode.Select :
|
||||
(radioButtonOrthogonalGrids.Checked ? CreateMode.Orthogonal : CreateMode.RadialAndArc);
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -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>
|
||||
+567
@@ -0,0 +1,567 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.832
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace MacroCSharpSamples.GridCreation.GridCreationProperties
|
||||
{
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class GridCreationResources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal GridCreationResources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MacroCSharpSamples.GridCreation.GridCreationProperties.GridCreationResources", typeof(GridCreationResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Please adjust the values and try again!.
|
||||
/// </summary>
|
||||
internal static string AjustValues
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("AjustValues", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Coordinate can not be null!.
|
||||
/// </summary>
|
||||
internal static string CoordinateCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("CoordinateCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Coordinate is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string CoordinateFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("CoordinateFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree can not be negative!.
|
||||
/// </summary>
|
||||
internal static string DegreeCannotBeNegative
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DegreeCannotBeNegative", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree can not be null!.
|
||||
/// </summary>
|
||||
internal static string DegreeCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DegreeCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string DegreeFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DegreeFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Start degree and end degree can not be so close!.
|
||||
/// </summary>
|
||||
internal static string DegreesAreTooClose
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DegreesAreTooClose", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree should be within the range of 0 - 360!.
|
||||
/// </summary>
|
||||
internal static string DegreeWithin0To360
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DegreeWithin0To360", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance can not be negative!.
|
||||
/// </summary>
|
||||
internal static string DistanceCannotBeNegative
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DistanceCannotBeNegative", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance can not be null!.
|
||||
/// </summary>
|
||||
internal static string DistanceCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DistanceCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string DistanceFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DistanceFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to cm.
|
||||
/// </summary>
|
||||
internal static string DUT_CENTIMETERS
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_CENTIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to '.
|
||||
/// </summary>
|
||||
internal static string DUT_DECIMAL_FEET
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_DECIMAL_FEET", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ".
|
||||
/// </summary>
|
||||
internal static string DUT_DECIMAL_INCHES
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_DECIMAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to '.
|
||||
/// </summary>
|
||||
internal static string DUT_FEET_FRACTIONAL_INCHES
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_FEET_FRACTIONAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ".
|
||||
/// </summary>
|
||||
internal static string DUT_FRACTIONAL_INCHES
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_FRACTIONAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to m.
|
||||
/// </summary>
|
||||
internal static string DUT_METERS
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_METERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to m.
|
||||
/// </summary>
|
||||
internal static string DUT_METERS_CENTIMETERS
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_METERS_CENTIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to mm.
|
||||
/// </summary>
|
||||
internal static string DUT_MILLIMETERS
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("DUT_MILLIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to - Start point and end point of arc grids are too close.
|
||||
/// </summary>
|
||||
internal static string EndPointsTooClose
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("EndPointsTooClose", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more arc grids..
|
||||
/// </summary>
|
||||
internal static string FailedToCreateArcGrids
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailedToCreateArcGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more grids. .
|
||||
/// </summary>
|
||||
internal static string FailedToCreateGrids
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailedToCreateGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more radial grids. .
|
||||
/// </summary>
|
||||
internal static string FailedToCreateRadialGrids
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailedToCreateRadialGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to delete some of the selected lines or arcs!.
|
||||
/// </summary>
|
||||
internal static string FailedToDeletedLinesOrArcs
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailedToDeletedLinesOrArcs", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to set label of grid to : .
|
||||
/// </summary>
|
||||
internal static string FailedToSetLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailedToSetLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Create Grids.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionCreateGrids
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailureCaptionCreateGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Delete Lines/Arcs.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionDeletedLinesOrArcs
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailureCaptionDeletedLinesOrArcs", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Invalid Value.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionInvalidValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailureCaptionInvalidValue", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Set Label.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionSetLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("FailureCaptionSetLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Label can not be null!.
|
||||
/// </summary>
|
||||
internal static string LabelCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("LabelCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A same label has already existed!.
|
||||
/// </summary>
|
||||
internal static string LabelExisted
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("LabelExisted", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The two labels can't be same!.
|
||||
/// </summary>
|
||||
internal static string LabelsCannotBeSame
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("LabelsCannotBeSame", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number should be an integer between 0 and 200!.
|
||||
/// </summary>
|
||||
internal static string NumberBetween0And200
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("NumberBetween0And200", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number can not be null!.
|
||||
/// </summary>
|
||||
internal static string NumberCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("NumberCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string NumberFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("NumberFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The two numbers can not be both zero!.
|
||||
/// </summary>
|
||||
internal static string NumbersCannotBeBothZero
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("NumbersCannotBeBothZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius can not be negative or zero!.
|
||||
/// </summary>
|
||||
internal static string RadiusCannotBeNegativeOrZero
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("RadiusCannotBeNegativeOrZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius can not be null!.
|
||||
/// </summary>
|
||||
internal static string RadiusCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("RadiusCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string RadiusFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("RadiusFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to That may be caused by one or more of following reasons:.
|
||||
/// </summary>
|
||||
internal static string Reasons
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("Reasons", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing can not be negative or zero!.
|
||||
/// </summary>
|
||||
internal static string SpacingCannotBeNegativeOrZero
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("SpacingCannotBeNegativeOrZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing can not be null!.
|
||||
/// </summary>
|
||||
internal static string SpacingCannotBeNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("SpacingCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string SpacingFormatWrong
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("SpacingFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to - Spacings between grids are too small.
|
||||
/// </summary>
|
||||
internal static string SpacingsTooSmall
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("SpacingsTooSmall", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Start degree should be less than end degree!.
|
||||
/// </summary>
|
||||
internal static string StartDegreeShouldBeLessThanEndDegree
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("StartDegreeShouldBeLessThanEndDegree", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+255
File diff suppressed because one or more lines are too long
+469
@@ -0,0 +1,469 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.832
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.Properties
|
||||
{
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MacroCSharpSamples.Samples.GridCreation.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Please adjust the values and try again!.
|
||||
/// </summary>
|
||||
internal static string AjustValues {
|
||||
get {
|
||||
return ResourceManager.GetString("AjustValues", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Coordinate can not be null!.
|
||||
/// </summary>
|
||||
internal static string CoordinateCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("CoordinateCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Coordinate is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string CoordinateFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("CoordinateFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree can not be negative!.
|
||||
/// </summary>
|
||||
internal static string DegreeCannotBeNegative {
|
||||
get {
|
||||
return ResourceManager.GetString("DegreeCannotBeNegative", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree can not be null!.
|
||||
/// </summary>
|
||||
internal static string DegreeCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("DegreeCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string DegreeFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("DegreeFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Start degree and end degree can not be so close!.
|
||||
/// </summary>
|
||||
internal static string DegreesAreTooClose {
|
||||
get {
|
||||
return ResourceManager.GetString("DegreesAreTooClose", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Degree should be within the range of 0 - 360!.
|
||||
/// </summary>
|
||||
internal static string DegreeWithin0To360 {
|
||||
get {
|
||||
return ResourceManager.GetString("DegreeWithin0To360", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance can not be negative!.
|
||||
/// </summary>
|
||||
internal static string DistanceCannotBeNegative {
|
||||
get {
|
||||
return ResourceManager.GetString("DistanceCannotBeNegative", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance can not be null!.
|
||||
/// </summary>
|
||||
internal static string DistanceCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("DistanceCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Distance is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string DistanceFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("DistanceFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to cm.
|
||||
/// </summary>
|
||||
internal static string DUT_CENTIMETERS {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_CENTIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to '.
|
||||
/// </summary>
|
||||
internal static string DUT_DECIMAL_FEET {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_DECIMAL_FEET", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ".
|
||||
/// </summary>
|
||||
internal static string DUT_DECIMAL_INCHES {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_DECIMAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to '.
|
||||
/// </summary>
|
||||
internal static string DUT_FEET_FRACTIONAL_INCHES {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_FEET_FRACTIONAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to ".
|
||||
/// </summary>
|
||||
internal static string DUT_FRACTIONAL_INCHES {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_FRACTIONAL_INCHES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to m.
|
||||
/// </summary>
|
||||
internal static string DUT_METERS {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_METERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to m.
|
||||
/// </summary>
|
||||
internal static string DUT_METERS_CENTIMETERS {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_METERS_CENTIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to mm.
|
||||
/// </summary>
|
||||
internal static string DUT_MILLIMETERS {
|
||||
get {
|
||||
return ResourceManager.GetString("DUT_MILLIMETERS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to - Start point and end point of arc grids are too close.
|
||||
/// </summary>
|
||||
internal static string EndPointsTooClose {
|
||||
get {
|
||||
return ResourceManager.GetString("EndPointsTooClose", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more arc grids..
|
||||
/// </summary>
|
||||
internal static string FailedToCreateArcGrids {
|
||||
get {
|
||||
return ResourceManager.GetString("FailedToCreateArcGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more grids. .
|
||||
/// </summary>
|
||||
internal static string FailedToCreateGrids {
|
||||
get {
|
||||
return ResourceManager.GetString("FailedToCreateGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create one or more radial grids. .
|
||||
/// </summary>
|
||||
internal static string FailedToCreateRadialGrids {
|
||||
get {
|
||||
return ResourceManager.GetString("FailedToCreateRadialGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to delete some of the selected lines or arcs!.
|
||||
/// </summary>
|
||||
internal static string FailedToDeletedLinesOrArcs {
|
||||
get {
|
||||
return ResourceManager.GetString("FailedToDeletedLinesOrArcs", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to set label of grid to : .
|
||||
/// </summary>
|
||||
internal static string FailedToSetLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("FailedToSetLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Create Grids.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionCreateGrids {
|
||||
get {
|
||||
return ResourceManager.GetString("FailureCaptionCreateGrids", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Delete Lines/Arcs.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionDeletedLinesOrArcs {
|
||||
get {
|
||||
return ResourceManager.GetString("FailureCaptionDeletedLinesOrArcs", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Invalid Value.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionInvalidValue {
|
||||
get {
|
||||
return ResourceManager.GetString("FailureCaptionInvalidValue", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to Set Label.
|
||||
/// </summary>
|
||||
internal static string FailureCaptionSetLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("FailureCaptionSetLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Label can not be null!.
|
||||
/// </summary>
|
||||
internal static string LabelCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("LabelCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A same label has already existed!.
|
||||
/// </summary>
|
||||
internal static string LabelExisted {
|
||||
get {
|
||||
return ResourceManager.GetString("LabelExisted", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The two labels can't be same!.
|
||||
/// </summary>
|
||||
internal static string LabelsCannotBeSame {
|
||||
get {
|
||||
return ResourceManager.GetString("LabelsCannotBeSame", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number should be an integer between 0 and 200!.
|
||||
/// </summary>
|
||||
internal static string NumberBetween0And200 {
|
||||
get {
|
||||
return ResourceManager.GetString("NumberBetween0And200", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number can not be null!.
|
||||
/// </summary>
|
||||
internal static string NumberCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("NumberCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Number is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string NumberFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("NumberFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The two numbers can not be both zero!.
|
||||
/// </summary>
|
||||
internal static string NumbersCannotBeBothZero {
|
||||
get {
|
||||
return ResourceManager.GetString("NumbersCannotBeBothZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius can not be negative or zero!.
|
||||
/// </summary>
|
||||
internal static string RadiusCannotBeNegativeOrZero {
|
||||
get {
|
||||
return ResourceManager.GetString("RadiusCannotBeNegativeOrZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius can not be null!.
|
||||
/// </summary>
|
||||
internal static string RadiusCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("RadiusCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string RadiusFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("RadiusFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to That may be caused by one or more of following reasons:.
|
||||
/// </summary>
|
||||
internal static string Reasons {
|
||||
get {
|
||||
return ResourceManager.GetString("Reasons", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing can not be negative or zero!.
|
||||
/// </summary>
|
||||
internal static string SpacingCannotBeNegativeOrZero {
|
||||
get {
|
||||
return ResourceManager.GetString("SpacingCannotBeNegativeOrZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing can not be null!.
|
||||
/// </summary>
|
||||
internal static string SpacingCannotBeNull {
|
||||
get {
|
||||
return ResourceManager.GetString("SpacingCannotBeNull", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Spacing is not in a correct format!.
|
||||
/// </summary>
|
||||
internal static string SpacingFormatWrong {
|
||||
get {
|
||||
return ResourceManager.GetString("SpacingFormatWrong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to - Spacings between grids are too small.
|
||||
/// </summary>
|
||||
internal static string SpacingsTooSmall {
|
||||
get {
|
||||
return ResourceManager.GetString("SpacingsTooSmall", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Start degree should be less than end degree!.
|
||||
/// </summary>
|
||||
internal static string StartDegreeShouldBeLessThanEndDegree {
|
||||
get {
|
||||
return ResourceManager.GetString("StartDegreeShouldBeLessThanEndDegree", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
<?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>
|
||||
<data name="AjustValues" xml:space="preserve">
|
||||
<value>Please adjust the values and try again!</value>
|
||||
</data>
|
||||
<data name="CoordinateCannotBeNull" xml:space="preserve">
|
||||
<value>Coordinate can not be null!</value>
|
||||
</data>
|
||||
<data name="CoordinateFormatWrong" xml:space="preserve">
|
||||
<value>Coordinate is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="DegreeCannotBeNegative" xml:space="preserve">
|
||||
<value>Degree can not be negative!</value>
|
||||
</data>
|
||||
<data name="DegreeCannotBeNull" xml:space="preserve">
|
||||
<value>Degree can not be null!</value>
|
||||
</data>
|
||||
<data name="DegreeFormatWrong" xml:space="preserve">
|
||||
<value>Degree is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="DegreesAreTooClose" xml:space="preserve">
|
||||
<value>Start degree and end degree can not be so close!</value>
|
||||
</data>
|
||||
<data name="DegreeWithin0To360" xml:space="preserve">
|
||||
<value>Degree should be within the range of 0 - 360!</value>
|
||||
</data>
|
||||
<data name="DistanceCannotBeNegative" xml:space="preserve">
|
||||
<value>Distance can not be negative!</value>
|
||||
</data>
|
||||
<data name="DistanceCannotBeNull" xml:space="preserve">
|
||||
<value>Distance can not be null!</value>
|
||||
</data>
|
||||
<data name="DistanceFormatWrong" xml:space="preserve">
|
||||
<value>Distance is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="DUT_CENTIMETERS" xml:space="preserve">
|
||||
<value>cm</value>
|
||||
</data>
|
||||
<data name="DUT_DECIMAL_FEET" xml:space="preserve">
|
||||
<value>'</value>
|
||||
</data>
|
||||
<data name="DUT_DECIMAL_INCHES" xml:space="preserve">
|
||||
<value>"</value>
|
||||
</data>
|
||||
<data name="DUT_FEET_FRACTIONAL_INCHES" xml:space="preserve">
|
||||
<value>'</value>
|
||||
</data>
|
||||
<data name="DUT_FRACTIONAL_INCHES" xml:space="preserve">
|
||||
<value>"</value>
|
||||
</data>
|
||||
<data name="DUT_METERS" xml:space="preserve">
|
||||
<value>m</value>
|
||||
</data>
|
||||
<data name="DUT_METERS_CENTIMETERS" xml:space="preserve">
|
||||
<value>m</value>
|
||||
</data>
|
||||
<data name="DUT_MILLIMETERS" xml:space="preserve">
|
||||
<value>mm</value>
|
||||
</data>
|
||||
<data name="EndPointsTooClose" xml:space="preserve">
|
||||
<value>- Start point and end point of arc grids are too close</value>
|
||||
</data>
|
||||
<data name="FailedToCreateArcGrids" xml:space="preserve">
|
||||
<value>Failed to create one or more arc grids.</value>
|
||||
</data>
|
||||
<data name="FailedToCreateGrids" xml:space="preserve">
|
||||
<value>Failed to create one or more grids. </value>
|
||||
</data>
|
||||
<data name="FailedToCreateRadialGrids" xml:space="preserve">
|
||||
<value>Failed to create one or more radial grids. </value>
|
||||
</data>
|
||||
<data name="FailedToDeletedLinesOrArcs" xml:space="preserve">
|
||||
<value>Failed to delete some of the selected lines or arcs!</value>
|
||||
</data>
|
||||
<data name="FailedToSetLabel" xml:space="preserve">
|
||||
<value>Failed to set label of grid to : </value>
|
||||
</data>
|
||||
<data name="FailureCaptionCreateGrids" xml:space="preserve">
|
||||
<value>Failed to Create Grids</value>
|
||||
</data>
|
||||
<data name="FailureCaptionDeletedLinesOrArcs" xml:space="preserve">
|
||||
<value>Failed to Delete Lines/Arcs</value>
|
||||
</data>
|
||||
<data name="FailureCaptionInvalidValue" xml:space="preserve">
|
||||
<value>Invalid Value</value>
|
||||
</data>
|
||||
<data name="FailureCaptionSetLabel" xml:space="preserve">
|
||||
<value>Failed to Set Label</value>
|
||||
</data>
|
||||
<data name="LabelCannotBeNull" xml:space="preserve">
|
||||
<value>Label can not be null!</value>
|
||||
</data>
|
||||
<data name="LabelExisted" xml:space="preserve">
|
||||
<value>A same label has already existed!</value>
|
||||
</data>
|
||||
<data name="LabelsCannotBeSame" xml:space="preserve">
|
||||
<value>The two labels can't be same!</value>
|
||||
</data>
|
||||
<data name="NumberBetween0And200" xml:space="preserve">
|
||||
<value>Number should be an integer between 0 and 200!</value>
|
||||
</data>
|
||||
<data name="NumberCannotBeNull" xml:space="preserve">
|
||||
<value>Number can not be null!</value>
|
||||
</data>
|
||||
<data name="NumberFormatWrong" xml:space="preserve">
|
||||
<value>Number is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="NumbersCannotBeBothZero" xml:space="preserve">
|
||||
<value>The two numbers can not be both zero!</value>
|
||||
</data>
|
||||
<data name="RadiusCannotBeNegativeOrZero" xml:space="preserve">
|
||||
<value>Radius can not be negative or zero!</value>
|
||||
</data>
|
||||
<data name="RadiusCannotBeNull" xml:space="preserve">
|
||||
<value>Radius can not be null!</value>
|
||||
</data>
|
||||
<data name="RadiusFormatWrong" xml:space="preserve">
|
||||
<value>Radius is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="Reasons" xml:space="preserve">
|
||||
<value> That may be caused by one or more of following reasons:</value>
|
||||
</data>
|
||||
<data name="SpacingCannotBeNegativeOrZero" xml:space="preserve">
|
||||
<value>Spacing can not be negative or zero!</value>
|
||||
</data>
|
||||
<data name="SpacingCannotBeNull" xml:space="preserve">
|
||||
<value>Spacing can not be null!</value>
|
||||
</data>
|
||||
<data name="SpacingFormatWrong" xml:space="preserve">
|
||||
<value>Spacing is not in a correct format!</value>
|
||||
</data>
|
||||
<data name="SpacingsTooSmall" xml:space="preserve">
|
||||
<value>- Spacings between grids are too small</value>
|
||||
</data>
|
||||
<data name="StartDegreeShouldBeLessThanEndDegree" xml:space="preserve">
|
||||
<value>Start degree should be less than end degree!</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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 Autodesk.Revit.DB;
|
||||
using Autodesk.Revit;
|
||||
|
||||
using System.Configuration;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides static functions to convert unit
|
||||
/// </summary>
|
||||
static class Unit
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Convert the value get from RevitAPI to the value indicated by DisplayUnitType
|
||||
/// </summary>
|
||||
/// <param name="to">DisplayUnitType indicates unit of target value</param>
|
||||
/// <param name="value">value get from RevitAPI</param>
|
||||
/// <returns>Target value</returns>
|
||||
public static double CovertFromAPI(ForgeTypeId to, double value)
|
||||
{
|
||||
return value *= ImperialDutRatio(to);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a value indicated by DisplayUnitType to the value used by RevitAPI
|
||||
/// </summary>
|
||||
/// <param name="value">Value to be converted</param>
|
||||
/// <param name="from">DisplayUnitType indicates the unit of the value to be converted</param>
|
||||
/// <returns>Target value</returns>
|
||||
public static double CovertToAPI(double value, ForgeTypeId from)
|
||||
{
|
||||
return value /= ImperialDutRatio(from);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get ratio between value in RevitAPI and value to display indicated by DisplayUnitType
|
||||
/// </summary>
|
||||
/// <param name="dut">DisplayUnitType indicates display unit type</param>
|
||||
/// <returns>Ratio </returns>
|
||||
private static double ImperialDutRatio(ForgeTypeId unit)
|
||||
{
|
||||
if (unit == UnitTypeId.Feet) return 1;
|
||||
if (unit == UnitTypeId.FeetFractionalInches) return 1;
|
||||
if (unit == UnitTypeId.Inches) return 12;
|
||||
if (unit == UnitTypeId.FractionalInches) return 12;
|
||||
if (unit == UnitTypeId.Meters) return 0.3048;
|
||||
if (unit == UnitTypeId.Centimeters) return 30.48;
|
||||
if (unit == UnitTypeId.Millimeters) return 304.8;
|
||||
if (unit == UnitTypeId.MetersCentimeters) return 0.3048;
|
||||
return 1;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+339
@@ -0,0 +1,339 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.Resources;
|
||||
using System.Collections;
|
||||
|
||||
using SamplePropertis = MacroCSharpSamples.GridCreation.GridCreationProperties;
|
||||
|
||||
namespace Revit.SDK.Samples.GridCreation.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to validate input data before creating grids
|
||||
/// </summary>
|
||||
public static class Validation
|
||||
{
|
||||
// Get the resource contains strings
|
||||
static ResourceManager resManager = SamplePropertis.GridCreationResources.ResourceManager;
|
||||
|
||||
/// <summary>
|
||||
/// Validate numbers in UI
|
||||
/// </summary>
|
||||
/// <param name="number1Ctrl">Control contains number information</param>
|
||||
/// <param name="number2Ctrl">Control contains another number information</param>
|
||||
/// <returns>Whether the numbers are validated</returns>
|
||||
public static bool ValidateNumbers(Control number1Ctrl, Control number2Ctrl)
|
||||
{
|
||||
if (!ValidateNumber(number1Ctrl) || !ValidateNumber(number2Ctrl))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Convert.ToUInt32(number1Ctrl.Text) == 0 && Convert.ToUInt32(number2Ctrl.Text) == 0)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString("NumbersCannotBeBothZero"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
number1Ctrl.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate number value
|
||||
/// </summary>
|
||||
/// <param name="numberCtrl">Control contains number information</param>
|
||||
/// <returns>Whether the number value is validated</returns>
|
||||
public static bool ValidateNumber(Control numberCtrl)
|
||||
{
|
||||
if (!ValidateNotNull(numberCtrl, "Number"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
uint number = Convert.ToUInt32(numberCtrl.Text);
|
||||
if (number > 200)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString("NumberBetween0And200"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
numberCtrl.Focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString("NumberBetween0And200"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
numberCtrl.Focus();
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString("NumberFormatWrong"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
numberCtrl.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate length value
|
||||
/// </summary>
|
||||
/// <param name="lengthCtrl">Control contains length information</param>
|
||||
/// <param name="typeName">Type of length</param>
|
||||
/// <param name="canBeZero">Whether the length can be zero</param>
|
||||
/// <returns>Whether the length value is validated</returns>
|
||||
public static bool ValidateLength(Control lengthCtrl, String typeName, bool canBeZero)
|
||||
{
|
||||
if (!ValidateNotNull(lengthCtrl, typeName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
double length = Convert.ToDouble(lengthCtrl.Text);
|
||||
if (length <= 0 && !canBeZero)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString(typeName + "CannotBeNegativeOrZero"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
lengthCtrl.Focus();
|
||||
return false;
|
||||
}
|
||||
else if (length < 0 && canBeZero)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString(typeName + "CannotBeNegative"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
lengthCtrl.Focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString(typeName + "FormatWrong"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
lengthCtrl.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate coordinate value
|
||||
/// </summary>
|
||||
/// <param name="coordCtrl">Control contains coordinate information</param>
|
||||
/// <returns>Whether the coordinate value is validated</returns>
|
||||
public static bool ValidateCoord(Control coordCtrl)
|
||||
{
|
||||
if (!ValidateNotNull(coordCtrl, "Coordinate"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Convert.ToDouble(coordCtrl.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString("CoordinateFormatWrong"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
coordCtrl.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate start degree and end degree
|
||||
/// </summary>
|
||||
/// <param name="startDegree">Control contains start degree information</param>
|
||||
/// <param name="endDegree">Control contains end degree information</param>
|
||||
/// <returns>Whether the degree values are validated</returns>
|
||||
public static bool ValidateDegrees(Control startDegree, Control endDegree)
|
||||
{
|
||||
if (!ValidateDegree(startDegree) || !ValidateDegree(endDegree))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Math.Abs(Convert.ToDouble(startDegree.Text) - Convert.ToDouble(endDegree.Text)) <= Double.Epsilon)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString("DegreesAreTooClose"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
startDegree.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Convert.ToDouble(startDegree.Text) >= Convert.ToDouble(endDegree.Text))
|
||||
{
|
||||
MessageBox.Show(resManager.GetString("StartDegreeShouldBeLessThanEndDegree"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
startDegree.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate degree value
|
||||
/// </summary>
|
||||
/// <param name="degreeCtrl">Control contains degree information</param>
|
||||
/// <returns>Whether the degree value is validated</returns>
|
||||
public static bool ValidateDegree(Control degreeCtrl)
|
||||
{
|
||||
if (!ValidateNotNull(degreeCtrl, "Degree"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
double startDegree = Convert.ToDouble(degreeCtrl.Text);
|
||||
if (startDegree < 0 || startDegree > 360)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString("DegreeWithin0To360"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
degreeCtrl.Focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString("DegreeFormatWrong"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
degreeCtrl.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate label
|
||||
/// </summary>
|
||||
/// <param name="labelCtrl">Control contains label information</param>
|
||||
/// <param name="allLabels">List contains all labels in Revit document</param>
|
||||
/// <returns>Whether the label value is validated</returns>
|
||||
public static bool ValidateLabel(Control labelCtrl, ArrayList allLabels)
|
||||
{
|
||||
if (!ValidateNotNull(labelCtrl, "Label"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String labelToBeValidated = labelCtrl.Text;
|
||||
foreach (String label in allLabels)
|
||||
{
|
||||
if (label == labelToBeValidated)
|
||||
{
|
||||
MessageBox.Show(resManager.GetString("LabelExisted"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
labelCtrl.Focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assure value is not null
|
||||
/// </summary>
|
||||
/// <param name="control">Control contains information needs to be checked</param>
|
||||
/// <param name="typeName">Type of information</param>
|
||||
/// <returns>Whether the value is not null</returns>
|
||||
public static bool ValidateNotNull(Control control, String typeName)
|
||||
{
|
||||
if (String.IsNullOrEmpty(control.Text.TrimStart(' ').TrimEnd(' ')))
|
||||
{
|
||||
MessageBox.Show(resManager.GetString(typeName + "CannotBeNull"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
control.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assure two labels are not same
|
||||
/// </summary>
|
||||
/// <param name="label1Ctrl">Control contains label information</param>
|
||||
/// <param name="label2Ctrl">Control contains label information</param>
|
||||
/// <returns>Whether the labels are same</returns>
|
||||
public static bool ValidateLabels(Control label1Ctrl, Control label2Ctrl)
|
||||
{
|
||||
if (label1Ctrl.Text.TrimStart(' ').TrimEnd(' ') == label2Ctrl.Text.TrimStart(' ').TrimEnd(' '))
|
||||
{
|
||||
MessageBox.Show(resManager.GetString("LabelsCannotBeSame"),
|
||||
SamplePropertis.GridCreationResources.ResourceManager.GetString("FailureCaptionInvalidValue"),
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
label1Ctrl.Focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<Optimize>False</Optimize>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>Portable</DebugType>
|
||||
<OutputPath>..\..\Addin\</OutputPath>
|
||||
<AssemblyName>MacroSamples_RVT</AssemblyName>
|
||||
<BaseInterMediateOutputPath>obj\</BaseInterMediateOutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<InterMediateOutputPath>obj\Debug</InterMediateOutputPath>
|
||||
<Deterministic>false</Deterministic>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
||||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="..\..\..\..\..\RevitAPI.dll">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="..\..\..\..\..\RevitAPIUI.dll">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||
<Exec Command="del $(OutputPath)\*.dll" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using MacroCSharpSamples;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Get some properties of a slab , such as Level, Type name, Span direction,
|
||||
/// Material name, Thickness, and Young Modulus for the slab's Material.
|
||||
/// </summary>
|
||||
public class SampleProjectInfo
|
||||
{
|
||||
// #region Class ctor implemetation
|
||||
/// <summary>
|
||||
/// Ctor without parameter is not allowed
|
||||
/// </summary>
|
||||
private SampleProjectInfo()
|
||||
{
|
||||
// no codes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor of StructuralLayerFunction
|
||||
/// </summary>
|
||||
public SampleProjectInfo(ThisApplication App)
|
||||
{
|
||||
// Init for varialbes
|
||||
// this application handler
|
||||
m_app = App;
|
||||
// initialize global information
|
||||
|
||||
RevitStartInfo.RevitApp = m_app.ActiveUIDocument.Application.Application;
|
||||
RevitStartInfo.RevitDoc = m_app.ActiveUIDocument.Document;
|
||||
RevitStartInfo.RevitProduct = m_app.ActiveUIDocument.Application.Application.Product;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run sample Rooms
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Get ProjectInfo object from current project
|
||||
if(m_app == null)
|
||||
return;
|
||||
Autodesk.Revit.DB.ProjectInfo projectInfo = m_app.ActiveUIDocument.Document.ProjectInformation;
|
||||
if (null != projectInfo)
|
||||
{
|
||||
ProjectInfoForm mainForm = new ProjectInfoForm(new ProjectInfoWrapper(projectInfo));
|
||||
mainForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
#region Class member variable
|
||||
ThisApplication? m_app;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts angle with string
|
||||
/// </summary>
|
||||
public class AngleConverter : TypeConverter
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
return false;
|
||||
return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to an element</param>
|
||||
/// <returns>An element if the element exists, otherwise null</returns>
|
||||
public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
|
||||
{
|
||||
string? text = value as string;
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
return AngleString2Double(text);
|
||||
}
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>Converted string</returns>
|
||||
public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
if (destinationType == null)
|
||||
{
|
||||
throw new ArgumentNullException("destinationType");
|
||||
}
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
if (value == null) return string.Empty;
|
||||
double angle = (double) value;
|
||||
return Double2AngleString(angle);
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert angle string to double value
|
||||
/// </summary>
|
||||
/// <param name="value">Angle string</param>
|
||||
/// <returns>Double value</returns>
|
||||
private static double AngleString2Double(string value)
|
||||
{
|
||||
int n = value.Length - 1;
|
||||
if (!char.IsDigit(value[n]))
|
||||
{
|
||||
value = value.Substring(0, n);
|
||||
}
|
||||
return Double.Parse(value) * 0.0174532925199433;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert double value to angle string
|
||||
/// </summary>
|
||||
/// <param name="value">Angle value</param>
|
||||
/// <returns>Angle string, the unit is degree.</returns>
|
||||
private static string Double2AngleString(Double value)
|
||||
{
|
||||
// 0xb0 is ASCII for unit flag of "degree"
|
||||
return ((object)Math.Round(value / 0.0174532925199433, 3)).ToString() + (char)0xb0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts City with string
|
||||
/// </summary>
|
||||
public class CityConverter : TypeConverter
|
||||
{
|
||||
|
||||
public static List<City>? Cities;
|
||||
public const string UserDefined = "User Defined";
|
||||
|
||||
static CityConverter()
|
||||
{
|
||||
if(RevitStartInfo.RevitApp == null)
|
||||
return;
|
||||
Cities = new List<City>();
|
||||
foreach (City city in RevitStartInfo.RevitApp.Cities)
|
||||
{
|
||||
Cities.Add(city);
|
||||
}
|
||||
}
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether this object supports a standard set of values that can be
|
||||
/// picked from a list, using the specified context.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
|
||||
/// is an exclusive list.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>Element collection retrieved through filtering current Revit document elements</returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
return new StandardValuesCollection(Cities);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
return false;
|
||||
return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an element from a string contains its id
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to an element</param>
|
||||
/// <returns>An element if the element exists, otherwise null</returns>
|
||||
public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
|
||||
{
|
||||
string? text = value as string;
|
||||
if(Cities == null)
|
||||
return null;
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
foreach (City city in Cities)
|
||||
{
|
||||
if (city.Name == text)
|
||||
return city;
|
||||
}
|
||||
}
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns element name.
|
||||
/// returns empty string if value is null or Element.Name throws an exception.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>Converted string</returns>
|
||||
public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
if (destinationType == null)
|
||||
{
|
||||
throw new ArgumentNullException("destinationType");
|
||||
}
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
if (value == null) return UserDefined;
|
||||
City? city = value as City;
|
||||
if (city != null)
|
||||
return city.Name;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
using ConstructionType = Autodesk.Revit.DB.Analysis.ConstructionType;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Converter for ConstructionWrapper
|
||||
/// </summary>
|
||||
public class ConstructionWrapperConverter : TypeConverter
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Returns whether this object supports a standard set of values that can be
|
||||
/// picked from a list, using the specified context.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
|
||||
/// is an exclusive list.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>ConstructionWrapper collection depends on current context</returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
List<ConstructionWrapper> list = new List<ConstructionWrapper>();
|
||||
// convert property name to ConstructionType
|
||||
|
||||
string? tmp = context?.PropertyDescriptor.Name;
|
||||
string tmp2 = string.Empty;
|
||||
if(tmp != null)
|
||||
{
|
||||
tmp2 = tmp;
|
||||
}
|
||||
ConstructionType constructionType = (ConstructionType)Enum.Parse(typeof(ConstructionType),tmp2);
|
||||
// convert instance to MEPBuildingConstructionWrapper
|
||||
MEPBuildingConstructionWrapper? mEPBuildingConstruction = context?.Instance as MEPBuildingConstructionWrapper;
|
||||
|
||||
// get all Constructions from MEPBuildingConstructionWrapper and add them to a list
|
||||
if(mEPBuildingConstruction != null)
|
||||
{
|
||||
foreach (Construction con in mEPBuildingConstruction.GetConstructions(constructionType))
|
||||
{
|
||||
list.Add(new ConstructionWrapper(con));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// sort the list
|
||||
list.Sort();
|
||||
return new StandardValuesCollection(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can convert from string
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="sourceType">A Type that represents the type you want to convert from. </param>
|
||||
/// <returns>true if sourceType is string, otherwise false</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can be converted to string
|
||||
/// </summary>
|
||||
/// <returns>true if destinationType is string, otherwise false</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return destinationType.Equals(typeof(System.String)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a ConstructionWrapper from a string
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to</param>
|
||||
/// <returns>A ConstructionWrapper from the StandardValues</returns>
|
||||
public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
|
||||
{
|
||||
string? text = value as string;
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
foreach (ConstructionWrapper con in this.GetStandardValues(context))
|
||||
{
|
||||
if (con.Name == text)
|
||||
{
|
||||
return con;
|
||||
}
|
||||
}
|
||||
}
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert object to string
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>empty string if current construction is null, otherwise construction name</returns>
|
||||
public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
if (destinationType == null)
|
||||
{
|
||||
throw new ArgumentNullException("destinationType");
|
||||
}
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
if (value == null) return string.Empty;
|
||||
ConstructionWrapper? construction = value as ConstructionWrapper;
|
||||
if (construction != null)
|
||||
{
|
||||
return construction.Name;
|
||||
}
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// (C) Copyright 2003-2009 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.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Autodesk.Revit;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Type converter for wrapper classes
|
||||
/// </summary>
|
||||
public class WrapperConverter : ExpandableObjectConverter
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Can be converted to string
|
||||
/// </summary>
|
||||
/// <returns>true if destinationType is string, otherwise false</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return destinationType.Equals(typeof(System.String)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts to string. If value is null, convert it to "(null)".
|
||||
/// if value has a "Name" property, returns its name. otherwise, returns "(...)".
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
if (destinationType == null)
|
||||
{
|
||||
throw new ArgumentNullException("destinationType");
|
||||
}
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
if (value == null) return "(null)";
|
||||
|
||||
// get its name
|
||||
Type type = value.GetType();
|
||||
string wrapperType = type.ToString();
|
||||
MethodInfo? mi = type.GetMethod("get_Name", new Type[0]);
|
||||
if (mi != null)
|
||||
{
|
||||
return mi.Invoke(value, new object[0])?.ToString();
|
||||
}
|
||||
|
||||
// if no name
|
||||
return "(...)";
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
}
|
||||
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert ElementIds with string
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Element Type</typeparam>
|
||||
public class ElementIdConverter<T> : TypeConverter where T: Element
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns whether this object supports a standard set of values that can be
|
||||
/// picked from a list, using the specified context.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
|
||||
/// is an exclusive list.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>Element collection retrieved through filtering current Revit document elements</returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
// using type filter to get the target type objects
|
||||
//Autodesk.Revit.DB.TypeFilter typeFilter = RevitStartInfo.RevitApp.Create.Filter.NewTypeFilter(targetType, true);
|
||||
//ElementIterator elementIterator = RevitStartInfo.RevitDoc.get_Elements(typeFilter);
|
||||
|
||||
//// create a list
|
||||
//List<Element> list = new List<Element>();
|
||||
//elementIterator.Reset();
|
||||
//while (elementIterator.MoveNext())
|
||||
//{
|
||||
// list.Add(elementIterator.Current as Element);
|
||||
//}
|
||||
var list = new FilteredElementCollector(RevitStartInfo.RevitDoc).OfClass(typeof(T));
|
||||
|
||||
return new StandardValuesCollection(list.ToElementIds().ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
return false;
|
||||
return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an element from a string contains its id
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to an element</param>
|
||||
/// <returns>An element if the element exists, otherwise null</returns>
|
||||
public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
|
||||
{
|
||||
string? text = value as string;
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
StandardValuesCollection svc = GetStandardValues(context);
|
||||
foreach (ElementId elementId in svc)
|
||||
{
|
||||
Element? element = RevitStartInfo.GetElement(elementId);
|
||||
if (element?.Name == text)
|
||||
return element.Id;
|
||||
}
|
||||
}
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns element name.
|
||||
/// returns empty string if value is null or Element.Name throws an exception.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>Converted string</returns>
|
||||
public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
if (destinationType == null)
|
||||
{
|
||||
throw new ArgumentNullException("destinationType");
|
||||
}
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
if (value == null) return string.Empty;
|
||||
ElementId? elementId = value as ElementId;
|
||||
if (elementId != null)
|
||||
{
|
||||
Element? element = RevitStartInfo.GetElement(elementId);
|
||||
if (element != null)
|
||||
{
|
||||
string elementName = string.Empty;
|
||||
try
|
||||
{
|
||||
elementName = element.Name;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return elementName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
};
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts ProjectLocation with string
|
||||
/// </summary>
|
||||
public class ProjectLocationConverter: TypeConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// All project locations in current document
|
||||
/// </summary>
|
||||
public static List<ProjectLocation>? ProjectLocations;
|
||||
/// <summary>
|
||||
/// User defined location
|
||||
/// </summary>
|
||||
public const string UserDefined = "User Defined";
|
||||
|
||||
/// <summary>
|
||||
/// Initialize ProjectLocations
|
||||
/// </summary>
|
||||
static ProjectLocationConverter()
|
||||
{
|
||||
if(RevitStartInfo.RevitDoc == null)
|
||||
return;
|
||||
ProjectLocations = new List<ProjectLocation>();
|
||||
foreach (ProjectLocation city in RevitStartInfo.RevitDoc.ProjectLocations)
|
||||
{
|
||||
ProjectLocations.Add(city);
|
||||
}
|
||||
}
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether this object supports a standard set of values that can be
|
||||
/// picked from a list, using the specified context.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
|
||||
/// is an exclusive list.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>Element collection retrieved through filtering current Revit document elements</returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
return new StandardValuesCollection(ProjectLocations);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <returns>Converted string</returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
if(destinationType == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts from string.
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to an element</param>
|
||||
/// <returns>An element if the element exists, otherwise null</returns>
|
||||
public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
|
||||
{
|
||||
string? text = value as string;
|
||||
if(ProjectLocations == null)
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
foreach (ProjectLocation projectLocation in ProjectLocations)
|
||||
{
|
||||
if (projectLocation.Name == text)
|
||||
return projectLocation;
|
||||
}
|
||||
}
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts to string.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>Converted string</returns>
|
||||
public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
if (destinationType == null)
|
||||
{
|
||||
throw new ArgumentNullException("destinationType");
|
||||
}
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
if (value == null) return UserDefined;
|
||||
ProjectLocation? projectLocation = value as ProjectLocation;
|
||||
if (projectLocation != null)
|
||||
return projectLocation.Name;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Converter for Enumeration types of RevitAPI
|
||||
/// </summary>
|
||||
public abstract class RevitEnumConverter : EnumConverter
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Dictionary contains enum and string map
|
||||
/// </summary>
|
||||
Dictionary<object, string>? m_map = null;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected abstract Dictionary<object, string> EnumMap
|
||||
{
|
||||
get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initialize private variables
|
||||
/// </summary>
|
||||
/// <param name="type">Enumeration type</param>
|
||||
public RevitEnumConverter(Type type)
|
||||
: base(type)
|
||||
{
|
||||
m_map = EnumMap;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>All enum items</returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
return new StandardValuesCollection(m_map?.Keys);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enum item from a string
|
||||
/// </summary>
|
||||
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext
|
||||
/// that provides a format context.</param>
|
||||
/// <param name="culture">An optional System.Globalization.CultureInfo.
|
||||
/// If not supplied, the current culture is assumed.</param>
|
||||
/// <param name="value">string to be converted to</param>
|
||||
/// <returns>An enum item</returns>
|
||||
public override object? ConvertFrom(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value)
|
||||
{
|
||||
object enumValue = value;
|
||||
string? valueText = value.ToString();
|
||||
if(m_map == null)
|
||||
return base.ConvertFrom(context, culture, enumValue);
|
||||
foreach (KeyValuePair<object, string> pair in m_map)
|
||||
{
|
||||
if (pair.Value == valueText)
|
||||
{
|
||||
string? tmp = pair.Key.ToString();
|
||||
if(tmp != null)
|
||||
enumValue = tmp;
|
||||
}
|
||||
}
|
||||
return base.ConvertFrom(context, culture, enumValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert enum item to string
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that provides a format context. </param>
|
||||
/// <param name="culture">A CultureInfo. If null is passed, the current culture is assumed. </param>
|
||||
/// <param name="value">The Object to convert. </param>
|
||||
/// <param name="destinationType">The Type to convert the value parameter to. </param>
|
||||
/// <returns>Corresponding string related with the enum item</returns>
|
||||
public override object? ConvertTo(ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
object? enumValue = base.ConvertTo(context, culture, value, destinationType);
|
||||
string? tmp = enumValue?.ToString();
|
||||
if(tmp == null || m_map == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
object enumObject = Enum.Parse(this.EnumType, tmp);
|
||||
return m_map[enumObject];
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converter for BuildingType
|
||||
/// </summary>
|
||||
public class BuildingTypeConverter : RevitEnumConverter
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="type">enumeration type</param>
|
||||
public BuildingTypeConverter(Type type) : base(type) { }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected override Dictionary<object, string> EnumMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return RevitStartInfo.BuildingTypeMap;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converter for ExportComplexityConverter
|
||||
/// </summary>
|
||||
public class ExportComplexityConverter : RevitEnumConverter
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="type">enumeration type</param>
|
||||
public ExportComplexityConverter(Type type) : base(type) { }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected override Dictionary<object, string> EnumMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return RevitStartInfo.ExportComplexityMap;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converter for ServiceType
|
||||
/// </summary>
|
||||
public class ServiceTypeConverter : RevitEnumConverter
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="type">enumeration type</param>
|
||||
public ServiceTypeConverter(Type type) : base(type) { }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected override Dictionary<object, string> EnumMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return RevitStartInfo.ServiceTypeMap;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converter for HVACLoadLoadsReportType
|
||||
/// </summary>
|
||||
public class HVACLoadLoadsReportTypeConverter : RevitEnumConverter
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="type">enumeration type</param>
|
||||
public HVACLoadLoadsReportTypeConverter(Type type) : base(type) { }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected override Dictionary<object, string> EnumMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return RevitStartInfo.HVACLoadLoadsReportTypeMap;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converter for HVACLoadConstructionClass
|
||||
/// </summary>
|
||||
public class HVACLoadConstructionClassConverter : RevitEnumConverter
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="type">enumeration type</param>
|
||||
public HVACLoadConstructionClassConverter(Type type) : base(type) { }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the enum-string map
|
||||
/// </summary>
|
||||
protected override Dictionary<object, string> EnumMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return RevitStartInfo.HVACLoadConstructionClassMap;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Converter used to convert TimeZone
|
||||
/// </summary>
|
||||
public class TimeZoneConverter : TypeConverter
|
||||
{
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Returns whether this object supports a standard set of values that can be
|
||||
/// picked from a list, using the specified context.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the collection of standard values returned from System.ComponentModel.TypeConverter.GetStandardValues()
|
||||
/// is an exclusive list.
|
||||
/// </summary>
|
||||
/// <returns>true</returns>
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of standard values from the default context for the
|
||||
/// data type this type converter is designed for.
|
||||
/// </summary>
|
||||
/// <returns>Element collection retrieved through filtering current Revit document elements</returns>
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
return new StandardValuesCollection(RevitStartInfo.TimeZones);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
}
|
||||
Generated
+118
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// (C) Copyright 2003-2010 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.ProjectInfo.CS
|
||||
{
|
||||
partial class ProjectInfoForm
|
||||
{
|
||||
/// <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.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.Location = new System.Drawing.Point(265, 384);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 0;
|
||||
this.okButton.Text = "&OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(346, 384);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cancelButton.TabIndex = 1;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// propertyGrid1
|
||||
//
|
||||
this.propertyGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.propertyGrid1.HelpVisible = false;
|
||||
this.propertyGrid1.Location = new System.Drawing.Point(12, 12);
|
||||
this.propertyGrid1.Name = "propertyGrid1";
|
||||
this.propertyGrid1.Size = new System.Drawing.Size(409, 366);
|
||||
this.propertyGrid1.TabIndex = 2;
|
||||
//
|
||||
// ProjectInfoForm
|
||||
//
|
||||
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(433, 419);
|
||||
this.Controls.Add(this.propertyGrid1);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ProjectInfoForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Project Information";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.PropertyGrid propertyGrid1;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// (C) Copyright 2003-2010 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;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Form used to display project information
|
||||
/// </summary>
|
||||
public partial class ProjectInfoForm : System.Windows.Forms.Form
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Wrapper for ProjectInfo
|
||||
/// </summary>
|
||||
ProjectInfoWrapper? m_projectInfoWrapper = null;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initialize component
|
||||
/// </summary>
|
||||
public ProjectInfoForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize PropertyGrid
|
||||
/// </summary>
|
||||
/// <param name="projectInfoWrapper">ProjectInfo wrapper</param>
|
||||
public ProjectInfoForm(ProjectInfoWrapper projectInfoWrapper)
|
||||
:this()
|
||||
{
|
||||
m_projectInfoWrapper = projectInfoWrapper;
|
||||
|
||||
// Initialize propertyGrid with CustomDescriptor
|
||||
propertyGrid1.SelectedObject = new WrapperCustomDescriptor(m_projectInfoWrapper);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+120
@@ -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>
|
||||
+262
@@ -0,0 +1,262 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Analysis;
|
||||
|
||||
/// <summary>
|
||||
/// Preserves global information
|
||||
/// </summary>
|
||||
public static class RevitStartInfo
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Current Revit application
|
||||
/// </summary>
|
||||
public static Autodesk.Revit.ApplicationServices.Application? RevitApp;
|
||||
|
||||
/// <summary>
|
||||
/// Active Revit document
|
||||
/// </summary>
|
||||
public static Document? RevitDoc;
|
||||
|
||||
/// <summary>
|
||||
/// Current Revit Product
|
||||
/// </summary>
|
||||
public static ProductType RevitProduct;
|
||||
|
||||
/// <summary>
|
||||
/// Time Zone Array
|
||||
/// </summary>
|
||||
public static string[] TimeZones;
|
||||
|
||||
/// <summary>
|
||||
/// BuildingType and its display string map.
|
||||
/// </summary>
|
||||
public static Dictionary<object, string> BuildingTypeMap;
|
||||
|
||||
/// <summary>
|
||||
/// ServiceType and its display string map.
|
||||
/// </summary>
|
||||
public static Dictionary<object, string> ServiceTypeMap;
|
||||
|
||||
/// <summary>
|
||||
/// ExportComplexity and its display string map.
|
||||
/// </summary>
|
||||
public static Dictionary<object, string> ExportComplexityMap;
|
||||
|
||||
/// <summary>
|
||||
/// HVACLoadLoadsReportType and its display string map.
|
||||
/// </summary>
|
||||
public static Dictionary<object, string> HVACLoadLoadsReportTypeMap;
|
||||
|
||||
/// <summary>
|
||||
/// HVACLoadConstructionClass and its display string map.
|
||||
/// </summary>
|
||||
public static Dictionary<object, string> HVACLoadConstructionClassMap;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize some static members
|
||||
/// </summary>
|
||||
static RevitStartInfo()
|
||||
{
|
||||
#region TimeZones
|
||||
TimeZones = new string[]{
|
||||
"(GMT-12:00) International Date Line West",
|
||||
"(GMT-11:00) Midway Island, Samoa",
|
||||
"(GMT-10:00) Hawaii",
|
||||
"(GMT-09:00) Alaska",
|
||||
"(GMT-08:00) Pacific Time (US/Canada)",
|
||||
"(GMT-08:00) Tijuana, Baja California",
|
||||
"(GMT-07:00) Arizona",
|
||||
"(GMT-07:00) Chihuahua, La Paz, Mazatlan - New",
|
||||
"(GMT-07:00) Chihuahua, La Paz, Mazatlan - Old",
|
||||
"(GMT-07:00) Mountain Time (US/Canada)",
|
||||
"(GMT-06:00) Central America",
|
||||
"(GMT-06:00) Central Time (US/Canada)",
|
||||
"(GMT-06:00) Guadalajara, Mexico City, Monterrey - New",
|
||||
"(GMT-06:00) Guadalajara, Mexico City, Monterrey - Old",
|
||||
"(GMT-06:00) Saskatchewan",
|
||||
"(GMT-05:00) Bogota, Lima, Quito, Rio Branco",
|
||||
"(GMT-05:00) Eastern Time (US/Canada)",
|
||||
"(GMT-05:00) Indiana (East)",
|
||||
"(GMT-04:00) Atlantic Time (Canada)",
|
||||
"(GMT-04:00) Caracas, La Paz",
|
||||
"(GMT-04:00) Santiago",
|
||||
"(GMT-03:30) Newfoundland",
|
||||
"(GMT-03:00) Brazilia",
|
||||
"(GMT-03:00) Buanos Aires, Georgetown",
|
||||
"(GMT-03:00) Greenland",
|
||||
"(GMT-03:00) Montevideo",
|
||||
"(GMT-02:00) Mid-Atlantic",
|
||||
"(GMT-01:00) Azores",
|
||||
"(GMT-01:00) Cape Verde Is.",
|
||||
"(GMT) Casablanca, Monrovia,Reykjavik",
|
||||
"(GMT) Greenwich Time: Dublin, Edinburgh, Lisbon, London",
|
||||
"(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna",
|
||||
"(GMT+01:00) Belgrade, Brastislava, Budapest, Ljubljana, Prague",
|
||||
"(GMT+01:00) Brussels, Copenhagen, Madrid, Paris",
|
||||
"(GMT+01:00) Sarajevo, Skopje, Sofija, Vilnus, Warsaw, Zagreb",
|
||||
"(GMT+01:00) West Central Africa",
|
||||
"(GMT+02:00) Amman",
|
||||
"(GMT+02:00) Athens, Bucharest, Istanbul",
|
||||
"(GMT+02:00) Beirut",
|
||||
"(GMT+02:00) Cairo",
|
||||
"(GMT+02:00) Harare, Pretoria",
|
||||
"(GMT+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius",
|
||||
"(GMT+02:00) Jerusalem",
|
||||
"(GMT+02:00) Minsk",
|
||||
"(GMT+02:00) Windhoek",
|
||||
"(GMT+03:00) Baghdad",
|
||||
"(GMT+03:00) Kuwait, Riyadh",
|
||||
"(GMT+03:00) Moscow, St. Petersburg, Volgograd",
|
||||
"(GMT+03:00) Nairobi",
|
||||
"(GMT+03:00) Tbilisi",
|
||||
"(GMT+03:00) Tehran",
|
||||
"(GMT+04:00) Abu Dhabi, Muscat",
|
||||
"(GMT+04:00) Baku",
|
||||
"(GMT+04:00) Yerevan",
|
||||
"(GMT+04:30) Kabul",
|
||||
"(GMT+05:00) Ekaterinburg",
|
||||
"(GMT+05:00) Islamabad, Karachi, Tashkent",
|
||||
"(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi",
|
||||
"(GMT+05:30) Sri Jayawardenepura",
|
||||
"(GMT+05:45) Kathmandu ",
|
||||
"(GMT+06:00) Almaty, Novosibirsk",
|
||||
"(GMT+06:00) Astana, Dhaka",
|
||||
"(GMT+06:30) Yangon (Rangoon)",
|
||||
"(GMT+07:00) Bangkok, Hanoi, Jakarta ",
|
||||
"(GMT+07:00) Krasnoyarsk ",
|
||||
"(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi ",
|
||||
"(GMT+08:00) Irkutsk, Ulaan Bataar ",
|
||||
"(GMT+08:00) Kuala Lumpur, Singapore ",
|
||||
"(GMT+08:00) Perth",
|
||||
"(GMT+08:00) Taipei",
|
||||
"(GMT+09:00) Osaka, Sapporo, Tokyo",
|
||||
"(GMT+09:00) Seoul",
|
||||
"(GMT+09:00) Yakutsk",
|
||||
"(GMT+09:30) Adelaide",
|
||||
"(GMT+09:30) Darwin",
|
||||
"(GMT+10:00) Brisbane",
|
||||
"(GMT+10:00) Canberra, Melbourne, Sydney",
|
||||
"(GMT+10:00) Guam, Port Moresby",
|
||||
"(GMT+10:00) Hobart",
|
||||
"(GMT+10:00) Vladivostok",
|
||||
"(GMT+11:00) Magadan, Solomon Is., New Caledonia ",
|
||||
"(GMT+12:00) Aukland, Wellington ",
|
||||
"(GMT+12:00) Fiji, Kamchatka, Marshall Is.",
|
||||
"(GMT+13:00) Nubu'alofa" };
|
||||
#endregion
|
||||
|
||||
#region BuildingTypeMap
|
||||
BuildingTypeMap = new Dictionary<object, string>();
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.AutomotiveFacility, "Automotive Facility");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.ConventionCenter, "Convention Center");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Courthouse, "Courthouse");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.DiningBarLoungeOrLeisure, "Dining Bar Lounge or Leisure");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.DiningCafeteriaFastFood, "Dining Cafeteria Fast Food");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.DiningFamily, "Dining Family");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Dormitory, "Dormitory");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.ExerciseCenter, "Exercise Center");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.FireStation, "Fire Station");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Gymnasium, "Gymnasium");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.HospitalOrHealthcare, "Hospital or Healthcare");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Hotel, "Hotel");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Library, "Library");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Manufacturing, "Manufacturing");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Motel, "Motel");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.MotionPictureTheatre, "Motion Picture Theatre");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.MultiFamily, "Multi Family");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Museum, "Museum");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.NoOfBuildingTypes, "None");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Office, "Office");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.ParkingGarage, "Parking Garage");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Penitentiary, "Penitentiary");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.PerformingArtsTheater, "Performing Arts Theater");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.PoliceStation, "Police Station");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.PostOffice, "Post Office");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.ReligiousBuilding, "Religious Building");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Retail, "Retail");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.SchoolOrUniversity, "School or University");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.SingleFamily, "Single Family");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.SportsArena, "Sports Arena");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.TownHall, "Town Hall");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Transportation, "Transportation");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Warehouse, "Warehouse");
|
||||
BuildingTypeMap.Add(gbXMLBuildingType.Workshop, "Workshop");
|
||||
#endregion
|
||||
|
||||
#region ServiceTypeMap
|
||||
ServiceTypeMap = new Dictionary<object, string>();
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ActiveChilledBeams, "Active Chilled Beams");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.CentralHeatingConvectors, "Central Heating: Convectors");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.CentralHeatingHotAir, "Central Heating: Hot Air");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.CentralHeatingRadiantFloor, "Central Heating: Radiant Floor");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.CentralHeatingRadiators, "Central Heating: Radiators");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ConstantVolumeDualDuct, "Constant Volume - Dual Duct");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ConstantVolumeFixedOA, "Constant Volume - Fixed OA");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ConstantVolumeTerminalReheat, "Constant Volume - Terminal Reheat");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ConstantVolumeVariableOA, "Constant Volume - Variable OA");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.FanCoilSystem, "Fan Coil System");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ForcedConvectionHeaterFlue, "Forced Convection Heater - Flue");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.ForcedConvectionHeaterNoFlue, "Forced Convection Heater - No Flue");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.InductionSystem, "Induction System");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.MultizoneHotDeckColdDeck, "Multi-zone - Hot Deck / Cold Deck");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.NoServiceType, "None");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.OtherRoomHeater, "Other Room Heater");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.RadiantCooledCeilings, "Radiant Cooled Ceilings");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.RadiantHeaterFlue, "Radiant Heater - Flue");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.RadiantHeaterMultiburner, "Radiant Heater - Multi-burner");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.RadiantHeaterNoFlue, "Radiant Heater - No Flue");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.SplitSystemsWithMechanicalVentilation, "Split System(s) with Mechanical Ventilation");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.SplitSystemsWithMechanicalVentilationWithCooling, "Split System(s) with Mechanical Ventilation with Cooling");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.SplitSystemsWithNaturalVentilation, "Split System(s) with Natural Ventilation");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.VariableRefrigerantFlow, "Variable Refrigerant Flow");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.VAVDualDuct, "VAV - Dual Duct");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.VAVIndoorPackagedCabinet, "VAV - Indoor Packaged Cabinet");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.VAVSingleDuct, "VAV - Single Duct");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.VAVTerminalReheat, "VAV - Terminal Reheat");
|
||||
ServiceTypeMap.Add(gbXMLServiceType.WaterLoopHeatPump, "Water Loop Heat Pump");
|
||||
#endregion
|
||||
|
||||
#region ExportComplexityMap
|
||||
ExportComplexityMap = new Dictionary<object, string>();
|
||||
ExportComplexityMap.Add(gbXMLExportComplexity.Complex, "Complex");
|
||||
ExportComplexityMap.Add(gbXMLExportComplexity.ComplexWithMullionsAndShadingSurfaces, "Complex With Mullions And Shading Surfaces");
|
||||
ExportComplexityMap.Add(gbXMLExportComplexity.ComplexWithShadingSurfaces, "Complex With Shading Surfaces");
|
||||
ExportComplexityMap.Add(gbXMLExportComplexity.Simple, "Simple");
|
||||
ExportComplexityMap.Add(gbXMLExportComplexity.SimpleWithShadingSurfaces, "Simple With Shading Surfaces");
|
||||
#endregion
|
||||
|
||||
#region HVACLoadLoadsReportTypeMap
|
||||
HVACLoadLoadsReportTypeMap = new Dictionary<object, string>();
|
||||
HVACLoadLoadsReportTypeMap.Add(HVACLoadLoadsReportType.DetailedReport, "Detailed");
|
||||
HVACLoadLoadsReportTypeMap.Add(HVACLoadLoadsReportType.NoReport, "No");
|
||||
HVACLoadLoadsReportTypeMap.Add(HVACLoadLoadsReportType.SimpleReport, "Simple");
|
||||
HVACLoadLoadsReportTypeMap.Add(HVACLoadLoadsReportType.StandardReport, "Standard");
|
||||
#endregion
|
||||
|
||||
#region HVACLoadConstructionClassMap
|
||||
HVACLoadConstructionClassMap = new Dictionary<object, string>();
|
||||
HVACLoadConstructionClassMap.Add(HVACLoadConstructionClass.LooseConstruction, "Loose");
|
||||
HVACLoadConstructionClassMap.Add(HVACLoadConstructionClass.NoneConstruction, "None");
|
||||
HVACLoadConstructionClassMap.Add(HVACLoadConstructionClass.MediumConstruction, "Medium");
|
||||
HVACLoadConstructionClassMap.Add(HVACLoadConstructionClass.TightConstruction, "Tight");
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public static Element? GetElement(ElementId elementId)
|
||||
{
|
||||
return RevitDoc?.GetElement(elementId);
|
||||
}
|
||||
public static Element? GetElement(Int64 elementId)
|
||||
{
|
||||
return GetElement(new ElementId(elementId));
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// (C) Copyright 2003-2010 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.Collections.ObjectModel;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute which designates Revit version names
|
||||
/// </summary>
|
||||
public sealed class RevitVersionAttribute : Attribute
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Revit version name array
|
||||
/// </summary>
|
||||
List<ProductType> m_products = new List<ProductType>();
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets Revit version names
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<ProductType> Names
|
||||
{
|
||||
get { return m_products.AsReadOnly(); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes Revit version name array
|
||||
/// </summary>
|
||||
/// <param name="names"></param>
|
||||
public RevitVersionAttribute(params ProductType[] names)
|
||||
{
|
||||
m_products.AddRange(names);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper class for Construction
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(ConstructionWrapperConverter))]
|
||||
public class ConstructionWrapper : IComparable, IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Construction
|
||||
/// </summary>
|
||||
private Construction m_construction;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes private variables.
|
||||
/// </summary>
|
||||
/// <param name="construction">Construction</param>
|
||||
public ConstructionWrapper(Construction construction)
|
||||
{
|
||||
m_construction = construction;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
#region IComparable Members
|
||||
|
||||
/// <summary>
|
||||
/// Compares the names of Constructions.
|
||||
/// </summary>
|
||||
/// <param name="obj">ConstructionWrapper used to compare</param>
|
||||
/// <returns>A 32-bit signed integer that indicates the relative order of the objects
|
||||
/// being compared. The return value has these meanings:
|
||||
/// Value Condition Less than zero This instance is less than value.
|
||||
/// Zero This instance is equal to value. Greater than zero This instance is
|
||||
/// greater than value.-or- value is null.</returns>
|
||||
public int CompareTo(object? obj)
|
||||
{
|
||||
ConstructionWrapper? wrapper = obj as ConstructionWrapper;
|
||||
if (wrapper != null)
|
||||
{
|
||||
return this.Name.CompareTo(wrapper.Name);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWrapper Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public object Handle
|
||||
{
|
||||
get { return m_construction; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public String Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_construction.Name;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+271
@@ -0,0 +1,271 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Analysis;
|
||||
using Autodesk.Revit.DB.Mechanical;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper class for gbXMLParamElem
|
||||
/// </summary>
|
||||
public class EnergyDataSettingsWrapper : IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// gbXMLParamElem
|
||||
/// </summary>
|
||||
private EnergyDataSettings m_energyDataSettings;
|
||||
/// <summary>
|
||||
/// Revit Document
|
||||
/// </summary>
|
||||
private Document m_document;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes private variables.
|
||||
/// </summary>
|
||||
/// <param name="gbXMLParamElem">gbXMLParamElem</param>
|
||||
public EnergyDataSettingsWrapper(Document document)
|
||||
{
|
||||
m_document = document;
|
||||
m_energyDataSettings = EnergyDataSettings.GetFromDocument(document);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Building Type
|
||||
/// </summary>
|
||||
[Category("Common"), DisplayName("Building Type")]
|
||||
[TypeConverter(typeof(BuildingTypeConverter))]
|
||||
public gbXMLBuildingType BuildingType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.BuildingType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.BuildingType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Ground Plane
|
||||
/// </summary>
|
||||
[Category("Common"), DisplayName("Ground Plane")]
|
||||
[TypeConverter(typeof(ElementIdConverter<Level>))]
|
||||
public ElementId GroundPlane
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.GroundPlane;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.GroundPlane = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Building Service
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Building Service")]
|
||||
[TypeConverter(typeof(ServiceTypeConverter))]
|
||||
[RevitVersion(ProductType.MEP)]
|
||||
public gbXMLServiceType BuildingService
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.ServiceType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.ServiceType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets Building Construction
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Building Construction"), TypeConverter(typeof(WrapperConverter)), RevitVersion(ProductType.MEP)]
|
||||
public MEPBuildingConstructionWrapper? BuildingConstruction
|
||||
{
|
||||
get
|
||||
{
|
||||
ElementId eid = EnergyDataSettings.GetBuildingConstructionSetElementId(m_document);
|
||||
MEPBuildingConstruction? mEPBuildingConstruction = RevitStartInfo.GetElement(eid) as MEPBuildingConstruction;
|
||||
//MEPBuildingConstruction mEPBuildingConstruction = RevitStartInfo.GetElement(m_energyDataSettings.ConstructionSetElementId) as MEPBuildingConstruction;
|
||||
if(mEPBuildingConstruction != null)
|
||||
return new MEPBuildingConstructionWrapper(mEPBuildingConstruction);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and Sets BuildingConstructionClass
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Building Infiltration Class")]
|
||||
[TypeConverter(typeof(HVACLoadConstructionClassConverter))]
|
||||
[RevitVersion(ProductType.MEP)]
|
||||
public HVACLoadConstructionClass BuildingConstructionClass
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.BuildingConstructionClass;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.BuildingConstructionClass = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Project Phase
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Project Phase")]
|
||||
[TypeConverter(typeof(ElementIdConverter<Phase>))]
|
||||
public ElementId ProjectPhase
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.ProjectPhase;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.ProjectPhase = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Sliver Space Tolerance
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Sliver Space Tolerance")]
|
||||
public Double SliverSpaceTolerance
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.SliverSpaceTolerance;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.SliverSpaceTolerance = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Export Complexity
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Export Complexity")]
|
||||
[TypeConverter(typeof(ExportComplexityConverter))]
|
||||
public gbXMLExportComplexity ExportComplexity
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.ExportComplexity;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.ExportComplexity = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Export Default Values
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Export Default Values")]
|
||||
[RevitVersion(ProductType.MEP)]
|
||||
public bool ExportDefaultValues
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.ExportDefaults;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.ExportDefaults = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and Sets ProjectReportType
|
||||
/// </summary>
|
||||
[Category("Detailed Model"), DisplayName("Report Type")]
|
||||
[TypeConverter(typeof(HVACLoadLoadsReportTypeConverter))]
|
||||
[RevitVersion(ProductType.MEP)]
|
||||
public HVACLoadLoadsReportType ProjectReportType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings.ProjectReportType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_energyDataSettings.ProjectReportType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets Project Location
|
||||
/// </summary>
|
||||
[DisplayName("Project Location"), TypeConverter(typeof(ProjectLocationConverter)), RevitVersion(ProductType.MEP, ProductType.Architecture)]
|
||||
public ProjectLocation ProjectLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_document.ActiveProjectLocation;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_document.ActiveProjectLocation = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets Site Location
|
||||
/// </summary>
|
||||
[DisplayName("Site Location"), TypeConverter(typeof(WrapperConverter)), RevitVersion(ProductType.MEP, ProductType.Architecture)]
|
||||
public SiteLocationWrapper SiteLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SiteLocationWrapper(m_document.SiteLocation);
|
||||
}
|
||||
}
|
||||
|
||||
#region IWrapper Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public object Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_energyDataSettings;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "";
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Mechanical;
|
||||
using ConstructionType = Autodesk.Revit.DB.Analysis.ConstructionType;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper class for MEPBuildingConstruction
|
||||
/// </summary>
|
||||
public class MEPBuildingConstructionWrapper : IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// MEPBuildingConstruction
|
||||
/// </summary>
|
||||
private MEPBuildingConstruction m_mEPBuildingConstruction;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes private variables.
|
||||
/// </summary>
|
||||
/// <param name="mEPBuildingConstruction">MEPBuildingConstruction</param>
|
||||
public MEPBuildingConstructionWrapper(MEPBuildingConstruction mEPBuildingConstruction)
|
||||
{
|
||||
m_mEPBuildingConstruction = mEPBuildingConstruction;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or sets Roofs
|
||||
/// </summary>
|
||||
[DisplayName("Roofs")]
|
||||
public ConstructionWrapper Roof
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Roof));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Roof, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Exterior Walls
|
||||
/// </summary>
|
||||
[DisplayName("Exterior Walls")]
|
||||
public ConstructionWrapper ExteriorWall
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.ExteriorWall));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.ExteriorWall, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Interior Walls
|
||||
/// </summary>
|
||||
[DisplayName("Interior Walls")]
|
||||
public ConstructionWrapper InteriorWall
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.InteriorWall));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.InteriorWall, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Ceilings
|
||||
/// </summary>
|
||||
[DisplayName("Ceilings")]
|
||||
public ConstructionWrapper Ceiling
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Ceiling));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Ceiling, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Doors
|
||||
/// </summary>
|
||||
[DisplayName("Doors")]
|
||||
public ConstructionWrapper Door
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Door));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Door, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Slabs
|
||||
/// </summary>
|
||||
[DisplayName("Slabs")]
|
||||
public ConstructionWrapper Slab
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Slab));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Slab, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Floors
|
||||
/// </summary>
|
||||
[DisplayName("Floors")]
|
||||
public ConstructionWrapper Floor
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Floor));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Floor, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Exterior Windows
|
||||
/// </summary>
|
||||
[DisplayName("Exterior Windows")]
|
||||
public ConstructionWrapper ExteriorWindow
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.ExteriorWindow));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.ExteriorWindow, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Interior Windows
|
||||
/// </summary>
|
||||
[DisplayName("Interior Windows")]
|
||||
public ConstructionWrapper InteriorWindow
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.ExteriorWindow));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.ExteriorWindow, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Skylights
|
||||
/// </summary>
|
||||
[DisplayName("Skylights")]
|
||||
public ConstructionWrapper Skylight
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ConstructionWrapper(m_mEPBuildingConstruction.GetBuildingConstruction(ConstructionType.Skylight));
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.SetBuildingConstruction(ConstructionType.Skylight, value.Handle as Construction);
|
||||
}
|
||||
}
|
||||
|
||||
#region IWrapper Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public object Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_mEPBuildingConstruction;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_mEPBuildingConstruction.Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_mEPBuildingConstruction.Name = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Get constructions
|
||||
/// </summary>
|
||||
/// <param name="constructionType">ConstructionType</param>
|
||||
/// <returns>Related Constructions specified by constructionTypes</returns>
|
||||
public ICollection<Construction> GetConstructions(ConstructionType constructionType)
|
||||
{
|
||||
return m_mEPBuildingConstruction.GetConstructions(constructionType);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.ApplicationServices;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper class for ProjectInfo
|
||||
/// </summary>
|
||||
public class ProjectInfoWrapper : IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// ProjectInfo
|
||||
/// </summary>
|
||||
private Autodesk.Revit.DB.ProjectInfo m_projectInfo;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes private variables.
|
||||
/// </summary>
|
||||
/// <param name="projectInfo">ProjectInfo</param>
|
||||
public ProjectInfoWrapper(Autodesk.Revit.DB.ProjectInfo projectInfo)
|
||||
{
|
||||
m_projectInfo = projectInfo;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets gbXMLSettings
|
||||
/// </summary>
|
||||
[Category("Energy Analysis"), DisplayName("Energy Settings")]
|
||||
[TypeConverter(typeof(WrapperConverter))]
|
||||
[RevitVersion(ProductType.MEP, ProductType.Architecture)]
|
||||
public ICustomTypeDescriptor EnergyDataSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return new WrapperCustomDescriptor(new EnergyDataSettingsWrapper(m_projectInfo.Document));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Project Issue Data
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Project Issue Data")]
|
||||
public String IssueDate
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.IssueDate;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.IssueDate = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Project Status
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Project Status")]
|
||||
public String Status
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.Status;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.Status = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Client Name
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Client Name")]
|
||||
public String ClientName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.ClientName;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.ClientName = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Project Address
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Project Address")]
|
||||
public String Address
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.Address;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.Address = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Project Number
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Project Number")]
|
||||
public String Number
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.Number;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.Number = value;
|
||||
}
|
||||
}
|
||||
|
||||
#region IWrapper Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public object Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
[Category("Other"), DisplayName("Project Name")]
|
||||
public String Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_projectInfo.Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_projectInfo.Name = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper class for SiteLocation
|
||||
/// </summary>
|
||||
public class SiteLocationWrapper : IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// SiteLocation
|
||||
/// </summary>
|
||||
private SiteLocation m_siteLocation;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes private variables.
|
||||
/// </summary>
|
||||
/// <param name="siteLocation"></param>
|
||||
public SiteLocationWrapper(SiteLocation siteLocation)
|
||||
{
|
||||
m_siteLocation = siteLocation;
|
||||
//m_citys = RevitStartInfo.RevitApp.Cities;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or sets TimeZone
|
||||
/// </summary>
|
||||
[DisplayName("Time Zone"), TypeConverter(typeof(TimeZoneConverter))]
|
||||
public String? TimeZone
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetTimeZoneFromDouble(m_siteLocation.TimeZone);
|
||||
}
|
||||
//set
|
||||
//{
|
||||
// m_siteLocation.TimeZone = GetTimeZoneFromString(value);
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Longitude
|
||||
/// </summary>
|
||||
[DisplayName("Longitude"), TypeConverter(typeof(AngleConverter))]
|
||||
public double Longitude
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_siteLocation.Longitude;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_siteLocation.Longitude = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Latitude
|
||||
/// </summary>
|
||||
[DisplayName("Latitude"), TypeConverter(typeof(AngleConverter))]
|
||||
public double Latitude
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_siteLocation.Latitude;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_siteLocation.Latitude = value;
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("City"), TypeConverter(typeof(CityConverter))]
|
||||
public City? City
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetCityFromPosition(Latitude, Longitude);
|
||||
}
|
||||
set
|
||||
{
|
||||
if(value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_siteLocation.Latitude = value.Latitude;
|
||||
m_siteLocation.Longitude = value.Longitude;
|
||||
m_siteLocation.TimeZone = value.TimeZone;
|
||||
}
|
||||
}
|
||||
|
||||
private City? GetCityFromPosition(double latitude, double longitude)
|
||||
{
|
||||
if(RevitStartInfo.RevitApp == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (City city in RevitStartInfo.RevitApp.Cities)
|
||||
{
|
||||
if (DoubleEquals(city.Latitude, latitude) && DoubleEquals(city.Longitude, longitude))
|
||||
return city;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool DoubleEquals(double x, double y)
|
||||
{
|
||||
return Math.Abs(x - y) < 1E-9;
|
||||
}
|
||||
|
||||
#region IWrapper Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public object Handle
|
||||
{
|
||||
get { return m_siteLocation; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public String Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_siteLocation.Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_siteLocation.Name = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Get time zone double value from time zone string
|
||||
/// </summary>
|
||||
/// <param name="value">time zone string</param>
|
||||
/// <returns>the value of time zone</returns>
|
||||
private double GetTimeZoneFromString(string value)
|
||||
{
|
||||
//i.e. convert "(GMT-12:00) International Date Line West" to 12.0
|
||||
//i.e. convert "(GMT-03:30) Newfoundland" to 3.30
|
||||
string timeZoneDouble = value.Substring(4, value.IndexOf(')') - 4).Replace(':', '.').Trim();
|
||||
if (string.IsNullOrEmpty(timeZoneDouble))
|
||||
return 0d;
|
||||
else
|
||||
return Double.Parse(timeZoneDouble);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get time zone display string from time zone value
|
||||
/// </summary>
|
||||
/// <param name="timeZone">zone value</param>
|
||||
/// <returns>display string</returns>
|
||||
private string? GetTimeZoneFromDouble(double timeZone)
|
||||
{
|
||||
// e.g. get "(GMT-04:00) Santiago" from double number 4.0
|
||||
// should find the last one who matches the time zone
|
||||
string? lastTimeZone = null;
|
||||
foreach (string tmpTimeZone in RevitStartInfo.TimeZones)
|
||||
{
|
||||
object tmpZone = this.GetTimeZoneFromString(tmpTimeZone);
|
||||
if ((double)tmpZone == timeZone)
|
||||
lastTimeZone = tmpTimeZone;
|
||||
}
|
||||
return lastTimeZone;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
//
|
||||
// (C) Copyright 2003-2009 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.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class WrapperCustomDescriptor : ICustomTypeDescriptor, IWrapper
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Handle object
|
||||
/// </summary>
|
||||
object m_handle = new object() ;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes handle object
|
||||
/// </summary>
|
||||
/// <param name="handle">Handle object</param>
|
||||
public WrapperCustomDescriptor(object handle)
|
||||
{
|
||||
m_handle = handle;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets handle object
|
||||
/// </summary>
|
||||
public object Handle
|
||||
{
|
||||
get { return m_handle; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle object if it has the Name property,
|
||||
/// otherwise returns Handle.ToString().
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
MethodInfo? mi = this.Handle.GetType().GetMethod("get_Name", new Type[0]);
|
||||
if (mi != null)
|
||||
{
|
||||
object? name = mi.Invoke(this.Handle, new object[0]);
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
string? tmp = name.ToString();
|
||||
if(tmp != null)
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
string? tmp2 =Handle.ToString();
|
||||
if(tmp2 != null)
|
||||
return tmp2;
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
#region ICustomTypeDescriptor Members
|
||||
|
||||
/// <summary>
|
||||
/// Returns a collection of custom attributes for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>Handle's attributes</returns>
|
||||
public AttributeCollection GetAttributes()
|
||||
{
|
||||
return TypeDescriptor.GetAttributes(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the class name of this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>Handle's class name</returns>
|
||||
public string? GetClassName()
|
||||
{
|
||||
return TypeDescriptor.GetClassName(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>The name of handle object</returns>
|
||||
public string? GetComponentName()
|
||||
{
|
||||
return TypeDescriptor.GetComponentName(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a type converter for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>The converter of the handle</returns>
|
||||
public TypeConverter GetConverter()
|
||||
{
|
||||
return TypeDescriptor.GetConverter(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the default event for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>An EventDescriptor that represents the default event for this object,
|
||||
/// or null if this object does not have events.</returns>
|
||||
public EventDescriptor? GetDefaultEvent()
|
||||
{
|
||||
return TypeDescriptor.GetDefaultEvent(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the default property for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>A PropertyDescriptor that represents the default property for this object,
|
||||
/// or null if this object does not have properties.</returns>
|
||||
public PropertyDescriptor? GetDefaultProperty()
|
||||
{
|
||||
return TypeDescriptor.GetDefaultProperty(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an editor of the specified type for this instance of a component.
|
||||
/// </summary>
|
||||
/// <param name="editorBaseType">A Type that represents the editor for this object. </param>
|
||||
/// <returns>An Object of the specified type that is the editor for this object,
|
||||
/// or null if the editor cannot be found.</returns>
|
||||
public object? GetEditor(Type editorBaseType)
|
||||
{
|
||||
return TypeDescriptor.GetEditor(m_handle, editorBaseType, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the events for this instance of a component using the specified attribute array as a filter.
|
||||
/// </summary>
|
||||
/// <param name="attributes">An array of type Attribute that is used as a filter. </param>
|
||||
/// <returns>An EventDescriptorCollection that represents the filtered events for this component instance.</returns>
|
||||
public EventDescriptorCollection GetEvents(Attribute[]? attributes)
|
||||
{
|
||||
return TypeDescriptor.GetEvents(m_handle, attributes, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the events for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>An EventDescriptorCollection that represents the events for this component instance.</returns>
|
||||
public EventDescriptorCollection GetEvents()
|
||||
{
|
||||
return TypeDescriptor.GetEvents(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the properties for this instance of a component using the attribute array as a filter.
|
||||
/// </summary>
|
||||
/// <param name="attributes">An array of type Attribute that is used as a filter.</param>
|
||||
/// <returns>A PropertyDescriptorCollection that
|
||||
/// represents the filtered properties for this component instance.</returns>
|
||||
public PropertyDescriptorCollection GetProperties(Attribute[]? attributes)
|
||||
{
|
||||
// get handle's properties
|
||||
PropertyDescriptorCollection collection = TypeDescriptor.GetProperties(m_handle, attributes, false);
|
||||
// create empty collection
|
||||
PropertyDescriptorCollection collection2 = new PropertyDescriptorCollection(new PropertyDescriptor[0]);
|
||||
|
||||
// filter properties by RevitVersionAttribute.
|
||||
// if there is RevitVersionAttribute specified and the designated names does not
|
||||
// contain current Revit version, the property will not be exposed.
|
||||
foreach (PropertyDescriptor pd in collection)
|
||||
{
|
||||
bool matchRevitVersion = true;
|
||||
foreach (Attribute att in pd.Attributes)
|
||||
{
|
||||
RevitVersionAttribute? pfa = att as RevitVersionAttribute;
|
||||
if (pfa != null)
|
||||
{
|
||||
if (!pfa.Names.Contains(RevitStartInfo.RevitProduct))
|
||||
matchRevitVersion = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matchRevitVersion)
|
||||
collection2.Add(pd);
|
||||
}
|
||||
return collection2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the properties for this instance of a component.
|
||||
/// </summary>
|
||||
/// <returns>A PropertyDescriptorCollection that represents the properties
|
||||
/// for this component instance.</returns>
|
||||
public PropertyDescriptorCollection GetProperties()
|
||||
{
|
||||
return TypeDescriptor.GetProperties(m_handle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an object that contains the property described by the specified property descriptor.
|
||||
/// </summary>
|
||||
/// <param name="pd">A PropertyDescriptor that represents the property whose owner is to be found. </param>
|
||||
/// <returns>Handle object</returns>
|
||||
public object GetPropertyOwner(PropertyDescriptor? pd)
|
||||
{
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// overrides ToString method
|
||||
/// </summary>
|
||||
/// <returns>The name of the handle object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// (C) Copyright 2003-2009 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.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
|
||||
namespace Revit.SDK.Samples.ProjectInfo.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// wrapper interface
|
||||
/// </summary>
|
||||
public interface IWrapper
|
||||
{
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets the handle object.
|
||||
/// </summary>
|
||||
object Handle
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the handle.
|
||||
/// </summary>
|
||||
string Name
|
||||
{
|
||||
get;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#region Using directives
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#endregion
|
||||
|
||||
// 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("NewModule")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NewModule")]
|
||||
[assembly: AssemblyCopyright("Copyright 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// This sets the default COM visibility of types in the assembly to invisible.
|
||||
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all the values or you can use the default the Revision and
|
||||
// Build Numbers by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
Generated
+75
@@ -0,0 +1,75 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
[assembly: global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "VSTACSharpSamples.Properties.Resources.get_ResourceManager():System.Resources.Resou" +
|
||||
"rceManager")]
|
||||
[assembly: global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "VSTACSharpSamples.Properties.Resources.get_Culture():System.Globalization.CultureIn" +
|
||||
"fo")]
|
||||
[assembly: global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "VSTACSharpSamples.Properties.Resources.set_Culture(System.Globalization.CultureInfo" +
|
||||
"):Void")]
|
||||
|
||||
namespace VSTACSharpSamples.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VSTACSharpSamples.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?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.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: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" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</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" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</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>
|
||||
Generated
+31
@@ -0,0 +1,31 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
[assembly: global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "VSTACSharpSamples.Properties.Settings.get_Default():VSTACSharpSamples.Properties.Sett" +
|
||||
"ings")]
|
||||
|
||||
namespace VSTACSharpSamples.Properties
|
||||
{
|
||||
|
||||
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
private static Settings defaultInstance = new Settings();
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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 Autodesk;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using MacroSamples_RVT;
|
||||
using VIEW = Autodesk.Revit.DB.View;
|
||||
|
||||
namespace Revit.SDK.Samples.QuickPrint.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Automatic print of all of a certain view type, to the default printer .
|
||||
/// </summary>
|
||||
public class QuickPrint
|
||||
{
|
||||
private Document? m_doc = null;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor without parameter is not allowed.
|
||||
/// </summary>
|
||||
private QuickPrint()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor wit parameter used to call this sample.
|
||||
/// </summary>
|
||||
/// <param name="doc"></param>
|
||||
public QuickPrint(ThisApplication hostDoc)
|
||||
{
|
||||
m_doc = hostDoc.ActiveUIDocument.Document;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// print the specified ViewType.
|
||||
/// </summary>
|
||||
public void Print(ViewType viewType)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_doc == null)
|
||||
return;
|
||||
Autodesk.Revit.DB.View? view = null;
|
||||
|
||||
// Create a view set to contain all view of designated type
|
||||
ViewSet views = m_doc.Application.Create.NewViewSet();
|
||||
|
||||
// Create a filter to filtrate the View Element.
|
||||
ElementClassFilter fileterView = new ElementClassFilter(typeof(VIEW));
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_doc);
|
||||
collector.WherePasses(fileterView);
|
||||
|
||||
IList<Element> arrayView = collector.ToElements();
|
||||
|
||||
// filtrate the designated type views.
|
||||
foreach (Element ee in arrayView)
|
||||
{
|
||||
view = ee as VIEW;
|
||||
if ((null != view) && (viewType == view.ViewType) && view.IsTemplate == false)
|
||||
{
|
||||
views.Insert(view);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// print
|
||||
if (!views.IsEmpty)
|
||||
{
|
||||
m_doc.Print(views);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No " + viewType.ToString() + " view to be printed!", "QuickPrint");
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
MessageBox.Show(ee.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+129
@@ -0,0 +1,129 @@
|
||||
namespace Revit.SDK.Samples.QuickPrint.CS
|
||||
{
|
||||
partial class QuickPrintDialog
|
||||
{
|
||||
/// <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.PlanType = new System.Windows.Forms.CheckBox();
|
||||
this.ElevationType = new System.Windows.Forms.CheckBox();
|
||||
this.SectionType = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PlanType
|
||||
//
|
||||
this.PlanType.AutoSize = true;
|
||||
this.PlanType.Location = new System.Drawing.Point(40, 30);
|
||||
this.PlanType.Name = "PlanType";
|
||||
this.PlanType.Size = new System.Drawing.Size(75, 17);
|
||||
this.PlanType.TabIndex = 0;
|
||||
this.PlanType.Text = "FloorPlans";
|
||||
this.PlanType.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ElevationType
|
||||
//
|
||||
this.ElevationType.AutoSize = true;
|
||||
this.ElevationType.Location = new System.Drawing.Point(40, 53);
|
||||
this.ElevationType.Name = "ElevationType";
|
||||
this.ElevationType.Size = new System.Drawing.Size(75, 17);
|
||||
this.ElevationType.TabIndex = 1;
|
||||
this.ElevationType.Text = "Elevations";
|
||||
this.ElevationType.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// SectionType
|
||||
//
|
||||
this.SectionType.AutoSize = true;
|
||||
this.SectionType.Location = new System.Drawing.Point(40, 76);
|
||||
this.SectionType.Name = "SectionType";
|
||||
this.SectionType.Size = new System.Drawing.Size(67, 17);
|
||||
this.SectionType.TabIndex = 2;
|
||||
this.SectionType.Text = "Sections";
|
||||
this.SectionType.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.PlanType);
|
||||
this.groupBox1.Controls.Add(this.SectionType);
|
||||
this.groupBox1.Controls.Add(this.ElevationType);
|
||||
this.groupBox1.Location = new System.Drawing.Point(10, 10);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(202, 114);
|
||||
this.groupBox1.TabIndex = 3;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Choose View Type";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.Location = new System.Drawing.Point(42, 144);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 4;
|
||||
this.button1.Text = "Cancel";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button2.Location = new System.Drawing.Point(136, 144);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||
this.button2.TabIndex = 5;
|
||||
this.button2.Text = "OK";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// QuickPrintDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(223, 180);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Name = "QuickPrintDialog";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "QuickPrint";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public System.Windows.Forms.CheckBox PlanType;
|
||||
public System.Windows.Forms.CheckBox ElevationType;
|
||||
public System.Windows.Forms.CheckBox SectionType;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Revit.SDK.Samples.QuickPrint.CS
|
||||
{
|
||||
public partial class QuickPrintDialog : Form
|
||||
{
|
||||
public QuickPrintDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -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,91 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.Rooms.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Get some properties of a slab , such as Level, Type name, Span direction,
|
||||
/// Material name, Thickness, and Young Modulus for the slab's Material.
|
||||
/// </summary>
|
||||
public class SamplesRoom
|
||||
{
|
||||
// #region Class ctor implemetation
|
||||
/// <summary>
|
||||
/// Ctor without parameter is not allowed
|
||||
/// </summary>
|
||||
private SamplesRoom()
|
||||
{
|
||||
// no codes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor of StructuralLayerFunction
|
||||
/// </summary>
|
||||
public SamplesRoom(ThisApplication hostApp)
|
||||
{
|
||||
// Init for varialbes
|
||||
// this document handler
|
||||
m_app = hostApp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run sample Rooms
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
//create a new instance of class Data
|
||||
if (m_app == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
RoomsData data = new RoomsData(m_app, m_app.ActiveUIDocument.Document.Application);
|
||||
//create a form to display the room information
|
||||
using (roomsInformationForm infoForm = new roomsInformationForm(data))
|
||||
{
|
||||
infoForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// If there are something wrong, give error information
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
#region Class member variable
|
||||
ThisApplication? m_app;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
|
||||
namespace Revit.SDK.Samples.Rooms.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// UI to display the rooms information
|
||||
/// </summary>
|
||||
public partial class roomsInformationForm : System.Windows.Forms.Form
|
||||
{
|
||||
RoomsData? m_data;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
public roomsInformationForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overload the constructor
|
||||
/// </summary>
|
||||
/// <param name="data">an instanc of Data class</param>
|
||||
public roomsInformationForm(RoomsData data)
|
||||
{
|
||||
m_data = data;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// add rooms of list roomsWithTag to the listview
|
||||
/// </summary>
|
||||
private void DisplayRooms(ReadOnlyCollection<Room> roomList, bool isHaveTag)
|
||||
{
|
||||
String? propertyValue = null; //value of department
|
||||
String? departmentName = null; //department name
|
||||
Double areaValue = 0.0; //room area
|
||||
|
||||
//add rooms to the listview
|
||||
foreach (Room tmpRoom in roomList)
|
||||
{
|
||||
long idValue = tmpRoom.Id.Value;
|
||||
string roomId = idValue.ToString();
|
||||
//create a list view Item
|
||||
ListViewItem tmpItem = new ListViewItem(roomId);
|
||||
tmpItem.SubItems.Add(tmpRoom.Name); //display room name.
|
||||
tmpItem.SubItems.Add(tmpRoom.Number); //display room number.
|
||||
tmpItem.SubItems.Add(tmpRoom.Level.Name); //display the level
|
||||
|
||||
//get department name from Department property
|
||||
departmentName = m_data?.GetProperty(tmpRoom, BuiltInParameter.ROOM_DEPARTMENT);
|
||||
tmpItem.SubItems.Add(departmentName);
|
||||
|
||||
//get property value
|
||||
propertyValue = m_data?.GetProperty(tmpRoom, BuiltInParameter.ROOM_AREA);
|
||||
//get the area value
|
||||
if (propertyValue != null)
|
||||
areaValue = Double.Parse(propertyValue);
|
||||
tmpItem.SubItems.Add(propertyValue + " SF");
|
||||
//display whether the room with tag or not
|
||||
if (isHaveTag)
|
||||
{
|
||||
tmpItem.SubItems.Add("Yes");
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpItem.SubItems.Add("No");
|
||||
}
|
||||
|
||||
//add the item to the listview
|
||||
roomsListView.Items.Add(tmpItem);
|
||||
|
||||
//add the area to the department
|
||||
if (departmentName != null)
|
||||
m_data?.CalculateDepartmentArea(departmentName, areaValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// when the form was loaded, display the room information
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void RoomInfoForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
roomsListView.Items.Clear();
|
||||
if (m_data == null)
|
||||
return;
|
||||
//add rooms in the list roomsWithoutTag to the listview
|
||||
this.DisplayRooms(m_data.RoomsWithoutTag, false);
|
||||
//add rooms in the list roomsWithTag to the listview
|
||||
this.DisplayRooms(m_data.RoomsWithTag, true);
|
||||
|
||||
//display the amount of the rooms
|
||||
String numberOfRooms = "The number of rooms: " + m_data.Rooms.Count.ToString();
|
||||
allRoomLabel.Text = numberOfRooms;
|
||||
|
||||
//display the amount of the rooms without tags
|
||||
String roomsWithoutTag = "The number of rooms without tags: " +
|
||||
m_data.RoomsWithoutTag.Count.ToString();
|
||||
tagLabel.Text = roomsWithoutTag;
|
||||
|
||||
// if all the rooms have tags ,the button will be set to disable
|
||||
if (0 == m_data.RoomsWithoutTag.Count)
|
||||
{
|
||||
addTagsButton.Enabled = false;
|
||||
}
|
||||
|
||||
//display the total area of each department
|
||||
this.DisplayDartmentsInfo();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// create room tags for the rooms without tags
|
||||
/// </summary>
|
||||
private void addTagButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
//close the form
|
||||
if (m_data == null)
|
||||
return;
|
||||
m_data.CreateTags();
|
||||
MessageBox.Show("Add tags to rooms successfully", "Macro Sample", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// reorder room number
|
||||
/// </summary>
|
||||
private void reorderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (m_data == null)
|
||||
return;
|
||||
m_data.ReorderRooms();
|
||||
MessageBox.Show("Reoder rooms successfully", "Macro Sample", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// display total room informations for each department
|
||||
/// </summary>
|
||||
private void DisplayDartmentsInfo()
|
||||
{
|
||||
if (m_data == null)
|
||||
return;
|
||||
for (int i = 0; i < m_data.DepartmentInfos.Count; i++)
|
||||
{
|
||||
//create a listview item
|
||||
ListViewItem tmpItem = new ListViewItem(m_data.DepartmentInfos[i].DepartmentName);
|
||||
tmpItem.SubItems.Add(m_data.DepartmentInfos[i].DepartmentAreaValue.ToString() + " SF");
|
||||
departmentsListView.Items.Add(tmpItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// export the total area of each department to a Excel file
|
||||
/// </summary>
|
||||
private void exportButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
//create a save file dialog
|
||||
if (m_data == null)
|
||||
return;
|
||||
using (SaveFileDialog sfdlg = new SaveFileDialog())
|
||||
{
|
||||
sfdlg.Title = "Export area of department to Excel file";
|
||||
sfdlg.Filter = "CSV(command delimited)(*.csv)|*.csv";
|
||||
sfdlg.RestoreDirectory = true;
|
||||
|
||||
if (DialogResult.OK == sfdlg.ShowDialog())
|
||||
{
|
||||
m_data.ExportFile(sfdlg.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+248
@@ -0,0 +1,248 @@
|
||||
namespace Revit.SDK.Samples.Rooms.CS
|
||||
{
|
||||
partial class roomsInformationForm
|
||||
{
|
||||
#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.allRoomLabel = new System.Windows.Forms.Label();
|
||||
this.addTagsButton = new System.Windows.Forms.Button();
|
||||
this.closeButton = new System.Windows.Forms.Button();
|
||||
this.roomsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.roomsListView = new System.Windows.Forms.ListView();
|
||||
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader8 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader9 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader10 = new System.Windows.Forms.ColumnHeader();
|
||||
this.tagLabel = new System.Windows.Forms.Label();
|
||||
this.reorderButton = new System.Windows.Forms.Button();
|
||||
this.exportButton = new System.Windows.Forms.Button();
|
||||
this.departmentGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.departmentsListView = new System.Windows.Forms.ListView();
|
||||
this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader7 = new System.Windows.Forms.ColumnHeader();
|
||||
this.roomsGroupBox.SuspendLayout();
|
||||
this.departmentGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// allRoomLabel
|
||||
//
|
||||
this.allRoomLabel.AutoSize = true;
|
||||
this.allRoomLabel.Location = new System.Drawing.Point(272, 349);
|
||||
this.allRoomLabel.Name = "allRoomLabel";
|
||||
this.allRoomLabel.Size = new System.Drawing.Size(112, 13);
|
||||
this.allRoomLabel.TabIndex = 9;
|
||||
this.allRoomLabel.Text = "amountOfRoomsLabel";
|
||||
//
|
||||
// addTagsButton
|
||||
//
|
||||
this.addTagsButton.Location = new System.Drawing.Point(431, 412);
|
||||
this.addTagsButton.Name = "addTagsButton";
|
||||
this.addTagsButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.addTagsButton.TabIndex = 1;
|
||||
this.addTagsButton.Text = "&Add Tags";
|
||||
this.addTagsButton.UseVisualStyleBackColor = true;
|
||||
this.addTagsButton.Click += new System.EventHandler(this.addTagButton_Click);
|
||||
//
|
||||
// closeButton
|
||||
//
|
||||
this.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.closeButton.Location = new System.Drawing.Point(431, 499);
|
||||
this.closeButton.Name = "closeButton";
|
||||
this.closeButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.closeButton.TabIndex = 4;
|
||||
this.closeButton.Text = "&Close";
|
||||
this.closeButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// roomsGroupBox
|
||||
//
|
||||
this.roomsGroupBox.Controls.Add(this.roomsListView);
|
||||
this.roomsGroupBox.Location = new System.Drawing.Point(2, 12);
|
||||
this.roomsGroupBox.Name = "roomsGroupBox";
|
||||
this.roomsGroupBox.Size = new System.Drawing.Size(515, 303);
|
||||
this.roomsGroupBox.TabIndex = 7;
|
||||
this.roomsGroupBox.TabStop = false;
|
||||
this.roomsGroupBox.Text = "Rooms information";
|
||||
//
|
||||
// roomsListView
|
||||
//
|
||||
this.roomsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader1,
|
||||
this.columnHeader4,
|
||||
this.columnHeader2,
|
||||
this.columnHeader3,
|
||||
this.columnHeader8,
|
||||
this.columnHeader9,
|
||||
this.columnHeader10});
|
||||
this.roomsListView.FullRowSelect = true;
|
||||
this.roomsListView.GridLines = true;
|
||||
this.roomsListView.Location = new System.Drawing.Point(5, 19);
|
||||
this.roomsListView.MultiSelect = false;
|
||||
this.roomsListView.Name = "roomsListView";
|
||||
this.roomsListView.Size = new System.Drawing.Size(504, 275);
|
||||
this.roomsListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||
this.roomsListView.TabIndex = 5;
|
||||
this.roomsListView.UseCompatibleStateImageBehavior = false;
|
||||
this.roomsListView.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "ID";
|
||||
this.columnHeader1.Width = 80;
|
||||
//
|
||||
// columnHeader4
|
||||
//
|
||||
this.columnHeader4.Text = "Name";
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Text = "Number";
|
||||
this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// columnHeader3
|
||||
//
|
||||
this.columnHeader3.Text = "level";
|
||||
this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// columnHeader8
|
||||
//
|
||||
this.columnHeader8.Text = "Department";
|
||||
this.columnHeader8.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
this.columnHeader8.Width = 80;
|
||||
//
|
||||
// columnHeader9
|
||||
//
|
||||
this.columnHeader9.Text = "Area";
|
||||
this.columnHeader9.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
this.columnHeader9.Width = 80;
|
||||
//
|
||||
// columnHeader10
|
||||
//
|
||||
this.columnHeader10.Text = "Have tag";
|
||||
this.columnHeader10.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// tagLabel
|
||||
//
|
||||
this.tagLabel.AutoSize = true;
|
||||
this.tagLabel.Location = new System.Drawing.Point(272, 379);
|
||||
this.tagLabel.Name = "tagLabel";
|
||||
this.tagLabel.Size = new System.Drawing.Size(168, 13);
|
||||
this.tagLabel.TabIndex = 10;
|
||||
this.tagLabel.Text = "amountOfRoomsWithoutTagLabel";
|
||||
//
|
||||
// reorderButton
|
||||
//
|
||||
this.reorderButton.Location = new System.Drawing.Point(431, 441);
|
||||
this.reorderButton.Name = "reorderButton";
|
||||
this.reorderButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.reorderButton.TabIndex = 2;
|
||||
this.reorderButton.Text = "&Reorder";
|
||||
this.reorderButton.UseVisualStyleBackColor = true;
|
||||
this.reorderButton.Click += new System.EventHandler(this.reorderButton_Click);
|
||||
//
|
||||
// exportButton
|
||||
//
|
||||
this.exportButton.Location = new System.Drawing.Point(431, 470);
|
||||
this.exportButton.Name = "exportButton";
|
||||
this.exportButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.exportButton.TabIndex = 3;
|
||||
this.exportButton.Text = "&Export";
|
||||
this.exportButton.UseVisualStyleBackColor = true;
|
||||
this.exportButton.Click += new System.EventHandler(this.exportButton_Click);
|
||||
//
|
||||
// departmentGroupBox
|
||||
//
|
||||
this.departmentGroupBox.Controls.Add(this.departmentsListView);
|
||||
this.departmentGroupBox.Location = new System.Drawing.Point(2, 330);
|
||||
this.departmentGroupBox.Name = "departmentGroupBox";
|
||||
this.departmentGroupBox.Size = new System.Drawing.Size(264, 201);
|
||||
this.departmentGroupBox.TabIndex = 8;
|
||||
this.departmentGroupBox.TabStop = false;
|
||||
this.departmentGroupBox.Text = "Area of departments";
|
||||
//
|
||||
// departmentsListView
|
||||
//
|
||||
this.departmentsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader6,
|
||||
this.columnHeader7});
|
||||
this.departmentsListView.FullRowSelect = true;
|
||||
this.departmentsListView.GridLines = true;
|
||||
this.departmentsListView.Location = new System.Drawing.Point(6, 19);
|
||||
this.departmentsListView.Name = "departmentsListView";
|
||||
this.departmentsListView.Size = new System.Drawing.Size(252, 174);
|
||||
this.departmentsListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||
this.departmentsListView.TabIndex = 6;
|
||||
this.departmentsListView.UseCompatibleStateImageBehavior = false;
|
||||
this.departmentsListView.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// columnHeader6
|
||||
//
|
||||
this.columnHeader6.Text = "Department";
|
||||
this.columnHeader6.Width = 120;
|
||||
//
|
||||
// columnHeader7
|
||||
//
|
||||
this.columnHeader7.Text = "Total Area";
|
||||
this.columnHeader7.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
this.columnHeader7.Width = 120;
|
||||
//
|
||||
// roomsInformationForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.closeButton;
|
||||
this.ClientSize = new System.Drawing.Size(518, 536);
|
||||
this.Controls.Add(this.departmentGroupBox);
|
||||
this.Controls.Add(this.exportButton);
|
||||
this.Controls.Add(this.reorderButton);
|
||||
this.Controls.Add(this.tagLabel);
|
||||
this.Controls.Add(this.roomsGroupBox);
|
||||
this.Controls.Add(this.closeButton);
|
||||
this.Controls.Add(this.addTagsButton);
|
||||
this.Controls.Add(this.allRoomLabel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "roomsInformationForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Room Information";
|
||||
this.Load += new System.EventHandler(this.RoomInfoForm_Load);
|
||||
this.roomsGroupBox.ResumeLayout(false);
|
||||
this.departmentGroupBox.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label allRoomLabel;
|
||||
private System.Windows.Forms.Button addTagsButton;
|
||||
private System.Windows.Forms.Button closeButton;
|
||||
private System.Windows.Forms.GroupBox roomsGroupBox;
|
||||
private System.Windows.Forms.ListView roomsListView;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader4;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader2;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader3;
|
||||
private System.Windows.Forms.Label tagLabel;
|
||||
private System.Windows.Forms.Button reorderButton;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader8;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader9;
|
||||
private System.Windows.Forms.Button exportButton;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader10;
|
||||
private System.Windows.Forms.GroupBox departmentGroupBox;
|
||||
private System.Windows.Forms.ListView departmentsListView;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader6;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader7;
|
||||
}
|
||||
}
|
||||
@@ -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,419 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
|
||||
using System.Diagnostics;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.Rooms.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Iterates through the rooms in the project and get the information of all the rooms
|
||||
/// </summary>
|
||||
public class RoomsData
|
||||
{
|
||||
ThisApplication m_thisApp;
|
||||
Autodesk.Revit.ApplicationServices.Application m_application;
|
||||
|
||||
List<Room> m_rooms = new List<Room>(); //a list to store all rooms in the project
|
||||
List<RoomTag> m_roomTags = new List<RoomTag>(); //a list to store all room tags in the project
|
||||
List<Room> m_roomsWithTag = new List<Room>(); //a list to store all rooms with tag
|
||||
List<Room> m_roomsWithoutTag = new List<Room>(); //a list to store all rooms without tag
|
||||
List<DepartmentInfo> m_departmentInfos = new List<DepartmentInfo>(); //a list to store department
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// a class to stor the value of property Area and Department
|
||||
/// </summary>
|
||||
public struct DepartmentInfo
|
||||
{
|
||||
String m_departmentName;
|
||||
double m_departmentAreaValue;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
public DepartmentInfo(String departmentName, double areaValue)
|
||||
{
|
||||
m_departmentName = departmentName;
|
||||
m_departmentAreaValue = areaValue;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// the name of department
|
||||
/// </summary>
|
||||
public String DepartmentName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_departmentName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// the total area of the rooms in department
|
||||
/// </summary>
|
||||
public double DepartmentAreaValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_departmentAreaValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// a list of all department
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<DepartmentInfo> DepartmentInfos
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ReadOnlyCollection<DepartmentInfo>(m_departmentInfos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// a list of all the rooms in the project
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<Room> Rooms
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ReadOnlyCollection<Room>(m_rooms);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// a list of all the room tags in the project
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<RoomTag> RoomTags
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ReadOnlyCollection<RoomTag>(m_roomTags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// a list of the rooms that had tag
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<Room> RoomsWithTag
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ReadOnlyCollection<Room>(m_roomsWithTag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// a list of the rooms without tags
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<Room> RoomsWithoutTag
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ReadOnlyCollection<Room>(m_roomsWithoutTag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///constructor
|
||||
/// </summary>
|
||||
public RoomsData(ThisApplication hostApp, Autodesk.Revit.ApplicationServices.Application application)
|
||||
{
|
||||
m_application = application;
|
||||
m_thisApp = hostApp;
|
||||
|
||||
RoomFilter roomFilter = new RoomFilter();
|
||||
RoomTagFilter roomTagFilter = new RoomTagFilter();
|
||||
LogicalOrFilter orFilter = new LogicalOrFilter(roomFilter, roomTagFilter);
|
||||
|
||||
FilteredElementIterator elementIterator =
|
||||
(new FilteredElementCollector(m_thisApp.ActiveUIDocument.Document)).WherePasses(orFilter).GetElementIterator();
|
||||
elementIterator.Reset();
|
||||
|
||||
// try to find all the rooms and room tags in the project and add to the list
|
||||
while (elementIterator.MoveNext())
|
||||
{
|
||||
object obj = elementIterator.Current;
|
||||
|
||||
// find the rooms, skip those rooms which don't locate at Level yet.
|
||||
Room? tmpRoom = obj as Room;
|
||||
if (null != tmpRoom && null != tmpRoom.Level)
|
||||
{
|
||||
m_rooms.Add(tmpRoom);
|
||||
continue;
|
||||
}
|
||||
|
||||
// find the room tags
|
||||
RoomTag? tmpTag = obj as RoomTag;
|
||||
if (null != tmpTag)
|
||||
{
|
||||
m_roomTags.Add(tmpTag);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//find out the rooms that without tag
|
||||
ClassifyRooms();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// find out the rooms that without tag
|
||||
/// </summary>
|
||||
private void ClassifyRooms()
|
||||
{
|
||||
//copy the all the elements in list Rooms to list RoomsWithoutTag
|
||||
m_roomsWithoutTag.AddRange(m_rooms);
|
||||
|
||||
//get the room id from room tag via room property
|
||||
//if find the room id in list RoomWithoutTag,
|
||||
//add it to the list RoomWithTag and delete it from list RoomWithoutTag
|
||||
foreach (RoomTag tmpTag in m_roomTags)
|
||||
{
|
||||
long idValue = tmpTag.Room.Id.Value;
|
||||
m_roomsWithTag.Add(tmpTag.Room);
|
||||
//search the id for list RoomWithoutTag
|
||||
foreach (Room tmpRoom in m_rooms)
|
||||
{
|
||||
if (idValue == tmpRoom.Id.Value)
|
||||
{
|
||||
m_roomsWithoutTag.Remove(tmpRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// create the room tag for the rooms without tags
|
||||
/// </summary>
|
||||
public void CreateTags()
|
||||
{
|
||||
foreach (Room tmpRoom in m_roomsWithoutTag)
|
||||
{
|
||||
//get the location point of the room
|
||||
LocationPoint? locPoint = tmpRoom.Location as LocationPoint;
|
||||
if (locPoint != null)
|
||||
{
|
||||
//create a instance of UV class
|
||||
double u = locPoint.Point.X;
|
||||
double v = locPoint.Point.Y;
|
||||
|
||||
UV point = m_application.Create.NewUV(u, v);
|
||||
|
||||
//create room tag
|
||||
m_thisApp.ActiveUIDocument.Document.Create.NewRoomTag(new LinkElementId(tmpRoom.Id), point, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// sort all the rooms by ascending order according their coordinate
|
||||
/// </summary>
|
||||
private void SortRooms()
|
||||
{
|
||||
LocationPoint? tmpPoint = null;
|
||||
LocationPoint? roomPoint = null;
|
||||
Room? listRoom = null;
|
||||
int result = 0;
|
||||
int flag = 0;
|
||||
int amount = m_rooms.Count;
|
||||
|
||||
//sort the rooms according their location point
|
||||
for (int i = 0; i < amount - 1; i++)
|
||||
{
|
||||
Room tmpRoom = m_rooms[i];
|
||||
for (int j = i + 1; j < amount; j++)
|
||||
{
|
||||
tmpPoint = tmpRoom.Location as LocationPoint;
|
||||
listRoom = m_rooms[j];
|
||||
roomPoint = listRoom.Location as LocationPoint;
|
||||
|
||||
//rooms in different level
|
||||
if (tmpPoint?.Point.Z > roomPoint?.Point.Z)
|
||||
{
|
||||
tmpRoom = listRoom;
|
||||
result = j;
|
||||
//if tmpRoom was changed,set flag to 1
|
||||
flag = 1;
|
||||
}
|
||||
//the two rooms in the same level
|
||||
else if (tmpPoint?.Point.Z == roomPoint?.Point.Z)
|
||||
{
|
||||
if (tmpPoint?.Point.X > roomPoint?.Point.X)
|
||||
{
|
||||
tmpRoom = listRoom;
|
||||
result = j;
|
||||
flag = 1;
|
||||
}
|
||||
else if (tmpPoint?.Point.X == roomPoint?.Point.X &&
|
||||
tmpPoint?.Point.Y > roomPoint?.Point.Y)
|
||||
{
|
||||
tmpRoom = listRoom;
|
||||
result = j;
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if flag equals 1 ,move the room to the front of list
|
||||
if (1 == flag)
|
||||
{
|
||||
Room tempRoom = m_rooms[i];
|
||||
m_rooms[i] = m_rooms[result];
|
||||
m_rooms[result] = tempRoom;
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// reorder all the rooms' number
|
||||
/// </summary>
|
||||
/// <param name="roomlist">a list of rooms</param>
|
||||
public void ReorderRooms()
|
||||
{
|
||||
//sort all the rooms by ascending order according their coordinate
|
||||
this.SortRooms();
|
||||
|
||||
//to avoid revit display the warning message,
|
||||
//change the rooms' name to a temp name
|
||||
foreach (Room tmpRoom in m_rooms)
|
||||
{
|
||||
tmpRoom.Number += "XXX";
|
||||
}
|
||||
|
||||
//set the rooms number to a new order
|
||||
for (int i = 1; i <= m_rooms.Count; i++)
|
||||
{
|
||||
m_rooms[i - 1].Number = i.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get the room property and Department property according the property name
|
||||
/// </summary>
|
||||
/// <param name="room">a instance of room class</param>
|
||||
/// <param name="propertyName">the property name</param>
|
||||
/// <param name="proValue">the value of property</param>
|
||||
public String? GetProperty(Room room, BuiltInParameter paramEnum)
|
||||
{
|
||||
String? propertyValue = null; //the value of parameter
|
||||
|
||||
//get the parameter via the parameterId
|
||||
Parameter param = room.get_Parameter(paramEnum);
|
||||
//get the parameter's storage type
|
||||
StorageType storageType = param.StorageType;
|
||||
switch (storageType)
|
||||
{
|
||||
case StorageType.Integer:
|
||||
int iVal = param.AsInteger();
|
||||
propertyValue = iVal.ToString();
|
||||
break;
|
||||
case StorageType.String:
|
||||
String stringVal = param.AsString();
|
||||
propertyValue = stringVal;
|
||||
break;
|
||||
case StorageType.Double:
|
||||
Double dVal = param.AsDouble();
|
||||
dVal = Math.Round(dVal, 2);
|
||||
propertyValue = dVal.ToString();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return propertyValue;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// calculate the area of rooms for each department
|
||||
/// </summary>
|
||||
/// <param name="deparName">the department name</param>
|
||||
/// <param name="areaValue">the value of room area</param>
|
||||
public void CalculateDepartmentArea(String deparName, Double areaValue)
|
||||
{
|
||||
//if the array list is empty add a new instance of DepartmentArea to the list
|
||||
if (0 == m_departmentInfos.Count)
|
||||
{
|
||||
//create a new instance of DepartmentArea struct and insert it to the list
|
||||
DepartmentInfo tmpDep = new DepartmentInfo(deparName, areaValue);
|
||||
m_departmentInfos.Add(tmpDep);
|
||||
}
|
||||
else
|
||||
{
|
||||
int flag = 0;
|
||||
//find whether the department exist in the project
|
||||
for (int i = 0; i < m_departmentInfos.Count; i++)
|
||||
{
|
||||
if (deparName == m_departmentInfos[i].DepartmentName)
|
||||
{
|
||||
double tempValue = m_departmentInfos[i].DepartmentAreaValue + areaValue;
|
||||
DepartmentInfo tempInstance = new DepartmentInfo(deparName, tempValue);
|
||||
m_departmentInfos[i] = tempInstance;
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
//if found a new department,
|
||||
//create a new instance of DepartmentArea struct and insert it to the list
|
||||
if (0 == flag)
|
||||
{
|
||||
DepartmentInfo tmpDep = new DepartmentInfo(deparName, areaValue);
|
||||
m_departmentInfos.Add(tmpDep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// export data into an Excel file
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
public void ExportFile(String fileName)
|
||||
{
|
||||
//store all the information that to be exported
|
||||
String allData = "";
|
||||
|
||||
//get the project title
|
||||
String projectTitle = m_thisApp.ActiveUIDocument.Document.Title; //the name of the project
|
||||
allData += "Total Rooms area of " + projectTitle + "\n";
|
||||
allData += "Department" + "," + "Area" + "\n";
|
||||
|
||||
foreach (DepartmentInfo tmp in m_departmentInfos)
|
||||
{
|
||||
allData += tmp.DepartmentName + "," + tmp.DepartmentAreaValue + " SF\n";
|
||||
}
|
||||
|
||||
//save the information into a Excel file
|
||||
if (allData.Length > 0)
|
||||
{
|
||||
System.IO.StreamWriter exportinfo = new System.IO.StreamWriter(fileName);
|
||||
exportinfo.WriteLine(allData);
|
||||
exportinfo.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+367
@@ -0,0 +1,367 @@
|
||||
//
|
||||
// (C) Copyright 1994-2005 by Autodesk, Inc. All rights reserved.
|
||||
//
|
||||
// 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 ITS 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.
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of studs and camber sizes for beams.
|
||||
/// </summary>
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Autodesk;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
|
||||
namespace Revit.SDK.Samples.RotateFramingObjects.CS
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// rotate the objects that were selected when the command was executed.
|
||||
/// and allow the user input the amount, in degrees that the objects should be rotated.
|
||||
/// the dialog contain option for the user to specify this value is absolute or relative.
|
||||
/// </summary>
|
||||
public class RotateFramingObjects
|
||||
{
|
||||
double m_receiveRotationTextBox; // receive change of Angle
|
||||
bool m_isAbsoluteChecked; // true if moving absolute
|
||||
ThisApplication? m_app; //document data for Macro
|
||||
|
||||
public double ReceiveRotationTextBox
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_receiveRotationTextBox;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_receiveRotationTextBox = value;
|
||||
}
|
||||
}
|
||||
public bool IsAbsoluteChecked
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_isAbsoluteChecked;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_isAbsoluteChecked = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor of RotateFramingObjects
|
||||
/// </summary>
|
||||
public RotateFramingObjects()
|
||||
{ }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Ctor with ThisDocument as
|
||||
/// </summary>
|
||||
/// <param name="hostApp">ThisDocument handler</param>
|
||||
public RotateFramingObjects(ThisApplication hostApp)
|
||||
{
|
||||
m_app = hostApp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run this sample
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
if (m_app == null)
|
||||
return;
|
||||
RotateFramingObjectsForm displayForm = new RotateFramingObjectsForm(this);
|
||||
ICollection<ElementId> selection = m_app.ActiveUIDocument.Selection.GetElementIds();
|
||||
bool isSingle = true; //selection is single object
|
||||
bool isAllFamilyInstance = true; //all is not familyInstance
|
||||
|
||||
// There must be beams, braces or columns selected
|
||||
if (selection.Count == 0)
|
||||
{
|
||||
// nothing selected
|
||||
MessageBox.Show("Please select FamilyInstance.(such as column)", "RotateFramingObjects");
|
||||
return;
|
||||
}
|
||||
else if (1 != selection.Count)
|
||||
{
|
||||
|
||||
isSingle = false;
|
||||
try
|
||||
{
|
||||
if (DialogResult.OK != displayForm.ShowDialog())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// return IExternalCommand.Result.Succeeded;
|
||||
// more that one object selected
|
||||
}
|
||||
|
||||
// if the selection are familyInstance, try to get their existing rotation
|
||||
foreach (Autodesk.Revit.DB.ElementId id in selection)
|
||||
{
|
||||
FamilyInstance? familyComponent = m_app.ActiveUIDocument.Document.GetElement(id) as FamilyInstance;
|
||||
if (familyComponent != null)
|
||||
{
|
||||
if (Autodesk.Revit.DB.Structure.StructuralType.Beam == familyComponent.StructuralType
|
||||
|| Autodesk.Revit.DB.Structure.StructuralType.Brace == familyComponent.StructuralType)
|
||||
{
|
||||
// selection is a beam or brace
|
||||
string returnValue = this.FindParameter("Angle", familyComponent);
|
||||
if (displayForm.rotationTextBox != null)
|
||||
displayForm.rotationTextBox.Text = returnValue.ToString();
|
||||
|
||||
}
|
||||
else if (Autodesk.Revit.DB.Structure.StructuralType.Column == familyComponent.StructuralType)
|
||||
{
|
||||
// selection is a column
|
||||
Autodesk.Revit.DB.Location columnLocation = familyComponent.Location;
|
||||
Autodesk.Revit.DB.LocationPoint? pointLocation = columnLocation as Autodesk.Revit.DB.LocationPoint;
|
||||
if (pointLocation != null)
|
||||
{
|
||||
double temp = pointLocation.Rotation;
|
||||
string output = (Math.Round(temp * 180 / (Math.PI), 3)).ToString();
|
||||
if (displayForm.rotationTextBox != null)
|
||||
displayForm.rotationTextBox.Text = output;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// other familyInstance can not be rotated
|
||||
MessageBox.Show("Can not deal with it.", "RotateFramingObjects");
|
||||
m_app.ActiveUIDocument.Selection.GetElementIds().Add(familyComponent.Id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isSingle)
|
||||
{
|
||||
MessageBox.Show("It is a Non-FamilyInstance.", "RotateFramingObjects");
|
||||
m_app.ActiveUIDocument.Selection.GetElementIds().Add(id);
|
||||
return;
|
||||
}
|
||||
// there is some objects is not familyInstance
|
||||
//MessageBox.Show("There is Non-FamilyInstance.", "RotateFramingObjects");
|
||||
m_app.ActiveUIDocument.Selection.GetElementIds().Add(id);
|
||||
isAllFamilyInstance = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isSingle)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DialogResult.OK != displayForm.ShowDialog())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isAllFamilyInstance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//output error information
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// The function set value to rotation of the beams and braces
|
||||
/// and rotate columns.
|
||||
/// </summary>
|
||||
public void RotateElement()
|
||||
{
|
||||
if (m_app == null)
|
||||
return;
|
||||
ICollection<ElementId> selection = m_app.ActiveUIDocument.Selection.GetElementIds();
|
||||
foreach (ElementId id in selection)
|
||||
{
|
||||
FamilyInstance? familyComponent = m_app.ActiveUIDocument.Document.GetElement(id) as FamilyInstance;
|
||||
if (familyComponent == null)
|
||||
{
|
||||
//is not a familyInstance
|
||||
continue;
|
||||
}
|
||||
// if be familyInstance,judge the types of familyInstance
|
||||
if (Autodesk.Revit.DB.Structure.StructuralType.Beam == familyComponent.StructuralType
|
||||
|| Autodesk.Revit.DB.Structure.StructuralType.Brace == familyComponent.StructuralType)
|
||||
{
|
||||
// selection is a beam or Brace
|
||||
ParameterSetIterator j = familyComponent.Parameters.ForwardIterator();
|
||||
j.Reset();
|
||||
|
||||
bool jMoreAttribute = j.MoveNext();
|
||||
while (jMoreAttribute)
|
||||
{
|
||||
object a = j.Current;
|
||||
Parameter? objectAttribute = a as Parameter;
|
||||
//set generic property named ��Angle��
|
||||
if (objectAttribute != null)
|
||||
{
|
||||
int p = objectAttribute.Definition.Name.CompareTo("Angle");
|
||||
if (0 == p)
|
||||
{
|
||||
Double temp = objectAttribute.AsDouble();
|
||||
double rotateDegree = m_receiveRotationTextBox * Math.PI / 180;
|
||||
if (!m_isAbsoluteChecked)
|
||||
{
|
||||
// absolute rotation
|
||||
rotateDegree += temp;
|
||||
}
|
||||
objectAttribute.Set(rotateDegree);
|
||||
// relative rotation
|
||||
}
|
||||
}
|
||||
jMoreAttribute = j.MoveNext();
|
||||
}
|
||||
}
|
||||
else if (Autodesk.Revit.DB.Structure.StructuralType.Column == familyComponent.StructuralType)
|
||||
{
|
||||
// rotate a column
|
||||
Autodesk.Revit.DB.Location columnLocation = familyComponent.Location;
|
||||
// get the location object
|
||||
Autodesk.Revit.DB.LocationPoint? pointLocation = columnLocation as Autodesk.Revit.DB.LocationPoint;
|
||||
Autodesk.Revit.DB.XYZ? insertPoint = pointLocation?.Point;
|
||||
double temp = 0;
|
||||
// get the location point
|
||||
if (pointLocation != null)
|
||||
{
|
||||
temp = pointLocation.Rotation;
|
||||
//existing rotation
|
||||
XYZ directionPoint = m_app.ActiveUIDocument.Document.Application.Create.NewXYZ(0, 0, 1);
|
||||
// define the vector of axis
|
||||
Autodesk.Revit.DB.Line rotateAxis = Line.CreateUnbound(insertPoint, directionPoint);
|
||||
double rotateDegree = m_receiveRotationTextBox * Math.PI / 180;
|
||||
// rotate column by rotate method
|
||||
if (m_isAbsoluteChecked)
|
||||
{
|
||||
rotateDegree -= temp;
|
||||
}
|
||||
bool rotateResult = pointLocation.Rotate(rotateAxis, rotateDegree);
|
||||
if (rotateResult == false)
|
||||
{
|
||||
MessageBox.Show("Rotate Failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get the parameter value according given parameter name
|
||||
/// </summary>
|
||||
public string FindParameter(string parameterName, FamilyInstance familyInstanceName)
|
||||
{
|
||||
ParameterSetIterator i = familyInstanceName.Parameters.ForwardIterator();
|
||||
i.Reset();
|
||||
string? valueOfParameter = null;
|
||||
bool iMoreAttribute = i.MoveNext();
|
||||
while (iMoreAttribute)
|
||||
{
|
||||
bool isFound = false;
|
||||
object o = i.Current;
|
||||
Parameter? familyAttribute = o as Parameter;
|
||||
if (familyAttribute != null)
|
||||
{
|
||||
if (familyAttribute.Definition.Name == parameterName)
|
||||
{
|
||||
//find the parameter whose name is same to the given parameter name
|
||||
Autodesk.Revit.DB.StorageType st = familyAttribute.StorageType;
|
||||
switch (st)
|
||||
{
|
||||
//get the storage type
|
||||
case (Autodesk.Revit.DB.StorageType.Double):
|
||||
{
|
||||
if (parameterName == "Angle")
|
||||
{
|
||||
//make conversion between degrees and radians
|
||||
Double temp = familyAttribute.AsDouble();
|
||||
valueOfParameter = Math.Round(temp * 180 / (Math.PI), 3).ToString();//+ "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
valueOfParameter = familyAttribute.AsDouble().ToString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (Autodesk.Revit.DB.StorageType.ElementId):
|
||||
{
|
||||
//get elementId as string
|
||||
valueOfParameter = familyAttribute.AsElementId().ToString();
|
||||
break;
|
||||
}
|
||||
case (Autodesk.Revit.DB.StorageType.Integer):
|
||||
{
|
||||
//get Integer as string
|
||||
valueOfParameter = familyAttribute.AsInteger().ToString();
|
||||
break;
|
||||
}
|
||||
case (Autodesk.Revit.DB.StorageType.String):
|
||||
{
|
||||
//get string
|
||||
valueOfParameter = familyAttribute.AsString();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
isFound = true;
|
||||
}
|
||||
if (isFound)
|
||||
{
|
||||
break;
|
||||
}
|
||||
iMoreAttribute = i.MoveNext();
|
||||
}
|
||||
//return the value.
|
||||
}
|
||||
if (valueOfParameter == null)
|
||||
return string.Empty;
|
||||
return valueOfParameter;
|
||||
}
|
||||
}
|
||||
}
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
//
|
||||
// (C) Copyright 1994-2005 by Autodesk, Inc. All rights reserved.
|
||||
//
|
||||
// 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 ITS 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.
|
||||
|
||||
/// <summary>
|
||||
/// Show the number of studs and camber sizes for beams.
|
||||
/// </summary>
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Revit.SDK.Samples.RotateFramingObjects.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for PutDialog.
|
||||
/// </summary>
|
||||
public class RotateFramingObjectsForm : System.Windows.Forms.Form
|
||||
{
|
||||
|
||||
private RotateFramingObjects? m_instance;
|
||||
private System.ComponentModel.Container? m_components = null;
|
||||
private System.Windows.Forms.Button? cancelButton;
|
||||
private System.Windows.Forms.Button? okButton;
|
||||
public System.Windows.Forms.RadioButton? absoluteRadio;
|
||||
private System.Windows.Forms.RadioButton? relativeRadio;
|
||||
private System.Windows.Forms.Label? rotationLabel;
|
||||
public System.Windows.Forms.TextBox? rotationTextBox;
|
||||
private bool m_isReset;
|
||||
|
||||
public bool IsReset
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_isReset;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_isReset = value;
|
||||
}
|
||||
}
|
||||
public RotateFramingObjectsForm(RotateFramingObjects Inst)
|
||||
{
|
||||
m_isReset = false;
|
||||
m_instance = Inst;
|
||||
if (null == m_instance)
|
||||
{
|
||||
MessageBox.Show("Load Application Failed");
|
||||
}
|
||||
InitializeComponent();
|
||||
//this.rotationTextBox.Text = "Value";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (m_components != null)
|
||||
{
|
||||
m_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.absoluteRadio = new System.Windows.Forms.RadioButton();
|
||||
this.relativeRadio = new System.Windows.Forms.RadioButton();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.rotationLabel = new System.Windows.Forms.Label();
|
||||
this.rotationTextBox = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// absoluteRadio
|
||||
//
|
||||
this.absoluteRadio.Location = new System.Drawing.Point(192, 160);
|
||||
this.absoluteRadio.Name = "absoluteRadio";
|
||||
this.absoluteRadio.Size = new System.Drawing.Size(72, 24);
|
||||
this.absoluteRadio.TabIndex = 0;
|
||||
this.absoluteRadio.Text = "Absolute";
|
||||
this.absoluteRadio.CheckedChanged += new System.EventHandler(this.allRadio_CheckedChanged);
|
||||
//
|
||||
// relativeRadio
|
||||
//
|
||||
this.relativeRadio.Checked = true;
|
||||
this.relativeRadio.Location = new System.Drawing.Point(72, 160);
|
||||
this.relativeRadio.Name = "relativeRadio";
|
||||
this.relativeRadio.Size = new System.Drawing.Size(64, 24);
|
||||
this.relativeRadio.TabIndex = 1;
|
||||
this.relativeRadio.TabStop = true;
|
||||
this.relativeRadio.Text = "Relative";
|
||||
this.relativeRadio.CheckedChanged += new System.EventHandler(this.singleRadio_CheckedChanged);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Location = new System.Drawing.Point(184, 232);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cancelButton.TabIndex = 6;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(56, 232);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 8;
|
||||
this.okButton.Text = "OK";
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// rotationLabel
|
||||
//
|
||||
this.rotationLabel.Location = new System.Drawing.Point(64, 80);
|
||||
this.rotationLabel.Name = "rotationLabel";
|
||||
this.rotationLabel.Size = new System.Drawing.Size(100, 16);
|
||||
this.rotationLabel.TabIndex = 10;
|
||||
this.rotationLabel.Text = "Rotation";
|
||||
//
|
||||
// rotationTextBox
|
||||
//
|
||||
this.rotationTextBox.Location = new System.Drawing.Point(176, 80);
|
||||
this.rotationTextBox.Name = "rotationTextBox";
|
||||
this.rotationTextBox.Size = new System.Drawing.Size(100, 20);
|
||||
this.rotationTextBox.TabIndex = 1;
|
||||
this.rotationTextBox.TextChanged += new System.EventHandler(this.rotationTextBox_TextChanged);
|
||||
this.rotationTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.rotationTextBox_KeyPress);
|
||||
//
|
||||
// RotateFramingObjectsForm
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
||||
this.ClientSize = new System.Drawing.Size(336, 302);
|
||||
this.Controls.Add(this.rotationTextBox);
|
||||
this.Controls.Add(this.relativeRadio);
|
||||
this.Controls.Add(this.rotationLabel);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.absoluteRadio);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "RotateFramingObjectsForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Rotate Framing Objects";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void okButton_Click(object? sender, System.EventArgs e)
|
||||
{
|
||||
if (IsReset && m_instance != null)
|
||||
{
|
||||
m_instance.RotateElement();
|
||||
}
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
|
||||
}
|
||||
|
||||
private void cancelButton_Click(object? sender, System.EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
|
||||
}
|
||||
private void singleRadio_CheckedChanged(object? sender, System.EventArgs e)
|
||||
{
|
||||
m_isReset = true;
|
||||
if (m_instance == null)
|
||||
return;
|
||||
m_instance.IsAbsoluteChecked = false;
|
||||
}
|
||||
|
||||
private void allRadio_CheckedChanged(object? sender, System.EventArgs e)
|
||||
{
|
||||
if (m_instance == null)
|
||||
return;
|
||||
m_isReset = true;
|
||||
m_instance.IsAbsoluteChecked = true;
|
||||
}
|
||||
|
||||
private void rotationTextBox_TextChanged(object? sender, System.EventArgs e)
|
||||
{
|
||||
if (this.rotationTextBox == null || m_instance == null)
|
||||
return;
|
||||
if ("" != this.rotationTextBox.Text)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_instance.ReceiveRotationTextBox = Convert.ToDouble(this.rotationTextBox.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//this.DialogResult=DialogResult.Cancel;
|
||||
MessageBox.Show("Please input number.");
|
||||
this.rotationTextBox.Clear();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_instance.ReceiveRotationTextBox = 0;
|
||||
}
|
||||
m_isReset = true;
|
||||
}
|
||||
|
||||
private void rotationTextBox_KeyPress(object? sender, System.Windows.Forms.KeyPressEventArgs e)
|
||||
{
|
||||
if (13 == e.KeyChar)
|
||||
{
|
||||
okButton_Click(sender, e);
|
||||
}
|
||||
else
|
||||
rotationTextBox_TextChanged(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -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>
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
namespace Revit.SDK.Samples.FindAndReplaceText.CS
|
||||
{
|
||||
partial class FindAndReplaceDialog
|
||||
{
|
||||
/// <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.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.FindContent = new System.Windows.Forms.TextBox();
|
||||
this.ReplaceContent = new System.Windows.Forms.TextBox();
|
||||
this.Cancel = new System.Windows.Forms.Button();
|
||||
this.OK = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(26, 37);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(56, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Find what:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(26, 90);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(72, 13);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Replace with:";
|
||||
//
|
||||
// FindContent
|
||||
//
|
||||
this.FindContent.Location = new System.Drawing.Point(117, 34);
|
||||
this.FindContent.Name = "FindContent";
|
||||
this.FindContent.Size = new System.Drawing.Size(226, 20);
|
||||
this.FindContent.TabIndex = 2;
|
||||
//
|
||||
// ReplaceContent
|
||||
//
|
||||
this.ReplaceContent.Location = new System.Drawing.Point(117, 83);
|
||||
this.ReplaceContent.Name = "ReplaceContent";
|
||||
this.ReplaceContent.Size = new System.Drawing.Size(226, 20);
|
||||
this.ReplaceContent.TabIndex = 3;
|
||||
//
|
||||
// Cancel
|
||||
//
|
||||
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.Cancel.Location = new System.Drawing.Point(186, 136);
|
||||
this.Cancel.Name = "Cancel";
|
||||
this.Cancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.Cancel.TabIndex = 4;
|
||||
this.Cancel.Text = "Cancel";
|
||||
this.Cancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// OK
|
||||
//
|
||||
this.OK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.OK.Location = new System.Drawing.Point(268, 136);
|
||||
this.OK.Name = "OK";
|
||||
this.OK.Size = new System.Drawing.Size(75, 23);
|
||||
this.OK.TabIndex = 5;
|
||||
this.OK.Text = "OK";
|
||||
this.OK.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FindAndReplaceDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.Cancel;
|
||||
this.ClientSize = new System.Drawing.Size(362, 176);
|
||||
this.Controls.Add(this.OK);
|
||||
this.Controls.Add(this.Cancel);
|
||||
this.Controls.Add(this.ReplaceContent);
|
||||
this.Controls.Add(this.FindContent);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "FindAndReplaceDialog";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "FindAndReplaceDialog";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
public System.Windows.Forms.TextBox FindContent;
|
||||
public System.Windows.Forms.TextBox ReplaceContent;
|
||||
private System.Windows.Forms.Button Cancel;
|
||||
private System.Windows.Forms.Button OK;
|
||||
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Revit.SDK.Samples.FindAndReplaceText.CS
|
||||
{
|
||||
public partial class FindAndReplaceDialog : Form
|
||||
{
|
||||
public FindAndReplaceDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -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>
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// (C) Copyright 2003-2008 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 Autodesk;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.FindAndReplaceText.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// automatically search all text notes in the project
|
||||
/// and replace text found with appropriate content.
|
||||
/// </summary>
|
||||
public class FindAndReplaceText
|
||||
{
|
||||
private Document? m_doc = null;
|
||||
|
||||
/// <summary>
|
||||
/// Automatic print of all of a certain view type, to the default printer .
|
||||
/// </summary>
|
||||
private FindAndReplaceText()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor wit parameter used to call this sample.
|
||||
/// </summary>
|
||||
/// <param name="doc"></param>
|
||||
public FindAndReplaceText(ThisApplication hostDoc)
|
||||
{
|
||||
m_doc = hostDoc.ActiveUIDocument.Document;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// run this sample now
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
String findContent = String.Empty;
|
||||
String replaceContent = String.Empty;
|
||||
FindAndReplaceDialog dialog = new FindAndReplaceDialog();
|
||||
|
||||
// Get the designated text
|
||||
if (DialogResult.OK == dialog.ShowDialog())
|
||||
{
|
||||
findContent = dialog.FindContent.Text;
|
||||
replaceContent = dialog.ReplaceContent.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// filtrate the TextElment from the element set.
|
||||
ElementClassFilter filterText = new ElementClassFilter(typeof(TextElement));
|
||||
FilteredElementCollector colloctor = new FilteredElementCollector(m_doc);
|
||||
colloctor.WherePasses(filterText);
|
||||
|
||||
IList<Element> arrayText = colloctor.ToElements();
|
||||
|
||||
// matching and replacing
|
||||
int replacenum = 0;
|
||||
foreach (Element ee in arrayText)
|
||||
{
|
||||
TextElement? textElem = ee as TextElement;
|
||||
if ((null != textElem) && (textElem.Text.Contains(findContent)))
|
||||
{
|
||||
|
||||
textElem.Text = textElem.Text.Replace(findContent,replaceContent);
|
||||
replacenum++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Show the number of replacement found.
|
||||
MessageBox.Show("Revit has completed its search and has made " + replacenum + " modifications.", "FindAndReplaceText");
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
MessageBox.Show(ee.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// (C) Copyright 2003-2008 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 Autodesk;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
using System.Linq;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.SearchAndReplaceWinType.CS
|
||||
{
|
||||
public class FindAndReplaceWinType
|
||||
{
|
||||
/// <summary>
|
||||
/// automatically replaces all windows of a given (hardcoded) type with another hardcoded type
|
||||
/// </summary>
|
||||
private Document? m_doc = null;
|
||||
|
||||
/// <summary>
|
||||
/// Automatic print of all of a certain view type, to the default printer .
|
||||
/// </summary>
|
||||
private FindAndReplaceWinType()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor wit parameter used to call this sample.
|
||||
/// </summary>
|
||||
/// <param name="doc"></param>
|
||||
public FindAndReplaceWinType(ThisApplication hostDoc)
|
||||
{
|
||||
m_doc = hostDoc.ActiveUIDocument.Document;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// run this sample now
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
// filtrate the windows from the element set.
|
||||
|
||||
ElementClassFilter filter1 = new ElementClassFilter(typeof(FamilyInstance));
|
||||
ElementCategoryFilter filter2 = new ElementCategoryFilter(BuiltInCategory.OST_Windows);
|
||||
LogicalAndFilter andFilter = new LogicalAndFilter(filter1, filter2);
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_doc);
|
||||
ICollection<Element> arrayFamily = collector.WherePasses(andFilter).ToElements();
|
||||
|
||||
// filtrate the Symbol from the element set to modify the window's type.
|
||||
|
||||
|
||||
ElementClassFilter filter3 = new ElementClassFilter(typeof(FamilySymbol));
|
||||
ElementCategoryFilter filter4 = new ElementCategoryFilter(BuiltInCategory.OST_Windows);
|
||||
LogicalAndFilter andFilter1 = new LogicalAndFilter(filter3, filter4);
|
||||
collector = new FilteredElementCollector(m_doc);
|
||||
ICollection<Element> found = collector.WherePasses(andFilter1).ToElements();
|
||||
ElementArray arraySymbol = new ElementArray();
|
||||
foreach (Element ee in found)
|
||||
{
|
||||
if (ee.Name == "36\" x 72\"")
|
||||
{
|
||||
arraySymbol.Insert(ee, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MessageBox.Show("Replace 16\" x 24\" to 36\" x 72\".", "FindAndReplaceWinType");
|
||||
// matching and replacing
|
||||
int replacenum = 0;
|
||||
foreach (Element ee in arrayFamily)
|
||||
{
|
||||
|
||||
FamilyInstance? windows = ee as FamilyInstance;
|
||||
if (windows == null)
|
||||
return;
|
||||
if (0 == windows.Symbol.Name.CompareTo("16\" x 24\""))
|
||||
{
|
||||
windows.Symbol = arraySymbol.get_Item(0) as FamilySymbol;
|
||||
replacenum++;
|
||||
}
|
||||
|
||||
}
|
||||
// Show the number of windows modified.
|
||||
MessageBox.Show("Revit has completed its search and has made " + replacenum + " modifications.", "FindAndReplaceWinType");
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
MessageBox.Show(ee.Message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,391 @@
|
||||
//
|
||||
// (C) Copyright 2003-2008 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
|
||||
// app.ActiveUIDocumentumentation.
|
||||
//
|
||||
// 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.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using System.Collections.Generic;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.SlabProperties.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Get some properties of a slab , such as Level, Type name, Span direction,
|
||||
/// Material name, Thickness, and Young Modulus for the slab's Material.
|
||||
/// </summary>
|
||||
public class SlabProperties
|
||||
{
|
||||
#region Class constant variables
|
||||
const double PI = 3.1415926535879;
|
||||
const int Degree = 180;
|
||||
const int ToMillimeter = 1000;
|
||||
const double ToMetricThickness = 0.3048; // unit for changing inch to meter
|
||||
const double ToMetricYoungmodulus = 304800.0;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Class member variables
|
||||
ThisApplication? m_app;
|
||||
|
||||
ICollection<ElementId>? m_slabComponent; // the selected Slab component
|
||||
Floor? m_slabFloor; // Floor
|
||||
CompoundStructureLayer? m_slabLayer; // Structure Layer
|
||||
IList<CompoundStructureLayer>? m_slabLayerCollection; // Structure Layer collection
|
||||
|
||||
string m_level = string.Empty; // level name of Slab
|
||||
string m_typeName = string.Empty; // type name of Slab
|
||||
string m_spanDirection = string.Empty; // span direction (degree) of Slab
|
||||
string m_thickness = string.Empty; // thick ness (millmeter) of slab layer
|
||||
string m_materialName = string.Empty; // material name of slab layer
|
||||
string m_youngModulusX = string.Empty; // Young modulus X
|
||||
string m_youngModulusY = string.Empty; // Young modulus Y
|
||||
string m_youngModulusZ = string.Empty; // Young modulus Z
|
||||
int m_numberOfLayers = 0; // number of Structure Layers
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Class Constructor methods implementation
|
||||
/// <summary>
|
||||
/// Ctro without parameter is not allowed
|
||||
/// </summary>
|
||||
private SlabProperties()
|
||||
{
|
||||
// none
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ctor with ThisDocument as
|
||||
/// </summary>
|
||||
/// <param name="hostApp">ThisDocument handler</param>
|
||||
public SlabProperties(ThisApplication hostApp)
|
||||
{
|
||||
m_app = hostApp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run this sample
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_app == null)
|
||||
return;
|
||||
// function initialization and find out a slab's Level, Type name, and set the Span Direction properties.
|
||||
bool isInitialization = this.Initialize(m_app);
|
||||
if (false == isInitialization)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// show a displayForm to display the properties of the slab
|
||||
SlabPropertiesForm slabForm = new SlabPropertiesForm(this);
|
||||
if (DialogResult.OK != slabForm.ShowDialog())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception displayProblem)
|
||||
{
|
||||
MessageBox.Show(displayProblem.ToString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Class propertied
|
||||
/// <summary>
|
||||
/// Level property, read only.
|
||||
/// </summary>
|
||||
public string Level
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_level;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// TypeName property, read only.
|
||||
/// </summary>
|
||||
public string TypeName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_typeName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// SpanDirection property, read only.
|
||||
/// </summary>
|
||||
public string SpanDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_spanDirection;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// NumberOfLayers property, read only.
|
||||
/// </summary>
|
||||
public int NumberOfLayers
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_numberOfLayers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LayerThickness property, read only.
|
||||
/// </summary>
|
||||
public string LayerThickness
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_thickness;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LayerMaterialName property, read only.
|
||||
/// </summary>
|
||||
public string LayerMaterialName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_materialName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LayerYoungModulusX property, read only.
|
||||
/// </summary>
|
||||
public string LayerYoungModulusX
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_youngModulusX;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LayerYoungModulusY property, read only.
|
||||
/// </summary>
|
||||
public string LayerYoungModulusY
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_youngModulusY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LayerYoungModulusZ property, read only.
|
||||
/// </summary>
|
||||
public string LayerYoungModulusZ
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_youngModulusZ;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Public class method
|
||||
/// <summary>
|
||||
/// SetLayer method
|
||||
/// </summary>
|
||||
/// <param name="layerNumber">The layerNumber for the number of the layers</param>
|
||||
public void SetLayer(int layerNumber)
|
||||
{
|
||||
// Get each layer.
|
||||
// An individual layer can be accessed by Layers property and its thickness and material can then be reported.
|
||||
if (m_slabLayerCollection == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_slabLayer = m_slabLayerCollection[layerNumber];
|
||||
|
||||
// Get the Thickness property and change to the metric millimeter
|
||||
m_thickness = ((m_slabLayer.Width) * ToMetricThickness * ToMillimeter).ToString() + " mm";
|
||||
|
||||
// Get the Material name property
|
||||
Material? slabLayerMaterial = GetMaterial(m_slabLayer.MaterialId);
|
||||
if (null != slabLayerMaterial)
|
||||
{
|
||||
m_materialName = slabLayerMaterial.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_materialName = "Null";
|
||||
}
|
||||
|
||||
// The Young modulus can be found from the material by using the following generic parameters:
|
||||
// PHY_MATERIAL_PARAM_YOUNG_MOD1, PHY_MATERIAL_PARAM_YOUNG_MOD2, PHY_MATERIAL_PARAM_YOUNG_MOD3
|
||||
if (null != slabLayerMaterial)
|
||||
{
|
||||
Parameter? youngModuleAttribute = null;
|
||||
youngModuleAttribute = slabLayerMaterial.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD1);
|
||||
if (null != youngModuleAttribute)
|
||||
{
|
||||
m_youngModulusX = (youngModuleAttribute.AsDouble() / ToMetricYoungmodulus).ToString("F2") + " MPa";
|
||||
}
|
||||
youngModuleAttribute = slabLayerMaterial.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD2);
|
||||
if (null != youngModuleAttribute)
|
||||
{
|
||||
m_youngModulusY = (youngModuleAttribute.AsDouble() / ToMetricYoungmodulus).ToString("F2") + " MPa";
|
||||
}
|
||||
youngModuleAttribute = slabLayerMaterial.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD3);
|
||||
if (null != youngModuleAttribute)
|
||||
{
|
||||
m_youngModulusZ = (youngModuleAttribute.AsDouble() / ToMetricYoungmodulus).ToString("F2") + " MPa";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_youngModulusX = "Null";
|
||||
m_youngModulusY = "Null";
|
||||
m_youngModulusZ = "Null";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Private class memeber methods
|
||||
|
||||
/// <summary>
|
||||
/// Get material element from an element id.
|
||||
/// </summary>
|
||||
private Material? GetMaterial(ElementId elemId)
|
||||
{
|
||||
return m_app?.ActiveUIDocument.Document.GetElement(elemId) as Material;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialization and find out a slab's Level, Type name, and set the Span Direction properties.
|
||||
/// </summary>
|
||||
/// <param name="revit">The revit object for the active instance of Autodesk Revit.</param>
|
||||
/// <returns>A value that signifies if your intitialization was successful for true or failed for false.</returns>
|
||||
private bool Initialize(ThisApplication app)
|
||||
{
|
||||
m_slabComponent = app.ActiveUIDocument.Selection.GetElementIds();
|
||||
|
||||
// There must be exactly one slab selected
|
||||
if (m_slabComponent.Count == 0)
|
||||
{
|
||||
// nothing selected
|
||||
MessageBox.Show("Please select a slab.");
|
||||
return false;
|
||||
}
|
||||
else if (1 != m_slabComponent.Count)
|
||||
{
|
||||
// too many things selected
|
||||
MessageBox.Show("Please select only one slab.");
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (ElementId id in m_slabComponent)
|
||||
{
|
||||
Element e = app.ActiveUIDocument.Document.GetElement(id);
|
||||
// If the element isn't a slab, give the message and return failure.
|
||||
// Else find out its Level, Type name, and set the Span Direction properties.
|
||||
if ("Autodesk.Revit.DB.Floor" != e.GetType().FullName)
|
||||
{
|
||||
MessageBox.Show("A slab should be selected.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Change the element type to floor type
|
||||
m_slabFloor = e as Floor;
|
||||
|
||||
// Get the layer information from the type object by using the CompoundStructure property
|
||||
// The Layers property is then used to retrieve all the layers
|
||||
if (m_slabFloor == null)
|
||||
return false;
|
||||
m_slabLayerCollection = m_slabFloor.FloorType.GetCompoundStructure().GetLayers();
|
||||
m_numberOfLayers = m_slabLayerCollection.Count;
|
||||
|
||||
// Get the Level property by the floor's Level property
|
||||
m_level = app.ActiveUIDocument.Document.GetElement(m_slabFloor.LevelId).Name;
|
||||
|
||||
// Get the Type name property by the floor's FloorType property
|
||||
m_typeName = m_slabFloor.FloorType.Name;
|
||||
|
||||
// The span direction can be found using generic parameter access
|
||||
// using the built in parameter FLOOR_PARAM_SPAN_DIRECTION
|
||||
Parameter spanDirectionAttribute;
|
||||
spanDirectionAttribute = m_slabFloor.get_Parameter(BuiltInParameter.FLOOR_PARAM_SPAN_DIRECTION);
|
||||
if (null != spanDirectionAttribute)
|
||||
{
|
||||
// Set the Span Direction property
|
||||
this.SetSpanDirection(spanDirectionAttribute.AsDouble());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set SpanDirection property to the class private member
|
||||
/// Because of the property retrieved from the parameter uses radian for unit, we should change it to degree.
|
||||
/// </summary>
|
||||
/// <param name="spanDirection">The value of span direction property</param>
|
||||
private void SetSpanDirection(double spanDirection)
|
||||
{
|
||||
double spanDirectionDegree;
|
||||
|
||||
// Change "radian" to "degree".
|
||||
spanDirectionDegree = spanDirection / PI * Degree;
|
||||
|
||||
// If the absolute value very small, we consider it to be zero
|
||||
if (Math.Abs(spanDirectionDegree) < 1E-12)
|
||||
{
|
||||
spanDirectionDegree = 0.0;
|
||||
}
|
||||
|
||||
// The precision is 0.01, and unit is "degree".
|
||||
m_spanDirection = spanDirectionDegree.ToString("F2") + "�";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+263
@@ -0,0 +1,263 @@
|
||||
//
|
||||
// (C) Copyright 2003-2007 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.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace Revit.SDK.Samples.SlabProperties.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Show some properties of a slab in Revit Structure 5, including Level, Type name, Span divection,
|
||||
/// Material name, Thickness, and Young Modulus for each layer of the slab's materiral.
|
||||
/// </summary>
|
||||
public class SlabPropertiesForm : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.GroupBox? layerGroupBox;
|
||||
private System.Windows.Forms.RichTextBox? layerRichTextBox;
|
||||
private System.Windows.Forms.Label? levelLabel;
|
||||
private System.Windows.Forms.Label? typeNameLabel;
|
||||
private System.Windows.Forms.Label? spanDirectionLabel;
|
||||
private System.Windows.Forms.TextBox? levelTextBox;
|
||||
private System.Windows.Forms.TextBox? typeNameTextBox;
|
||||
private System.Windows.Forms.TextBox? spanDirectionTextBox;
|
||||
private System.Windows.Forms.Button? closeButton;
|
||||
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container? components = null;
|
||||
|
||||
// To store the datas
|
||||
private SlabProperties? m_dataBuffer;
|
||||
|
||||
|
||||
private SlabPropertiesForm()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// overload the constructor
|
||||
/// </summary>
|
||||
/// <param name="dataBuffer">To store the datas of a slab</param>
|
||||
public SlabPropertiesForm(SlabProperties dataBuffer)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// get all the data
|
||||
m_dataBuffer = dataBuffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (null != components)
|
||||
{
|
||||
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.layerGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.layerRichTextBox = new System.Windows.Forms.RichTextBox();
|
||||
this.levelLabel = new System.Windows.Forms.Label();
|
||||
this.levelTextBox = new System.Windows.Forms.TextBox();
|
||||
this.typeNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.spanDirectionTextBox = new System.Windows.Forms.TextBox();
|
||||
this.typeNameLabel = new System.Windows.Forms.Label();
|
||||
this.spanDirectionLabel = new System.Windows.Forms.Label();
|
||||
this.closeButton = new System.Windows.Forms.Button();
|
||||
this.layerGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// layerGroupBox
|
||||
//
|
||||
this.layerGroupBox.Controls.Add(this.layerRichTextBox);
|
||||
this.layerGroupBox.Location = new System.Drawing.Point(22, 86);
|
||||
this.layerGroupBox.Name = "layerGroupBox";
|
||||
this.layerGroupBox.Size = new System.Drawing.Size(375, 265);
|
||||
this.layerGroupBox.TabIndex = 29;
|
||||
this.layerGroupBox.TabStop = false;
|
||||
this.layerGroupBox.Text = "Layers:";
|
||||
//
|
||||
// layerRichTextBox
|
||||
//
|
||||
this.layerRichTextBox.Location = new System.Drawing.Point(6, 19);
|
||||
this.layerRichTextBox.Name = "layerRichTextBox";
|
||||
this.layerRichTextBox.ReadOnly = true;
|
||||
this.layerRichTextBox.Size = new System.Drawing.Size(359, 232);
|
||||
this.layerRichTextBox.TabIndex = 2;
|
||||
this.layerRichTextBox.Text = "";
|
||||
//
|
||||
// levelLabel
|
||||
//
|
||||
this.levelLabel.Location = new System.Drawing.Point(13, 7);
|
||||
this.levelLabel.Name = "levelLabel";
|
||||
this.levelLabel.Size = new System.Drawing.Size(98, 23);
|
||||
this.levelLabel.TabIndex = 27;
|
||||
this.levelLabel.Text = "Level:";
|
||||
this.levelLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// levelTextBox
|
||||
//
|
||||
this.levelTextBox.Location = new System.Drawing.Point(117, 8);
|
||||
this.levelTextBox.Name = "levelTextBox";
|
||||
this.levelTextBox.ReadOnly = true;
|
||||
this.levelTextBox.Size = new System.Drawing.Size(280, 20);
|
||||
this.levelTextBox.TabIndex = 24;
|
||||
//
|
||||
// typeNameTextBox
|
||||
//
|
||||
this.typeNameTextBox.Location = new System.Drawing.Point(117, 34);
|
||||
this.typeNameTextBox.Name = "typeNameTextBox";
|
||||
this.typeNameTextBox.ReadOnly = true;
|
||||
this.typeNameTextBox.Size = new System.Drawing.Size(280, 20);
|
||||
this.typeNameTextBox.TabIndex = 22;
|
||||
//
|
||||
// spanDirectionTextBox
|
||||
//
|
||||
this.spanDirectionTextBox.Location = new System.Drawing.Point(117, 60);
|
||||
this.spanDirectionTextBox.Name = "spanDirectionTextBox";
|
||||
this.spanDirectionTextBox.ReadOnly = true;
|
||||
this.spanDirectionTextBox.Size = new System.Drawing.Size(280, 20);
|
||||
this.spanDirectionTextBox.TabIndex = 23;
|
||||
//
|
||||
// typeNameLabel
|
||||
//
|
||||
this.typeNameLabel.Location = new System.Drawing.Point(13, 34);
|
||||
this.typeNameLabel.Name = "typeNameLabel";
|
||||
this.typeNameLabel.Size = new System.Drawing.Size(98, 23);
|
||||
this.typeNameLabel.TabIndex = 25;
|
||||
this.typeNameLabel.Text = "Type Name:";
|
||||
this.typeNameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// spanDirectionLabel
|
||||
//
|
||||
this.spanDirectionLabel.Location = new System.Drawing.Point(13, 60);
|
||||
this.spanDirectionLabel.Name = "spanDirectionLabel";
|
||||
this.spanDirectionLabel.Size = new System.Drawing.Size(98, 23);
|
||||
this.spanDirectionLabel.TabIndex = 26;
|
||||
this.spanDirectionLabel.Text = "Span Direction:";
|
||||
this.spanDirectionLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// closeButton
|
||||
//
|
||||
this.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.closeButton.Location = new System.Drawing.Point(322, 367);
|
||||
this.closeButton.Name = "closeButton";
|
||||
this.closeButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.closeButton.TabIndex = 0;
|
||||
this.closeButton.Text = "Close";
|
||||
this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
|
||||
//
|
||||
// SlabPropertiesForm
|
||||
//
|
||||
this.AcceptButton = this.closeButton;
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
||||
this.CancelButton = this.closeButton;
|
||||
this.ClientSize = new System.Drawing.Size(411, 402);
|
||||
this.Controls.Add(this.layerGroupBox);
|
||||
this.Controls.Add(this.levelLabel);
|
||||
this.Controls.Add(this.levelTextBox);
|
||||
this.Controls.Add(this.typeNameTextBox);
|
||||
this.Controls.Add(this.spanDirectionTextBox);
|
||||
this.Controls.Add(this.typeNameLabel);
|
||||
this.Controls.Add(this.spanDirectionLabel);
|
||||
this.Controls.Add(this.closeButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "SlabPropertiesForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Slab Properties";
|
||||
this.Load += new System.EventHandler(this.SlabPropertiesForm_Load);
|
||||
this.layerGroupBox.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Close the Form
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void closeButton_Click(object? sender, System.EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Display the properties on the form when the form load
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SlabPropertiesForm_Load(object? sender, System.EventArgs e)
|
||||
{
|
||||
if (levelTextBox == null || typeNameTextBox == null || spanDirectionTextBox == null || layerRichTextBox == null || m_dataBuffer == null)
|
||||
return;
|
||||
this.levelTextBox.Text = m_dataBuffer.Level;
|
||||
this.typeNameTextBox.Text = m_dataBuffer.TypeName;
|
||||
this.spanDirectionTextBox.Text = m_dataBuffer.SpanDirection;
|
||||
|
||||
int numberOfLayers = m_dataBuffer.NumberOfLayers;
|
||||
|
||||
this.layerRichTextBox.Text = "";
|
||||
|
||||
for (int i = 0; i < numberOfLayers; i++)
|
||||
{
|
||||
// Get each layer's Material name and Young Modulus properties
|
||||
m_dataBuffer.SetLayer(i);
|
||||
|
||||
this.layerRichTextBox.Text += "Layer " + (i + 1).ToString() + "\n";
|
||||
this.layerRichTextBox.Text += "Material name: " + m_dataBuffer.LayerMaterialName + "\n";
|
||||
this.layerRichTextBox.Text += "Thickness: " + m_dataBuffer.LayerThickness + "\n";
|
||||
this.layerRichTextBox.Text += "YoungModulus X: " + m_dataBuffer.LayerYoungModulusX + "\n";
|
||||
this.layerRichTextBox.Text += "YoungModulus Y: " + m_dataBuffer.LayerYoungModulusY + "\n";
|
||||
this.layerRichTextBox.Text += "YoungModulus Z: " + m_dataBuffer.LayerYoungModulusZ + "\n";
|
||||
this.layerRichTextBox.Text += "-----------------------------------------------------------" + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -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>
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
//
|
||||
// (C) Copyright 2003-2008 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 System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
using MacroSamples_RVT;
|
||||
|
||||
namespace Revit.SDK.Samples.StructuralLayerFunction.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// With the selected floor, display the function of each of its structural layers
|
||||
/// in order from outside to inside in a dialog box
|
||||
/// </summary>
|
||||
public class StructuralLayerFunction
|
||||
{
|
||||
#region Private data members
|
||||
Autodesk.Revit.DB.Floor? m_slab = null; // Store the selected floor
|
||||
ArrayList? m_functions; // Store the function of each floor
|
||||
ThisApplication? m_app; // host document for ThisDocument
|
||||
#endregion
|
||||
|
||||
|
||||
#region class public property
|
||||
/// <summary>
|
||||
/// With the selected floor, export the function of each of its structural layers
|
||||
/// </summary>
|
||||
public ArrayList? Functions
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_functions;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Class ctor implemetation
|
||||
/// <summary>
|
||||
/// Ctor without parameter is not allowed
|
||||
/// </summary>
|
||||
private StructuralLayerFunction()
|
||||
{
|
||||
// no codes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor of StructuralLayerFunction
|
||||
/// </summary>
|
||||
public StructuralLayerFunction(ThisApplication hostApp)
|
||||
{
|
||||
// Init for varialbes
|
||||
// this document handler
|
||||
m_app = hostApp;
|
||||
m_functions = new ArrayList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run this sample now
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
//
|
||||
// Get the selected floor
|
||||
if (m_app == null)
|
||||
return;
|
||||
Selection choices = m_app.ActiveUIDocument.Selection;
|
||||
ICollection<ElementId> collection = choices.GetElementIds();
|
||||
//
|
||||
// Only allow to select one floor, or else report the failure
|
||||
if (1 != collection.Count)
|
||||
{
|
||||
MessageBox.Show("Please select a floor firstly.");
|
||||
return;
|
||||
}
|
||||
foreach (ElementId id in collection)
|
||||
{
|
||||
m_slab = m_app.ActiveUIDocument.Document.GetElement(id) as Autodesk.Revit.DB.Floor;
|
||||
if (null == m_slab)
|
||||
{
|
||||
MessageBox.Show("Please select a floor firstly.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Get the function of each of its structural layers
|
||||
if (m_slab == null)
|
||||
return;
|
||||
foreach (CompoundStructureLayer e in m_slab.FloorType.GetCompoundStructure().GetLayers())
|
||||
{
|
||||
// With the selected floor, judge if the function of each of its structural layers
|
||||
// is exist, if it's not exist, there should be zero.
|
||||
if (0 == e.Function)
|
||||
{
|
||||
m_functions?.Add("No function");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_functions?.Add(e.Function.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
// Display them in a form
|
||||
StructuralLayerFunctionForm displayForm = new StructuralLayerFunctionForm(this);
|
||||
displayForm.ShowDialog();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
//
|
||||
// (C) Copyright 2003-2008 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.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using MacroCSharpSamples;
|
||||
|
||||
namespace Revit.SDK.Samples.StructuralLayerFunction.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// display the function of each of a select floor's structural layers
|
||||
/// </summary>
|
||||
public class StructuralLayerFunctionForm : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.ListBox? functionListBox;
|
||||
private System.Windows.Forms.GroupBox? functionGroupBox;
|
||||
private System.Windows.Forms.Button? okButton;
|
||||
|
||||
private System.ComponentModel.Container? components = null;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor of StructuralLayerFunctionForm
|
||||
/// </summary>
|
||||
/// <param name="dataBuffer">A reference of StructuralLayerFunction class</param>
|
||||
public StructuralLayerFunctionForm(StructuralLayerFunction dataBuffer)
|
||||
{
|
||||
// Required for Windows Form Designer support
|
||||
InitializeComponent();
|
||||
if (functionListBox == null)
|
||||
return;
|
||||
// Set the data source of the ListBox control
|
||||
functionListBox.DataSource = dataBuffer.Functions;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (null != components)
|
||||
{
|
||||
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.functionListBox = new System.Windows.Forms.ListBox();
|
||||
this.functionGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.functionGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// functionListBox
|
||||
//
|
||||
this.functionListBox.Location = new System.Drawing.Point(6, 24);
|
||||
this.functionListBox.Name = "functionListBox";
|
||||
this.functionListBox.Size = new System.Drawing.Size(189, 147);
|
||||
this.functionListBox.TabIndex = 0;
|
||||
//
|
||||
// functionGroupBox
|
||||
//
|
||||
this.functionGroupBox.Controls.Add(this.functionListBox);
|
||||
this.functionGroupBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.functionGroupBox.Name = "functionGroupBox";
|
||||
this.functionGroupBox.Size = new System.Drawing.Size(201, 184);
|
||||
this.functionGroupBox.TabIndex = 1;
|
||||
this.functionGroupBox.TabStop = false;
|
||||
this.functionGroupBox.Text = "Layers Functions List";
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.Location = new System.Drawing.Point(138, 202);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 2;
|
||||
this.okButton.Text = "OK";
|
||||
//
|
||||
// StructuralLayerFunctionForm
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
||||
this.CancelButton = this.okButton;
|
||||
this.ClientSize = new System.Drawing.Size(225, 236);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.functionGroupBox);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "StructuralLayerFunctionForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Structure Layers Function";
|
||||
this.functionGroupBox.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+120
@@ -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>
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
namespace MacroSamples_RVT {
|
||||
|
||||
public sealed partial class ThisApplication : Autodesk.Revit.UI.Macros.ApplicationEntryPoint {
|
||||
|
||||
public event System.EventHandler Startup;
|
||||
|
||||
public event System.EventHandler Shutdown;
|
||||
|
||||
///
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||
private void OnStartup() {
|
||||
}
|
||||
|
||||
///
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||
protected override void FinishInitialization() {
|
||||
base.FinishInitialization();
|
||||
this.OnStartup();
|
||||
this.InternalStartup();
|
||||
if ((this.Startup != null)) {
|
||||
this.Startup(this, System.EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||
protected override void OnShutdown() {
|
||||
if ((this.Shutdown != null)) {
|
||||
this.Shutdown(this, System.EventArgs.Empty);
|
||||
}
|
||||
base.OnShutdown();
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||
protected override string PrimaryCookie {
|
||||
get {
|
||||
return "ThisApplication";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Revit.SDK.Samples.QuickPrint.CS;
|
||||
using Revit.SDK.Samples.FindAndReplaceText.CS;
|
||||
using Revit.SDK.Samples.CapitalizeText.CS;
|
||||
using Revit.SDK.Samples.SearchAndReplaceWinType.CS;
|
||||
using Revit.SDK.Samples.CreateBeamsColumnsBraces.CS;
|
||||
using Revit.SDK.Samples.DeleteObject.CS;
|
||||
using Revit.SDK.Samples.ProjectInfo.CS;
|
||||
using Revit.SDK.Samples.Rooms.CS;
|
||||
using Revit.SDK.Samples.RotateFramingObjects.CS;
|
||||
using Revit.SDK.Samples.SlabProperties.CS;
|
||||
using Revit.SDK.Samples.StructuralLayerFunction.CS;
|
||||
using Revit.SDK.Samples.GridCreation.CS;
|
||||
|
||||
namespace MacroSamples_RVT
|
||||
{
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.DB.Macros.AddInId("9EADAEFA-4C28-40FC-849F-7720890B1490")]
|
||||
public partial class ThisApplication
|
||||
{
|
||||
private void Module_Startup(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Module_Shutdown(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region Revit Macros generated code
|
||||
private void InternalStartup()
|
||||
{
|
||||
this.Startup += new System.EventHandler(Module_Startup);
|
||||
this.Shutdown += new System.EventHandler(Module_Shutdown);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void CreateBeamsColumnsBraces()
|
||||
{
|
||||
using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "CreateBeamsColumnsBraces"))
|
||||
{
|
||||
trans.Start();
|
||||
CreateBeamsColumnsBraces sample = new CreateBeamsColumnsBraces(this);
|
||||
sample.Run();
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteObject()
|
||||
{
|
||||
using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "DeleteObject"))
|
||||
{
|
||||
trans.Start();
|
||||
DeleteObject sample = new DeleteObject(this);
|
||||
sample.Run();
|
||||
trans.Commit();
|
||||
}
|
||||
|
||||
}
|
||||
public void GridCreation()
|
||||
{
|
||||
using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "GridCreation"))
|
||||
{
|
||||
trans.Start();
|
||||
Revit.SDK.Samples.GridCreation.CS.GridCreation sample = new Revit.SDK.Samples.GridCreation.CS.GridCreation(this);
|
||||
sample.Run();
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
public void ProjectInfo()
|
||||
{
|
||||
SampleProjectInfo sample = new SampleProjectInfo(this);
|
||||
sample.Run();
|
||||
}
|
||||
public void Rooms()
|
||||
{
|
||||
using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "Rooms"))
|
||||
{
|
||||
trans.Start();
|
||||
SamplesRoom sample = new SamplesRoom(this);
|
||||
sample.Run();
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
public void RotateFramingObjects()
|
||||
{
|
||||
using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "RotateFramingObjects"))
|
||||
{
|
||||
trans.Start();
|
||||
RotateFramingObjects sample = new RotateFramingObjects(this);
|
||||
sample.Run();
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
public void SlabProperties()
|
||||
{
|
||||
SlabProperties sample = new SlabProperties(this);
|
||||
sample.Run();
|
||||
}
|
||||
|
||||
public void StructuralLayerFunction()
|
||||
{
|
||||
StructuralLayerFunction sample = new StructuralLayerFunction(this);
|
||||
sample.Run();
|
||||
}
|
||||
public void QuickPrint_FloorPlans()
|
||||
{
|
||||
QuickPrint sample = new QuickPrint(this);
|
||||
sample.Print(ViewType.FloorPlan);
|
||||
}
|
||||
|
||||
public void QuickPrint_Elevations()
|
||||
{
|
||||
QuickPrint sample = new QuickPrint(this);
|
||||
sample.Print(ViewType.Elevation);
|
||||
}
|
||||
|
||||
public void QuickPrint_Section()
|
||||
{
|
||||
QuickPrint sample = new QuickPrint(this);
|
||||
sample.Print(ViewType.Section);
|
||||
}
|
||||
|
||||
public void FindAndReplaceText()
|
||||
{
|
||||
using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "FindAndReplaceText"))
|
||||
{
|
||||
trans.Start();
|
||||
FindAndReplaceText sample = new FindAndReplaceText(this);
|
||||
sample.Run();
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
public void CapitalizeText()
|
||||
{
|
||||
using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "CapitalizeText"))
|
||||
{
|
||||
trans.Start();
|
||||
CapitalizeText sample = new CapitalizeText(this);
|
||||
sample.Run();
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
public void FindAndReplaceWinType()
|
||||
{
|
||||
using (Transaction trans = new Transaction(this.ActiveUIDocument.Document, "FindAndReplaceWinType"))
|
||||
{
|
||||
trans.Start();
|
||||
FindAndReplaceWinType sample = new FindAndReplaceWinType(this);
|
||||
sample.Run();
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user