added Revit 2022 SDK minus except *rvt and *rfa

This commit is contained in:
Jeremy Tammik
2021-04-20 11:36:21 +02:00
parent 1133a82dc5
commit 7e327986e8
3034 changed files with 1245318 additions and 0 deletions
+579
View File
@@ -0,0 +1,579 @@
//
// (C) Copyright 2003-2020 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 System.Diagnostics;
using System.Globalization;
using System.Linq;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Analysis;
namespace Revit.SDK.Samples.PathOfTravelCreation.CS
{
/// <summary>
/// The options for creating the PathOfTravel.
/// </summary>
public enum PathCreateOptions
{
/// <summary>
/// Create from a single room's corners to single door
/// </summary>
SingleRoomCornersToSingleDoor,
/// <summary>
/// Create from all room's centerpoints to all doors
/// </summary>
AllRoomCenterToSingleDoor,
/// <summary>
/// Create from all room's corners to all doors
/// </summary>
AllRoomCornersToAllDoors,
}
/// <summary>
/// Implements the Revit add-in interface IExternalCommand
/// </summary>
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
public class Command : IExternalCommand
{
#region Class Interface Implementation
/// <summary>
/// Implement this method as an external command for Revit.
/// </summary>
/// <param name="commandData">An object that is passed to the external application
/// which contains data related to the command,
/// such as the application object and active view.</param>
/// <param name="message">A message that can be set by the external application
/// which will be displayed if a failure or cancellation is returned by
/// the external command.</param>
/// <param name="elements">A set of elements to which the external application
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
/// <returns>Return the status of the external command.
/// A result of Succeeded means that the API external method functioned as expected.
/// Cancelled can be used to signify that the user cancelled the external operation
/// at some point. Failure should be returned if the application is unable to proceed with
/// the operation.</returns>
public virtual Result Execute(ExternalCommandData commandData
, ref string message, ElementSet elements)
{
try
{
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
ViewPlan viewPlan = uiDoc.ActiveView as ViewPlan;
if (null == viewPlan)
{
TaskDialog td = new TaskDialog("Cannot create PathOfTravel.");
td.MainInstruction = String.Format("PathOfTravel can only be created for plan views.");
td.Show();
return Result.Succeeded;
}
using (CreateForm createForm = new CreateForm())
{
if (DialogResult.OK == createForm.ShowDialog())
{
if (createForm.PathCreateOption == PathCreateOptions.SingleRoomCornersToSingleDoor)
{
CreatePathsOfTravelInOneRoomMultiplePointsToOneDoor(uiDoc);
}
else if (createForm.PathCreateOption == PathCreateOptions.AllRoomCenterToSingleDoor)
{
CreatePathsOfTravelRoomCenterpointsToSingleDoor(uiDoc);
}
else
{
CreatePathsOfTravelInAllRoomsAllDoorsMultiplePointsManyToMany(uiDoc);
}
}
}
return Result.Succeeded;
}
catch (Exception ex)
{
message = ex.Message;
return Result.Failed;
}
}
#endregion
#region MainMethods
/// <summary>
/// Generates paths of travel for near-corner points in one room to a single selected door.
/// </summary>
private void CreatePathsOfTravelInOneRoomMultiplePointsToOneDoor(UIDocument uiDoc)
{
Document doc = uiDoc.Document;
ViewPlan viewPlan = uiDoc.ActiveView as ViewPlan;
ElementId levelId = viewPlan.GenLevel.Id;
// select room
Reference reference = uiDoc.Selection.PickObject(ObjectType.Element, new RoomSelectionFilter(), "Select a room");
Room room = doc.GetElement(reference) as Room;
// select exit door
Reference roomReference = uiDoc.Selection.PickObject(ObjectType.Element, new DoorSelectionFilter(), "Select a target door");
Instance doorElement = doc.GetElement(roomReference) as Instance;
Transform trf = doorElement.GetTransform();
XYZ endPoint = trf.Origin;
ResultsSummary resultsSummary = new ResultsSummary();
resultsSummary.numDoors = 1;
Stopwatch stopwatch = Stopwatch.StartNew();
GeneratePathsOfTravelForOneRoomOneDoor(doc, viewPlan, room, endPoint, resultsSummary);
stopwatch.Stop();
resultsSummary.elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
ShowResults(resultsSummary);
}
/// <summary>
/// Generates paths of travel from the center points of the room to a single door using the many to many approach. Does not collect and display results.
/// </summary>
private void CreatePathsOfTravelRoomCenterpointsToSingleDoor(UIDocument uiDoc)
{
Document doc = uiDoc.Document;
ViewPlan viewPlan = uiDoc.ActiveView as ViewPlan;
ElementId levelId = viewPlan.GenLevel.Id;
// select exit door
Reference reference = uiDoc.Selection.PickObject(ObjectType.Element, new DoorSelectionFilter(), "Select a target door");
Instance doorElement = doc.GetElement(reference) as Instance;
Transform trf = doorElement.GetTransform();
XYZ endPoint = trf.Origin;
// find all rooms
FilteredElementCollector fec = new FilteredElementCollector(doc);
fec.WherePasses(new Autodesk.Revit.DB.Architecture.RoomFilter());
List<XYZ> startPoints = new List<XYZ>();
foreach (Room room in fec.Cast<Room>().Where<Room>(rm => rm.Level.Id == levelId))
{
LocationPoint location = room.Location as LocationPoint;
if (location == null)
continue;
XYZ roomPoint = location.Point;
startPoints.Add(roomPoint);
}
// generate paths
using (Transaction t = new Transaction(doc, "Generate paths of travel"))
{
t.Start();
IList<PathOfTravelCalculationStatus> statuses;
PathOfTravel.CreateMapped(viewPlan, startPoints, new List<XYZ> { endPoint }, out statuses);
t.Commit();
}
}
/// <summary>
/// Creates paths of travel using all rooms on the given floor plan, starting from the near-corner points of those rooms, to all doors in the same floor plan.
/// This version uses Revit's many-to-many API with automatic mapping between start and endpoints.
/// </summary>
private void CreatePathsOfTravelInAllRoomsAllDoorsMultiplePointsManyToMany(UIDocument uiDoc)
{
Document doc = uiDoc.Document;
ViewPlan viewPlan = uiDoc.ActiveView as ViewPlan;
CreatePathsOfTravelInAllRoomsAllDoorsMultiplePointsManyToMany(doc, viewPlan, false);
}
#endregion
#region RoomUtils
/// <summary>
/// A selection filter that accepts selection of door elements only.
/// </summary>
class DoorSelectionFilter : ISelectionFilter
{
public bool AllowElement(Element element)
{
if (element.Category.Id == new ElementId(BuiltInCategory.OST_Doors))
{
return true;
}
return false;
}
public bool AllowReference(Reference refer, XYZ point)
{
return false;
}
}
/// <summary>
/// A selection filter that accepts selection of room elements only.
/// </summary>
class RoomSelectionFilter : ISelectionFilter
{
public bool AllowElement(Element element)
{
if (element is Room)
{
return true;
}
return false;
}
public bool AllowReference(Reference refer, XYZ point)
{
return false;
}
}
/// <summary>
/// Appends a list of the room's near-corner points to a pre-existing list.
/// </summary>
/// <remarks>
/// A near-corner point is offset from the room boundaries by 1.5 ft (18 inches). The points are calculated geometrically and some situations may not return
/// all logical near-corner points, or may return points which are inside furniture, casework or other design elements. Only the first boundary region of the room is
/// currently processed.
/// </remarks>
/// <param name="room"></param>
/// <param name="nearCornerPoints"></param>
/// <returns></returns>
private static void AppendRoomNearCornerPoints(Room room, List<XYZ> nearCornerPoints)
{
IList<IList<BoundarySegment>> segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions());
if (segments == null || segments.Count == 0)
return;
// First region only
IList<BoundarySegment> firstSegments = segments[0];
int numSegments = firstSegments.Count;
for (int i = 0; i < numSegments; i++)
{
BoundarySegment seg1 = firstSegments.ElementAt(i);
BoundarySegment seg2 = firstSegments.ElementAt(i == numSegments - 1 ? 0 : i + 1);
Curve curve1 = seg1.GetCurve();
Curve curve2 = seg2.GetCurve();
Curve offsetCurve1 = curve1.CreateOffset(-1.5, XYZ.BasisZ);
Curve offsetCurve2 = curve2.CreateOffset(-1.5, XYZ.BasisZ);
IntersectionResultArray intersections = null;
SetComparisonResult result = offsetCurve1.Intersect(offsetCurve2, out intersections);
// First intersection only
if (result == SetComparisonResult.Overlap && intersections.Size == 1)
{
nearCornerPoints.Add(intersections.get_Item(0).XYZPoint);
}
}
}
/// <summary>
/// Returns a list of the room's near-corner points.
/// </summary>
/// <remarks>
/// A near-corner point is offset from the room boundaries by 1.5 ft (18 inches). The points are calculated geometrically and some situations may not return
/// all logical near-corner points, or may return points which are inside furniture, casework or other design elements. Only the first boundary region of the room is
/// currently processed.
/// </remarks>
/// <param name="room"></param>
/// <returns></returns>
private static List<XYZ> GetRoomNearCornerPoints(Room room)
{
List<XYZ> nearCornerPoints = new List<XYZ>();
AppendRoomNearCornerPoints(room, nearCornerPoints);
return nearCornerPoints;
}
#endregion
#region PathOfTravelCreationUtils
/// <summary>
/// Shared implementation for use of Path of Travel bulk creation routine from all near-corner room points to all doors.
/// </summary>
/// <param name="doc"></param>
/// <param name="viewPlan"></param>
/// <param name="mapAllStartsToAllEnds"></param>
private static void CreatePathsOfTravelInAllRoomsAllDoorsMultiplePointsManyToMany(Document doc, ViewPlan viewPlan, bool mapAllStartsToAllEnds)
{
ElementId levelId = viewPlan.GenLevel.Id;
// find rooms on level
FilteredElementCollector fec = new FilteredElementCollector(doc, viewPlan.Id);
fec.WherePasses(new Autodesk.Revit.DB.Architecture.RoomFilter());
// find doors on level
FilteredElementCollector fec2 = new FilteredElementCollector(doc, viewPlan.Id);
fec2.OfCategory(BuiltInCategory.OST_Doors);
// setup results
ResultsSummary resultsSummary = new ResultsSummary();
List<XYZ> endPoints = new List<XYZ>();
// Collect rooms
List<Room> rooms = fec.Cast<Room>().ToList<Room>();
// Loop on doors and collect target points (the door's origin)
foreach (Element element in fec2)
{
Instance doorElement = (Instance)element;
Transform trf = doorElement.GetTransform();
endPoints.Add(trf.Origin);
}
resultsSummary.numDoors = endPoints.Count;
using (TransactionGroup group = new TransactionGroup(doc, "Generate all paths of travel"))
{
group.Start();
GeneratePathsOfTravelForRoomsToEndpointsManyToMany(doc, viewPlan, rooms, endPoints, resultsSummary, mapAllStartsToAllEnds);
group.Assimilate();
}
ShowResults(resultsSummary);
}
/// <summary>
/// Generates path of travels from room corner points to the corresponding list of end points.
/// </summary>
/// <param name="doc"></param>
/// <param name="viewPlan"></param>
/// <param name="rooms"></param>
/// <param name="endPoints"></param>
/// <param name="resultsSummary"></param>
/// <param name="mapAllStartsToAllEnds"></param>
private static void GeneratePathsOfTravelForRoomsToEndpointsManyToMany(Document doc, ViewPlan viewPlan, List<Room> rooms, List<XYZ> endPoints, ResultsSummary resultsSummary,
bool mapAllStartsToAllEnds)
{
List<XYZ> allSourcePoints = new List<XYZ>();
foreach (Room room in rooms)
{
AppendRoomNearCornerPoints(room, allSourcePoints);
}
// foreach (Room room in rooms)
// {
// LocationPoint location = room.Location as LocationPoint;
// if (location == null)
// continue;
// XYZ roomPoint = location.Point;
// allSourcePoints.Add(roomPoint);
// }
resultsSummary.numSourcePoints += allSourcePoints.Count;
List<XYZ> inputStartPoints = null;
List<XYZ> inputEndPoints = null;
// generate full lists of start and end points mapped to one another.
// This is for testing purposes, the API option to do this mapping is likely more efficient for this case.
if (mapAllStartsToAllEnds)
{
List<XYZ> allSourcePointsMappedToEnds = new List<XYZ>();
List<XYZ> allEndPointsMappedToEnds = new List<XYZ>();
foreach (XYZ source in allSourcePoints)
{
foreach (XYZ end in endPoints)
{
allSourcePointsMappedToEnds.Add(source);
allEndPointsMappedToEnds.Add(end);
}
}
inputStartPoints = allSourcePointsMappedToEnds;
inputEndPoints = allEndPointsMappedToEnds;
}
else
{
inputStartPoints = allSourcePoints;
inputEndPoints = endPoints;
}
GeneratePathsOfTravel(doc, viewPlan, inputStartPoints, inputEndPoints, resultsSummary, !mapAllStartsToAllEnds);
}
/// <summary>
/// Wraps all calls to PathOfTravel.Create() with multiple start/ends.
/// </summary>
/// <param name="doc"></param>
/// <param name="viewPlan"></param>
/// <param name="startPoints"></param>
/// <param name="endPoints"></param>
/// <param name="resultsSummary"></param>
/// <param name="mapAllStartsToAllEnds"></param>
private static void GeneratePathsOfTravel(Document doc, ViewPlan viewPlan, List<XYZ> startPoints, List<XYZ> endPoints, ResultsSummary resultsSummary, bool mapAllStartsToAllEnds)
{
// Performance monitoring
Stopwatch stopwatch = Stopwatch.StartNew();
using (Transaction t = new Transaction(doc, "Generate paths of travel"))
{
t.Start();
IList<PathOfTravelCalculationStatus> statuses;
IList<PathOfTravel> pathsOfTravel;
if (mapAllStartsToAllEnds)
pathsOfTravel = PathOfTravel.CreateMapped(viewPlan, startPoints, endPoints, out statuses);
else
pathsOfTravel = PathOfTravel.CreateMultiple(viewPlan, startPoints, endPoints, out statuses);
int i = 0;
foreach (PathOfTravel pathOfTravel in pathsOfTravel)
{
if (pathOfTravel == null)
{
resultsSummary.numFailures++;
resultsSummary.failuresFound.Add(statuses[i]);
}
else resultsSummary.numSuccesses++;
i++;
}
t.Commit();
}
stopwatch.Stop();
resultsSummary.elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
}
/// <summary>
/// Generates paths of travel from points in one room to many target locations using the slower (one-at-a-time) method.
/// </summary>
/// <param name="doc"></param>
/// <param name="viewPlan"></param>
/// <param name="room"></param>
/// <param name="endPoints"></param>
/// <param name="resultsSummary"></param>
private static void GeneratePathsOfTravelForOneRoomManyDoors(Document doc, ViewPlan viewPlan, Room room, List<XYZ> endPoints, ResultsSummary resultsSummary)
{
List<XYZ> sourcePoints = GetRoomNearCornerPoints(room);
resultsSummary.numSourcePoints += sourcePoints.Count;
// generate paths
using (Transaction t = new Transaction(doc, "Generate paths of travel"))
{
t.Start();
IList<PathOfTravelCalculationStatus> statuses;
IList<PathOfTravel> pathsOfTravel = PathOfTravel.CreateMapped(viewPlan, sourcePoints, endPoints, out statuses);
foreach (PathOfTravel pOT in pathsOfTravel)
{
if (pOT == null) resultsSummary.numFailures++;
else resultsSummary.numSuccesses++;
}
t.Commit();
}
}
/// <summary>
/// Generates paths of travel from points in one room to a single target location using the slower (one-at-a-time) method.
/// </summary>
/// <param name="doc"></param>
/// <param name="viewPlan"></param>
/// <param name="room"></param>
/// <param name="endPoint"></param>
/// <param name="resultsSummary"></param>
private static void GeneratePathsOfTravelForOneRoomOneDoor(Document doc, ViewPlan viewPlan, Room room, XYZ endPoint, ResultsSummary resultsSummary)
{
GeneratePathsOfTravelForOneRoomManyDoors(doc, viewPlan, room, new List<XYZ> { endPoint }, resultsSummary);
}
#endregion
#region ResultsUtils
/// <summary>
/// Class that aggregates the results of the path of travel creation for later display and/or logging.
/// </summary>
class ResultsSummary
{
public int numSourcePoints { get; set; }
public int numDoors { get; set; }
public int numSuccesses { get; set; }
public int numFailures { get; set; }
public long elapsedMilliseconds { get; set; }
public List<PathOfTravelCalculationStatus> failuresFound { get; set; }
public ResultsSummary()
{
failuresFound = new List<PathOfTravelCalculationStatus>();
}
}
/// <summary>
/// Displays the results from a run of path of travel creation using a TaskDialog.
/// </summary>
/// <param name="resultsSummary"></param>
private static void ShowResults(ResultsSummary resultsSummary)
{
CultureInfo ci = new CultureInfo("en-us");
int numOfPathsToCreate = resultsSummary.numSourcePoints * resultsSummary.numDoors;
double successRatePercent = (double)(resultsSummary.numSuccesses) / (double)(numOfPathsToCreate);
TaskDialog td = new TaskDialog("Results of PathOfTravel creation");
td.MainInstruction = String.Format("Path of Travel succeeded on {0} of known points", successRatePercent.ToString("P01", ci));
String details = String.Format("There were {0} room source points found in room analysis (via offsetting boundaries). " +
"They would be connected to {2} door target points. {1} failed to generate a Path of Travel out of {4} " +
"Processing took {3} milliseconds.",
resultsSummary.numSourcePoints, resultsSummary.numFailures, resultsSummary.numDoors, resultsSummary.elapsedMilliseconds, numOfPathsToCreate);
if (resultsSummary.numFailures > 0)
{
details += " Most likely reason for failures is an obstacle on or nearby to the source point.";
}
td.MainContent = details;
td.Show();
}
#endregion
}
}
+129
View File
@@ -0,0 +1,129 @@
namespace Revit.SDK.Samples.PathOfTravelCreation.CS
{
partial class CreateForm
{
/// <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.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.SuspendLayout();
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.buttonOK.Location = new System.Drawing.Point(211, 147);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 0;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(292, 147);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 1;
this.buttonCancel.Text = "&Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(15, 30);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(191, 20);
this.radioButton1.TabIndex = 2;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Single room corners to single door";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(15, 65);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(196, 20);
this.radioButton2.TabIndex = 3;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "All room centerpoints to single door";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Location = new System.Drawing.Point(15, 101);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(161, 20);
this.radioButton3.TabIndex = 5;
this.radioButton3.TabStop = true;
this.radioButton3.Text = "All room corners to all doors";
this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
//
// CreateForm
//
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(379, 182);
this.Controls.Add(this.radioButton3);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
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 = "CreateForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Select an option to create Path of Travel";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton3;
}
}
+71
View File
@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Revit.SDK.Samples.PathOfTravelCreation.CS
{
/// <summary>
/// Form presented to the user to fill in the options to control the path of travel creation.
/// </summary>
public partial class CreateForm : System.Windows.Forms.Form
{
PathCreateOptions m_createOption;
/// <summary>
/// Constructor
/// </summary>
public CreateForm()
{
InitializeComponent();
radioButton1.Checked = true;
m_createOption = PathCreateOptions.SingleRoomCornersToSingleDoor;
}
/// <summary>
/// The option for creating Path of Travel.
/// </summary>
public PathCreateOptions PathCreateOption
{
get
{
return m_createOption;
}
}
/// <summary>
/// Set the CreateOptions.SingleRoomCornersToSingleDoor option.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The event arg.</param>
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
m_createOption = PathCreateOptions.SingleRoomCornersToSingleDoor;
}
/// <summary>
/// Set the CreateOptions.AllRoomCenterToSingleDoor option.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The event arg.</param>
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
m_createOption = PathCreateOptions.AllRoomCenterToSingleDoor;
}
/// <summary>
/// Set the CreateOptions.AllRoomCornersToAllDoors option.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The event arg.</param>
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
m_createOption = PathCreateOptions.AllRoomCornersToAllDoors;
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Command">
<Assembly>PathOfTravel.dll</Assembly>
<ClientId>79250234-920b-4328-846b-5082f41b001a</ClientId>
<FullClassName>Revit.SDK.Samples.PathOfTravelCreation.CS.Command</FullClassName>
<Text>Create PathOfTravel.</Text>
<Description>This sample demonstrated how to create PathOfTravel elements from room(s) to door(s) in a plan view.</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<LanguageType>Unknown</LanguageType>
<VendorId>ADSK</VendorId>
</AddIn>
</RevitAddIns>
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{178B68F6-2120-448F-BEAB-84B824604F8D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Revit.SDK.Samples.PathOfTravel.CS</RootNamespace>
<AssemblyName>PathOfTravel</AssemblyName>
<StartupObject>
</StartupObject>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>bin\Debug\PathOfTravel.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>bin\Debug\PathOfTravel.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\Release\PathOfTravel.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core">
<RequiredTargetFramework>4.7</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Command.cs" />
<Compile Include="CreateForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CreateForm.Designer.cs">
<DependentUpon>CreateForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="CreateForm.resx">
<DependentUpon>CreateForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
</Project>
@@ -0,0 +1,55 @@
//
// (C) Copyright 2003-2016 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PathOfTravelCreation")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("bff81dc2-2bde-4f31-96ac-0aede32ed7ca")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Binary file not shown.