mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-08-30 16:42:51 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.ModelLines.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the Revit add-in interface IExternalCommand
|
||||
/// </summary>
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
|
||||
public class Command : IExternalCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Implement this method as an external command for Revit.
|
||||
/// </summary>
|
||||
/// <param name="commandData">An object that is passed to the external application
|
||||
/// which contains data related to the command,
|
||||
/// such as the application object and active view.</param>
|
||||
/// <param name="message">A message that can be set by the external application
|
||||
/// which will be displayed if a failure or cancellation is returned by
|
||||
/// the external command.</param>
|
||||
/// <param name="elements">A set of elements to which the external application
|
||||
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
/// <returns>Return the status of the external command.
|
||||
/// A result of Succeeded means that the API external method functioned as expected.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation
|
||||
/// at some point. Failure should be returned if the application is unable to proceed with
|
||||
/// the operation.</returns>
|
||||
public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
|
||||
ref string message,
|
||||
ElementSet elements)
|
||||
{
|
||||
try
|
||||
{
|
||||
Transaction documentTransaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "Document");
|
||||
documentTransaction.Start();
|
||||
// Get the application of revit
|
||||
Autodesk.Revit.UI.UIApplication revit = commandData.Application;
|
||||
|
||||
// New a real operation class.
|
||||
ModelLines deal = new ModelLines(revit);
|
||||
|
||||
// The main deal operation
|
||||
deal.Run();
|
||||
documentTransaction.Commit();
|
||||
|
||||
// if everything goes well, return succeeded.
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// If any error, give error information and return failed
|
||||
message = ex.Message;
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ModelLines.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The map class which store the data and display in informationDataGridView
|
||||
/// </summary>
|
||||
public class ModelCurveCounter
|
||||
{
|
||||
// Private members
|
||||
String m_typeName; // type name
|
||||
int m_number; // the number of corresponding type
|
||||
|
||||
// Properties
|
||||
/// <summary>
|
||||
/// Indicate the type name, such ModelArc, ModelLine, etc
|
||||
/// </summary>
|
||||
public String TypeName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_typeName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicate the number of the corresponding type which name stored in type name
|
||||
/// </summary>
|
||||
public int Number
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_number;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_number = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Methods
|
||||
/// <summary>
|
||||
/// The constructor of ModelCurveCounter
|
||||
/// </summary>
|
||||
/// <param name="typeName">The type name</param>
|
||||
public ModelCurveCounter(String typeName)
|
||||
{
|
||||
m_typeName = typeName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The map class which store the information used in elementIdComboBox comboBox in UI
|
||||
/// </summary>
|
||||
public class IdInfo
|
||||
{
|
||||
// Private members
|
||||
String m_text; // The display text
|
||||
int m_id; // The real value - id
|
||||
|
||||
// Properties
|
||||
/// <summary>
|
||||
/// The text displayed in the comboBox, as the DisplayMember
|
||||
/// </summary>
|
||||
public String DisplayText
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The real value of the comboBox, as the ValueMember
|
||||
/// </summary>
|
||||
public int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
}
|
||||
|
||||
// Methods
|
||||
/// <summary>
|
||||
/// The constructor of CreateInfo
|
||||
/// </summary>
|
||||
/// <param name="typeName">indicate model curve type</param>
|
||||
/// <param name="id">the element id</param>
|
||||
public IdInfo(String typeName, int id)
|
||||
{
|
||||
m_id = id; // Store the element id
|
||||
|
||||
// Generate the display text
|
||||
m_text = typeName + " : " + id.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>ModelLines.dll</Assembly>
|
||||
<ClientId>f79fd33a-0d84-48c8-bc0e-43df2c54ddd8</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.ModelLines.CS.Command</FullClassName>
|
||||
<Text>Model Lines</Text>
|
||||
<Description>Report the number of each model line type and allow the user to specify the shape and sketch plane to create some new model lines.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,533 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ModelLines.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The main deal class, which takes charge of showing the number of each model line type
|
||||
/// and creating one instance for each type using Revit API
|
||||
/// </summary>
|
||||
public class ModelLines
|
||||
{
|
||||
// Private members
|
||||
Autodesk.Revit.UI.UIApplication m_revit; // Store the reference of the application in revit
|
||||
Autodesk.Revit.Creation.Application m_createApp;// Store the create Application reference
|
||||
Autodesk.Revit.Creation.Document m_createDoc; // Store the create Document reference
|
||||
|
||||
ModelCurveArray m_lineArray; // Store the ModelLine references
|
||||
ModelCurveArray m_arcArray; // Store the ModelArc references
|
||||
ModelCurveArray m_ellipseArray; // Store the ModelEllipse references
|
||||
ModelCurveArray m_hermiteArray; // Store the ModelHermiteSpline references
|
||||
ModelCurveArray m_nurbArray; // Store the ModelNurbSpline references
|
||||
List<SketchPlane> m_sketchArray; // Store the SketchPlane references
|
||||
|
||||
List<ModelCurveCounter> m_informationMap; // Store the number of each model line type
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// The type-number map, store the number of each model line type
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<ModelCurveCounter> InformationMap
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ReadOnlyCollection<ModelCurveCounter>(m_informationMap);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the id information of all ModelEllipses in revit,
|
||||
/// which displayed this in elementIdComboBox when ellipseRadioButton checked
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<IdInfo> EllispeIDArray
|
||||
{
|
||||
get
|
||||
{
|
||||
// Create a new list
|
||||
List<IdInfo> idArray = new List<IdInfo>();
|
||||
// Add all ModelEllipses' id information into the list
|
||||
foreach (ModelCurve ellipse in m_ellipseArray)
|
||||
{
|
||||
IdInfo info = new IdInfo("ModelEllipse", ellipse.Id.IntegerValue);
|
||||
idArray.Add(info);
|
||||
}
|
||||
// return a read only list
|
||||
return new ReadOnlyCollection<IdInfo>(idArray);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the id information of all ModelHermiteSpline in revit,
|
||||
/// which displayed this in elementIdComboBox when hermiteSplineRadioButton checked
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<IdInfo> HermiteSplineIDArray
|
||||
{
|
||||
get
|
||||
{
|
||||
// Create a new list
|
||||
List<IdInfo> idArray = new List<IdInfo>();
|
||||
// Add all ModelHermiteSplines' id information into the list
|
||||
foreach (ModelCurve hermite in m_hermiteArray)
|
||||
{
|
||||
IdInfo info = new IdInfo("ModelHermiteSpline", hermite.Id.IntegerValue);
|
||||
idArray.Add(info);
|
||||
}
|
||||
// return a read only list
|
||||
return new ReadOnlyCollection<IdInfo>(idArray);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the id information of all ModelNurbSpline in revit,
|
||||
/// which displayed this in elementIdComboBox when NurbSplineRadioButton checked
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<IdInfo> NurbSplineIDArray
|
||||
{
|
||||
get
|
||||
{
|
||||
// Create a new list
|
||||
List<IdInfo> idArray = new List<IdInfo>();
|
||||
// Add all ModelNurbSplines' id information into the list
|
||||
foreach (ModelCurve nurb in m_nurbArray)
|
||||
{
|
||||
IdInfo info = new IdInfo("ModelNurbSpline", nurb.Id.IntegerValue);
|
||||
idArray.Add(info);
|
||||
}
|
||||
// return a read only list
|
||||
return new ReadOnlyCollection<IdInfo>(idArray);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allow the user to get all sketch plane in revit
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<IdInfo> SketchPlaneIDArray
|
||||
{
|
||||
get
|
||||
{
|
||||
// Create a new list
|
||||
List<IdInfo> idArray = new List<IdInfo>();
|
||||
// Add all SketchPlane' id information into the list
|
||||
foreach (SketchPlane sketch in m_sketchArray)
|
||||
{
|
||||
IdInfo info = new IdInfo("SketchPlane", sketch.Id.IntegerValue);
|
||||
idArray.Add(info);
|
||||
}
|
||||
// return a read only list
|
||||
return new ReadOnlyCollection<IdInfo>(idArray);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// The default constructor
|
||||
/// </summary>
|
||||
/// <param name="revit">The reference of the application in revit</param>
|
||||
public ModelLines(Autodesk.Revit.UI.UIApplication revit)
|
||||
{
|
||||
// Store the reference of the application for further use.
|
||||
m_revit = revit;
|
||||
// Get the create references
|
||||
m_createApp = m_revit.Application.Create; // Creation.Application
|
||||
m_createDoc = m_revit.ActiveUIDocument.Document.Create;// Creation.Document
|
||||
|
||||
// Construct all the ModelCurveArray instances for model lines
|
||||
m_lineArray = new ModelCurveArray();
|
||||
m_arcArray = new ModelCurveArray();
|
||||
m_ellipseArray = new ModelCurveArray();
|
||||
m_hermiteArray = new ModelCurveArray();
|
||||
m_nurbArray = new ModelCurveArray();
|
||||
|
||||
// Construct the sketch plane list data
|
||||
m_sketchArray = new List<SketchPlane>();
|
||||
|
||||
// Construct the information list data
|
||||
m_informationMap = new List<ModelCurveCounter>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This is the main deal method in this example.
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
// Get all sketch plane in revit
|
||||
GetSketchPlane();
|
||||
|
||||
// Get all model lines in revit
|
||||
GetModelLines();
|
||||
|
||||
// Initialize the InformationMap property for DataGridView display
|
||||
InitDisplayInformation();
|
||||
|
||||
// Display the form and allow the user to create one of each model line in revit
|
||||
using (ModelLinesForm displayForm = new ModelLinesForm(this))
|
||||
{
|
||||
displayForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new sketch plane which all model lines are placed on.
|
||||
/// </summary>
|
||||
/// <param name="normal"></param>
|
||||
/// <param name="origin"></param>
|
||||
public void CreateSketchPlane(Autodesk.Revit.DB.XYZ normal, Autodesk.Revit.DB.XYZ origin)
|
||||
{
|
||||
try
|
||||
{
|
||||
// First create a Geometry.Plane which need in NewSketchPlane() method
|
||||
Plane geometryPlane = Plane.CreateByNormalAndOrigin(normal, origin);
|
||||
if (null == geometryPlane) // assert the creation is successful
|
||||
{
|
||||
throw new Exception("Create the geometry plane failed.");
|
||||
}
|
||||
// Then create a sketch plane using the Geometry.Plane
|
||||
SketchPlane plane = SketchPlane.Create(m_revit.ActiveUIDocument.Document, geometryPlane);
|
||||
if (null == plane) // assert the creation is successful
|
||||
{
|
||||
throw new Exception("Create the sketch plane failed.");
|
||||
}
|
||||
|
||||
// Finally add the created plane into the sketch plane array
|
||||
m_sketchArray.Add(plane);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Can not create the sketch plane, message: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create the line(ModelLine)
|
||||
/// </summary>
|
||||
/// <param name="sketchId">the id of the sketch plane</param>
|
||||
/// <param name="startPoint">the start point of the line</param>
|
||||
/// <param name="endPoint">the end point of the line</param>
|
||||
public void CreateLine(int sketchId, Autodesk.Revit.DB.XYZ startPoint, Autodesk.Revit.DB.XYZ endPoint)
|
||||
{
|
||||
try
|
||||
{
|
||||
// First get the sketch plane by the giving element id.
|
||||
SketchPlane workPlane = GetSketchPlaneById(sketchId);
|
||||
|
||||
// Additional check: start point should not equal end point
|
||||
if (startPoint.Equals(endPoint))
|
||||
{
|
||||
throw new ArgumentException("Two points should not be the same.");
|
||||
}
|
||||
|
||||
// create geometry line
|
||||
Line geometryLine = Line.CreateBound(startPoint, endPoint);
|
||||
if (null == geometryLine) // assert the creation is successful
|
||||
{
|
||||
throw new Exception("Create the geometry line failed.");
|
||||
}
|
||||
// create the ModelLine
|
||||
ModelLine line = m_createDoc.NewModelCurve(geometryLine, workPlane) as ModelLine;
|
||||
if (null == line) // assert the creation is successful
|
||||
{
|
||||
throw new Exception("Create the ModelLine failed.");
|
||||
}
|
||||
// Add the created ModelLine into the line array
|
||||
m_lineArray.Append(line);
|
||||
|
||||
// Finally refresh information map.
|
||||
RefreshInformationMap();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Can not create the ModelLine, message: " + ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create the arc(ModelArc)
|
||||
/// </summary>
|
||||
/// <param name="sketchId">the id of the sketch plane</param>
|
||||
/// <param name="startPoint">the start point of the arc</param>
|
||||
/// <param name="endPoint">the end point of the arc</param>
|
||||
/// <param name="thirdPoint">the third point which is on the arc</param>
|
||||
public void CreateArc(int sketchId, Autodesk.Revit.DB.XYZ startPoint, Autodesk.Revit.DB.XYZ endPoint, Autodesk.Revit.DB.XYZ thirdPoint)
|
||||
{
|
||||
try
|
||||
{
|
||||
// First get the sketch plane by the giving element id.
|
||||
SketchPlane workPlane = GetSketchPlaneById(sketchId);
|
||||
|
||||
// Additional check: the start, end and third point should not be the same
|
||||
if (startPoint.Equals(endPoint) || startPoint.Equals(thirdPoint)
|
||||
|| endPoint.Equals(thirdPoint))
|
||||
{
|
||||
throw new ArgumentException("Three points should not be the same.");
|
||||
}
|
||||
|
||||
// create the geometry arc
|
||||
Arc geometryArc = Arc.Create(startPoint, endPoint, thirdPoint);
|
||||
if (null == geometryArc) // assert the creation is successful
|
||||
{
|
||||
throw new Exception("Create the geometry arc failed.");
|
||||
}
|
||||
// create the ModelArc
|
||||
ModelArc arc = m_createDoc.NewModelCurve(geometryArc, workPlane) as ModelArc;
|
||||
if (null == arc) // assert the creation is successful
|
||||
{
|
||||
throw new Exception("Create the ModelArc failed.");
|
||||
}
|
||||
// Add the created ModelArc into the arc array
|
||||
m_arcArray.Append(arc);
|
||||
|
||||
// Finally refresh information map.
|
||||
RefreshInformationMap();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Can not create the ModelArc, message: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create other lines, including Ellipse, HermiteSpline and NurbSpline
|
||||
/// </summary>
|
||||
/// <param name="sketchId">the id of the sketch plane</param>
|
||||
/// <param name="elementId">the element id which copy the curve from</param>
|
||||
/// <param name="offsetPoint">the offset direction from the copied line</param>
|
||||
public void CreateOthers(int sketchId, int elementId, Autodesk.Revit.DB.XYZ offsetPoint)
|
||||
{
|
||||
// First get the sketch plane by the giving element id.
|
||||
SketchPlane workPlane = GetSketchPlaneById(sketchId);
|
||||
|
||||
// Because the geometry of these lines can't be created by API,
|
||||
// use an existing geometry to create ModelEllipse, ModelHermiteSpline, ModelNurbSpline
|
||||
// and then move a bit to make the user see the creation distinctly
|
||||
|
||||
// This method use NewModelCurveArray() method to create model lines
|
||||
CurveArray curves = m_createApp.NewCurveArray();// create a geometry curve array
|
||||
|
||||
// Get the Autodesk.Revit.DB.ElementId which used to get the corresponding element
|
||||
ModelCurve selected = GetElementById(elementId) as ModelCurve;
|
||||
if (null == selected)
|
||||
{
|
||||
throw new Exception("Don't have the element you select");
|
||||
}
|
||||
|
||||
// add the geometry curve of the element
|
||||
curves.Append(selected.GeometryCurve); // add the geometry ellipse
|
||||
|
||||
// Create the model line
|
||||
ModelCurveArray modelCurves = m_createDoc.NewModelCurveArray(curves, workPlane);
|
||||
if (null == modelCurves || 1 != modelCurves.Size) // assert the creation is successful
|
||||
{
|
||||
throw new Exception("Create the ModelCurveArray failed.");
|
||||
}
|
||||
|
||||
// Offset the create model lines in order to differentiate the existing model lines
|
||||
foreach (ModelCurve m in modelCurves)
|
||||
{
|
||||
ElementTransformUtils.MoveElement(m.Document, m.Id, offsetPoint); // move the lines
|
||||
}
|
||||
// Add the created model lines into corresponding array
|
||||
foreach (ModelCurve m in modelCurves)
|
||||
{
|
||||
switch (m.GetType().Name)
|
||||
{
|
||||
case "ModelEllipse": // If the line is Ellipse
|
||||
m_ellipseArray.Append(m); // Add to Ellipse array
|
||||
break;
|
||||
case "ModelHermiteSpline": // If the line is HermiteSpline
|
||||
m_hermiteArray.Append(m); // Add to HermiteSpline array
|
||||
break;
|
||||
case "ModelNurbSpline": // If the line is NurbSpline
|
||||
m_nurbArray.Append(m); // Add to NurbSpline
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Finally refresh information map.
|
||||
RefreshInformationMap();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Get all model lines in current document of revit, and store them into the arrays
|
||||
/// </summary>
|
||||
void GetModelLines()
|
||||
{
|
||||
// Search all elements in current document and find all model lines
|
||||
// ModelLine is not supported by ElementClassFilter/OfClass,
|
||||
// so use its base type to find all CurveElement and then process the results further to find modelline
|
||||
IEnumerable<ModelCurve> modelCurves = from elem in ((new FilteredElementCollector(m_revit.ActiveUIDocument.Document)).OfClass(typeof(CurveElement)).ToElements())
|
||||
let modelCurve = elem as ModelCurve
|
||||
where modelCurve != null
|
||||
select modelCurve;
|
||||
foreach (ModelCurve modelCurve in modelCurves)
|
||||
{
|
||||
// Get all the ModelLines references
|
||||
String typeName = modelCurve.GetType().Name;
|
||||
switch (typeName)
|
||||
{
|
||||
case "ModelLine": // Get all the ModelLine references
|
||||
m_lineArray.Append(modelCurve);
|
||||
break;
|
||||
case "ModelArc": // Get all the ModelArc references
|
||||
m_arcArray.Append(modelCurve);
|
||||
break;
|
||||
case "ModelEllipse":// Get all the ModelEllipse references
|
||||
m_ellipseArray.Append(modelCurve);
|
||||
break;
|
||||
case "ModelHermiteSpline": // Get all the ModelHermiteSpline references
|
||||
m_hermiteArray.Append(modelCurve);
|
||||
break;
|
||||
case "ModelNurbSpline": // Get all the ModelNurbSpline references
|
||||
m_nurbArray.Append(modelCurve);
|
||||
break;
|
||||
default: // If not a model curve, just break
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get all sketch planes in revit
|
||||
/// </summary>
|
||||
void GetSketchPlane()
|
||||
{
|
||||
// Search all elements in current document and find all sketch planes
|
||||
IList<Element> elements = (new FilteredElementCollector(m_revit.ActiveUIDocument.Document)).OfClass(typeof(SketchPlane)).ToElements();
|
||||
foreach (Element elem in elements)
|
||||
{
|
||||
SketchPlane sketch = elem as SketchPlane;
|
||||
if (null != sketch)
|
||||
{
|
||||
// Add all the sketchPlane into the array
|
||||
m_sketchArray.Add(sketch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initiate the information map which will display in information DataGridView
|
||||
/// </summary>
|
||||
void InitDisplayInformation()
|
||||
{
|
||||
// First add the type name into the m_information data map
|
||||
m_informationMap.Add(new ModelCurveCounter("ModelArc"));
|
||||
m_informationMap.Add(new ModelCurveCounter("ModelLine"));
|
||||
m_informationMap.Add(new ModelCurveCounter("ModelEllipse"));
|
||||
m_informationMap.Add(new ModelCurveCounter("ModelHermiteSpline"));
|
||||
m_informationMap.Add(new ModelCurveCounter("ModelNurbSpline"));
|
||||
|
||||
// Use RefreshInformationMap to refresh the number of each model line type
|
||||
RefreshInformationMap();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Refresh the m_informationMap member, include the number of each model line type
|
||||
/// </summary>
|
||||
public void RefreshInformationMap()
|
||||
{
|
||||
// Search the model line types in the map, and refresh the number of each type
|
||||
foreach (ModelCurveCounter info in m_informationMap)
|
||||
{
|
||||
switch (info.TypeName)
|
||||
{
|
||||
case "ModelArc": // if the type is ModelAre
|
||||
info.Number = m_arcArray.Size; // refresh the number of arc
|
||||
break;
|
||||
case "ModelLine": // if the type is ModelLine
|
||||
info.Number = m_lineArray.Size; // refresh the number of line
|
||||
break;
|
||||
case "ModelEllipse":// If the type is ModelEllipse
|
||||
info.Number = m_ellipseArray.Size; // refresh the number of ellipse
|
||||
break;
|
||||
case "ModelHermiteSpline": // If the type is ModelHermiteSpline
|
||||
info.Number = m_hermiteArray.Size; // refresh the number of HermiteSpline
|
||||
break;
|
||||
case "ModelNurbSpline": // If the type is ModelNurbSpline
|
||||
info.Number = m_nurbArray.Size; // refresh the number of NurbSpline
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Use Autodesk.Revit.DB.ElementId to get the corresponding element
|
||||
/// </summary>
|
||||
/// <param name="id">the element id value</param>
|
||||
/// <returns>the corresponding element</returns>
|
||||
Autodesk.Revit.DB.Element GetElementById(int id)
|
||||
{
|
||||
// Create a Autodesk.Revit.DB.ElementId data
|
||||
Autodesk.Revit.DB.ElementId elementId = new Autodesk.Revit.DB.ElementId(id);
|
||||
|
||||
// Get the corresponding element
|
||||
return m_revit.ActiveUIDocument.Document.GetElement(elementId);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Use Autodesk.Revit.DB.ElementId to get the corresponding sketch plane
|
||||
/// </summary>
|
||||
/// <param name="id">the element id value</param>
|
||||
/// <returns>the corresponding sketch plane</returns>
|
||||
SketchPlane GetSketchPlaneById(int id)
|
||||
{
|
||||
// First get the sketch plane by the giving element id.
|
||||
SketchPlane workPlane = GetElementById(id) as SketchPlane;
|
||||
if (null == workPlane)
|
||||
{
|
||||
throw new Exception("Don't have the work plane you select.");
|
||||
}
|
||||
return workPlane;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F3413A79-C2DC-4C02-A03A-B614123258BC}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ModelLines</RootNamespace>
|
||||
<AssemblyName>ModelLines</AssemblyName>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="Information.cs" />
|
||||
<Compile Include="ModelLines.cs" />
|
||||
<Compile Include="ModelLinesForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ModelLinesForm.Designer.cs">
|
||||
<DependentUpon>ModelLinesForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="PointUserControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PointUserControl.Designer.cs">
|
||||
<DependentUpon>PointUserControl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SketchPlaneForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SketchPlaneForm.Designer.cs">
|
||||
<DependentUpon>SketchPlaneForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ModelLinesForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>ModelLinesForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="PointUserControl.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>PointUserControl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="SketchPlaneForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>SketchPlaneForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
|
||||
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
+446
@@ -0,0 +1,446 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
namespace Revit.SDK.Samples.ModelLines.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The Mail Form
|
||||
/// </summary>
|
||||
partial class ModelLinesForm
|
||||
{
|
||||
/// <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.informationGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.informationDataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.typeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.numberColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.otherPanel = new System.Windows.Forms.Panel();
|
||||
this.offsetPointUserControl = new Revit.SDK.Samples.ModelLines.CS.PointUserControl();
|
||||
this.elementIdComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.offsetLabel = new System.Windows.Forms.Label();
|
||||
this.copyFromLabel = new System.Windows.Forms.Label();
|
||||
this.otherInfoLabel = new System.Windows.Forms.Label();
|
||||
this.creationGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.createSketchPlaneButton = new System.Windows.Forms.Button();
|
||||
this.sketchPlaneComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.sketchPlaneLabel = new System.Windows.Forms.Label();
|
||||
this.NurbSplineRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.hermiteSplineRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.ellipseRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.arcRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.lineRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.lineArcPanel = new System.Windows.Forms.Panel();
|
||||
this.lineArcInfoLabel = new System.Windows.Forms.Label();
|
||||
this.thirdPointUserControl = new Revit.SDK.Samples.ModelLines.CS.PointUserControl();
|
||||
this.secondPointUserControl = new Revit.SDK.Samples.ModelLines.CS.PointUserControl();
|
||||
this.thirdPointLabel = new System.Windows.Forms.Label();
|
||||
this.secondPointLabel = new System.Windows.Forms.Label();
|
||||
this.firstPointLabel = new System.Windows.Forms.Label();
|
||||
this.firstPointUserControl = new Revit.SDK.Samples.ModelLines.CS.PointUserControl();
|
||||
this.createButton = new System.Windows.Forms.Button();
|
||||
this.closeButton = new System.Windows.Forms.Button();
|
||||
this.informationGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.informationDataGridView)).BeginInit();
|
||||
this.otherPanel.SuspendLayout();
|
||||
this.creationGroupBox.SuspendLayout();
|
||||
this.lineArcPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// informationGroupBox
|
||||
//
|
||||
this.informationGroupBox.Controls.Add(this.informationDataGridView);
|
||||
this.informationGroupBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.informationGroupBox.Name = "informationGroupBox";
|
||||
this.informationGroupBox.Size = new System.Drawing.Size(481, 161);
|
||||
this.informationGroupBox.TabIndex = 1;
|
||||
this.informationGroupBox.TabStop = false;
|
||||
this.informationGroupBox.Text = "Model Lines Information";
|
||||
//
|
||||
// informationDataGridView
|
||||
//
|
||||
this.informationDataGridView.AllowUserToAddRows = false;
|
||||
this.informationDataGridView.AllowUserToDeleteRows = false;
|
||||
this.informationDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.informationDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.typeColumn,
|
||||
this.numberColumn});
|
||||
this.informationDataGridView.Location = new System.Drawing.Point(6, 19);
|
||||
this.informationDataGridView.Name = "informationDataGridView";
|
||||
this.informationDataGridView.ReadOnly = true;
|
||||
this.informationDataGridView.RowHeadersVisible = false;
|
||||
this.informationDataGridView.Size = new System.Drawing.Size(469, 133);
|
||||
this.informationDataGridView.TabIndex = 1;
|
||||
//
|
||||
// typeColumn
|
||||
//
|
||||
this.typeColumn.HeaderText = "Type";
|
||||
this.typeColumn.Name = "typeColumn";
|
||||
this.typeColumn.ReadOnly = true;
|
||||
this.typeColumn.Width = 150;
|
||||
//
|
||||
// numberColumn
|
||||
//
|
||||
this.numberColumn.HeaderText = "Number";
|
||||
this.numberColumn.Name = "numberColumn";
|
||||
this.numberColumn.ReadOnly = true;
|
||||
this.numberColumn.Width = 150;
|
||||
//
|
||||
// otherPanel
|
||||
//
|
||||
this.otherPanel.Controls.Add(this.offsetPointUserControl);
|
||||
this.otherPanel.Controls.Add(this.elementIdComboBox);
|
||||
this.otherPanel.Controls.Add(this.offsetLabel);
|
||||
this.otherPanel.Controls.Add(this.copyFromLabel);
|
||||
this.otherPanel.Controls.Add(this.otherInfoLabel);
|
||||
this.otherPanel.Location = new System.Drawing.Point(7, 19);
|
||||
this.otherPanel.Name = "otherPanel";
|
||||
this.otherPanel.Size = new System.Drawing.Size(346, 117);
|
||||
this.otherPanel.TabIndex = 4;
|
||||
this.otherPanel.Visible = false;
|
||||
//
|
||||
// offsetPointUserControl
|
||||
//
|
||||
this.offsetPointUserControl.Location = new System.Drawing.Point(118, 81);
|
||||
this.offsetPointUserControl.Name = "offsetPointUserControl";
|
||||
this.offsetPointUserControl.Size = new System.Drawing.Size(213, 28);
|
||||
this.offsetPointUserControl.TabIndex = 3;
|
||||
//
|
||||
// elementIdComboBox
|
||||
//
|
||||
this.elementIdComboBox.FormattingEnabled = true;
|
||||
this.elementIdComboBox.Location = new System.Drawing.Point(117, 39);
|
||||
this.elementIdComboBox.Name = "elementIdComboBox";
|
||||
this.elementIdComboBox.Size = new System.Drawing.Size(213, 21);
|
||||
this.elementIdComboBox.TabIndex = 4;
|
||||
//
|
||||
// offsetLabel
|
||||
//
|
||||
this.offsetLabel.AutoSize = true;
|
||||
this.offsetLabel.Location = new System.Drawing.Point(24, 87);
|
||||
this.offsetLabel.Name = "offsetLabel";
|
||||
this.offsetLabel.Size = new System.Drawing.Size(38, 13);
|
||||
this.offsetLabel.TabIndex = 2;
|
||||
this.offsetLabel.Text = "Offset:";
|
||||
//
|
||||
// copyFromLabel
|
||||
//
|
||||
this.copyFromLabel.AutoSize = true;
|
||||
this.copyFromLabel.Location = new System.Drawing.Point(24, 42);
|
||||
this.copyFromLabel.Name = "copyFromLabel";
|
||||
this.copyFromLabel.Size = new System.Drawing.Size(82, 13);
|
||||
this.copyFromLabel.TabIndex = 1;
|
||||
this.copyFromLabel.Text = "Use curve from:";
|
||||
//
|
||||
// otherInfoLabel
|
||||
//
|
||||
this.otherInfoLabel.AutoSize = true;
|
||||
this.otherInfoLabel.Location = new System.Drawing.Point(3, 12);
|
||||
this.otherInfoLabel.Name = "otherInfoLabel";
|
||||
this.otherInfoLabel.Size = new System.Drawing.Size(145, 13);
|
||||
this.otherInfoLabel.TabIndex = 0;
|
||||
this.otherInfoLabel.Text = "New ellipse need information:";
|
||||
//
|
||||
// creationGroupBox
|
||||
//
|
||||
this.creationGroupBox.Controls.Add(this.createSketchPlaneButton);
|
||||
this.creationGroupBox.Controls.Add(this.sketchPlaneComboBox);
|
||||
this.creationGroupBox.Controls.Add(this.sketchPlaneLabel);
|
||||
this.creationGroupBox.Controls.Add(this.NurbSplineRadioButton);
|
||||
this.creationGroupBox.Controls.Add(this.hermiteSplineRadioButton);
|
||||
this.creationGroupBox.Controls.Add(this.ellipseRadioButton);
|
||||
this.creationGroupBox.Controls.Add(this.arcRadioButton);
|
||||
this.creationGroupBox.Controls.Add(this.lineRadioButton);
|
||||
this.creationGroupBox.Controls.Add(this.otherPanel);
|
||||
this.creationGroupBox.Controls.Add(this.lineArcPanel);
|
||||
this.creationGroupBox.Location = new System.Drawing.Point(12, 179);
|
||||
this.creationGroupBox.Name = "creationGroupBox";
|
||||
this.creationGroupBox.Size = new System.Drawing.Size(481, 167);
|
||||
this.creationGroupBox.TabIndex = 3;
|
||||
this.creationGroupBox.TabStop = false;
|
||||
this.creationGroupBox.Text = "Model Lines Creation";
|
||||
//
|
||||
// createSketchPlaneButton
|
||||
//
|
||||
this.createSketchPlaneButton.Location = new System.Drawing.Point(294, 139);
|
||||
this.createSketchPlaneButton.Name = "createSketchPlaneButton";
|
||||
this.createSketchPlaneButton.Size = new System.Drawing.Size(44, 23);
|
||||
this.createSketchPlaneButton.TabIndex = 5;
|
||||
this.createSketchPlaneButton.Text = "&New";
|
||||
this.createSketchPlaneButton.UseVisualStyleBackColor = true;
|
||||
this.createSketchPlaneButton.Click += new System.EventHandler(this.createSketchPlaneButton_Click);
|
||||
//
|
||||
// sketchPlaneComboBox
|
||||
//
|
||||
this.sketchPlaneComboBox.FormattingEnabled = true;
|
||||
this.sketchPlaneComboBox.Location = new System.Drawing.Point(119, 139);
|
||||
this.sketchPlaneComboBox.Name = "sketchPlaneComboBox";
|
||||
this.sketchPlaneComboBox.Size = new System.Drawing.Size(162, 21);
|
||||
this.sketchPlaneComboBox.TabIndex = 4;
|
||||
//
|
||||
// sketchPlaneLabel
|
||||
//
|
||||
this.sketchPlaneLabel.AutoSize = true;
|
||||
this.sketchPlaneLabel.Location = new System.Drawing.Point(10, 144);
|
||||
this.sketchPlaneLabel.Name = "sketchPlaneLabel";
|
||||
this.sketchPlaneLabel.Size = new System.Drawing.Size(74, 13);
|
||||
this.sketchPlaneLabel.TabIndex = 18;
|
||||
this.sketchPlaneLabel.Text = "Sketch Plane:";
|
||||
//
|
||||
// NurbSplineRadioButton
|
||||
//
|
||||
this.NurbSplineRadioButton.AutoSize = true;
|
||||
this.NurbSplineRadioButton.Location = new System.Drawing.Point(359, 140);
|
||||
this.NurbSplineRadioButton.Name = "NurbSplineRadioButton";
|
||||
this.NurbSplineRadioButton.Size = new System.Drawing.Size(106, 17);
|
||||
this.NurbSplineRadioButton.TabIndex = 10;
|
||||
this.NurbSplineRadioButton.TabStop = true;
|
||||
this.NurbSplineRadioButton.Text = "ModelNurbSpline";
|
||||
this.NurbSplineRadioButton.UseVisualStyleBackColor = true;
|
||||
this.NurbSplineRadioButton.CheckedChanged += new System.EventHandler(this.NurbSplineRadioButton_CheckedChanged);
|
||||
//
|
||||
// hermiteSplineRadioButton
|
||||
//
|
||||
this.hermiteSplineRadioButton.AutoSize = true;
|
||||
this.hermiteSplineRadioButton.Location = new System.Drawing.Point(359, 111);
|
||||
this.hermiteSplineRadioButton.Name = "hermiteSplineRadioButton";
|
||||
this.hermiteSplineRadioButton.Size = new System.Drawing.Size(119, 17);
|
||||
this.hermiteSplineRadioButton.TabIndex = 9;
|
||||
this.hermiteSplineRadioButton.TabStop = true;
|
||||
this.hermiteSplineRadioButton.Text = "ModelHermiteSpline";
|
||||
this.hermiteSplineRadioButton.UseVisualStyleBackColor = true;
|
||||
this.hermiteSplineRadioButton.CheckedChanged += new System.EventHandler(this.hermiteSplineRadioButton_CheckedChanged);
|
||||
//
|
||||
// ellipseRadioButton
|
||||
//
|
||||
this.ellipseRadioButton.AutoSize = true;
|
||||
this.ellipseRadioButton.Location = new System.Drawing.Point(359, 82);
|
||||
this.ellipseRadioButton.Name = "ellipseRadioButton";
|
||||
this.ellipseRadioButton.Size = new System.Drawing.Size(84, 17);
|
||||
this.ellipseRadioButton.TabIndex = 8;
|
||||
this.ellipseRadioButton.TabStop = true;
|
||||
this.ellipseRadioButton.Text = "ModelEllipse";
|
||||
this.ellipseRadioButton.UseVisualStyleBackColor = true;
|
||||
this.ellipseRadioButton.CheckedChanged += new System.EventHandler(this.ellipseRadioButton_CheckedChanged);
|
||||
//
|
||||
// arcRadioButton
|
||||
//
|
||||
this.arcRadioButton.AutoSize = true;
|
||||
this.arcRadioButton.Location = new System.Drawing.Point(359, 24);
|
||||
this.arcRadioButton.Name = "arcRadioButton";
|
||||
this.arcRadioButton.Size = new System.Drawing.Size(70, 17);
|
||||
this.arcRadioButton.TabIndex = 6;
|
||||
this.arcRadioButton.TabStop = true;
|
||||
this.arcRadioButton.Text = "ModelArc";
|
||||
this.arcRadioButton.UseVisualStyleBackColor = true;
|
||||
this.arcRadioButton.CheckedChanged += new System.EventHandler(this.arcRadioButton_CheckedChanged);
|
||||
//
|
||||
// lineRadioButton
|
||||
//
|
||||
this.lineRadioButton.AutoSize = true;
|
||||
this.lineRadioButton.Location = new System.Drawing.Point(359, 53);
|
||||
this.lineRadioButton.Name = "lineRadioButton";
|
||||
this.lineRadioButton.Size = new System.Drawing.Size(74, 17);
|
||||
this.lineRadioButton.TabIndex = 7;
|
||||
this.lineRadioButton.TabStop = true;
|
||||
this.lineRadioButton.Text = "ModelLine";
|
||||
this.lineRadioButton.UseVisualStyleBackColor = true;
|
||||
this.lineRadioButton.CheckedChanged += new System.EventHandler(this.lineRadioButton_CheckedChanged);
|
||||
//
|
||||
// lineArcPanel
|
||||
//
|
||||
this.lineArcPanel.Controls.Add(this.lineArcInfoLabel);
|
||||
this.lineArcPanel.Controls.Add(this.thirdPointUserControl);
|
||||
this.lineArcPanel.Controls.Add(this.secondPointUserControl);
|
||||
this.lineArcPanel.Controls.Add(this.thirdPointLabel);
|
||||
this.lineArcPanel.Controls.Add(this.secondPointLabel);
|
||||
this.lineArcPanel.Controls.Add(this.firstPointLabel);
|
||||
this.lineArcPanel.Controls.Add(this.firstPointUserControl);
|
||||
this.lineArcPanel.Location = new System.Drawing.Point(7, 19);
|
||||
this.lineArcPanel.Name = "lineArcPanel";
|
||||
this.lineArcPanel.Size = new System.Drawing.Size(346, 117);
|
||||
this.lineArcPanel.TabIndex = 5;
|
||||
this.lineArcPanel.Visible = false;
|
||||
//
|
||||
// lineArcInfoLabel
|
||||
//
|
||||
this.lineArcInfoLabel.AutoSize = true;
|
||||
this.lineArcInfoLabel.Location = new System.Drawing.Point(3, 12);
|
||||
this.lineArcInfoLabel.Name = "lineArcInfoLabel";
|
||||
this.lineArcInfoLabel.Size = new System.Drawing.Size(131, 13);
|
||||
this.lineArcInfoLabel.TabIndex = 6;
|
||||
this.lineArcInfoLabel.Text = "New arc need information:";
|
||||
//
|
||||
// thirdPointUserControl
|
||||
//
|
||||
this.thirdPointUserControl.Location = new System.Drawing.Point(118, 92);
|
||||
this.thirdPointUserControl.Name = "thirdPointUserControl";
|
||||
this.thirdPointUserControl.Size = new System.Drawing.Size(213, 22);
|
||||
this.thirdPointUserControl.TabIndex = 16;
|
||||
//
|
||||
// secondPointUserControl
|
||||
//
|
||||
this.secondPointUserControl.Location = new System.Drawing.Point(118, 63);
|
||||
this.secondPointUserControl.Name = "secondPointUserControl";
|
||||
this.secondPointUserControl.Size = new System.Drawing.Size(213, 25);
|
||||
this.secondPointUserControl.TabIndex = 15;
|
||||
//
|
||||
// thirdPointLabel
|
||||
//
|
||||
this.thirdPointLabel.AutoSize = true;
|
||||
this.thirdPointLabel.Location = new System.Drawing.Point(24, 96);
|
||||
this.thirdPointLabel.Name = "thirdPointLabel";
|
||||
this.thirdPointLabel.Size = new System.Drawing.Size(61, 13);
|
||||
this.thirdPointLabel.TabIndex = 13;
|
||||
this.thirdPointLabel.Text = "Third Point:";
|
||||
//
|
||||
// secondPointLabel
|
||||
//
|
||||
this.secondPointLabel.AutoSize = true;
|
||||
this.secondPointLabel.Location = new System.Drawing.Point(24, 67);
|
||||
this.secondPointLabel.Name = "secondPointLabel";
|
||||
this.secondPointLabel.Size = new System.Drawing.Size(74, 13);
|
||||
this.secondPointLabel.TabIndex = 12;
|
||||
this.secondPointLabel.Text = "Second Point:";
|
||||
//
|
||||
// firstPointLabel
|
||||
//
|
||||
this.firstPointLabel.AutoSize = true;
|
||||
this.firstPointLabel.Location = new System.Drawing.Point(24, 42);
|
||||
this.firstPointLabel.Name = "firstPointLabel";
|
||||
this.firstPointLabel.Size = new System.Drawing.Size(56, 13);
|
||||
this.firstPointLabel.TabIndex = 11;
|
||||
this.firstPointLabel.Text = "First Point:";
|
||||
//
|
||||
// firstPointUserControl
|
||||
//
|
||||
this.firstPointUserControl.Location = new System.Drawing.Point(118, 35);
|
||||
this.firstPointUserControl.Name = "firstPointUserControl";
|
||||
this.firstPointUserControl.Size = new System.Drawing.Size(213, 25);
|
||||
this.firstPointUserControl.TabIndex = 2;
|
||||
//
|
||||
// createButton
|
||||
//
|
||||
this.createButton.Location = new System.Drawing.Point(337, 352);
|
||||
this.createButton.Name = "createButton";
|
||||
this.createButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.createButton.TabIndex = 11;
|
||||
this.createButton.Text = "C&reate";
|
||||
this.createButton.UseVisualStyleBackColor = true;
|
||||
this.createButton.Click += new System.EventHandler(this.createButton_Click);
|
||||
//
|
||||
// closeButton
|
||||
//
|
||||
this.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.closeButton.Location = new System.Drawing.Point(418, 352);
|
||||
this.closeButton.Name = "closeButton";
|
||||
this.closeButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.closeButton.TabIndex = 12;
|
||||
this.closeButton.Text = "&Close";
|
||||
this.closeButton.UseVisualStyleBackColor = true;
|
||||
this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
|
||||
//
|
||||
// ModelLinesForm
|
||||
//
|
||||
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(506, 382);
|
||||
this.Controls.Add(this.closeButton);
|
||||
this.Controls.Add(this.createButton);
|
||||
this.Controls.Add(this.creationGroupBox);
|
||||
this.Controls.Add(this.informationGroupBox);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ModelLinesForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Model Lines";
|
||||
this.informationGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.informationDataGridView)).EndInit();
|
||||
this.otherPanel.ResumeLayout(false);
|
||||
this.otherPanel.PerformLayout();
|
||||
this.creationGroupBox.ResumeLayout(false);
|
||||
this.creationGroupBox.PerformLayout();
|
||||
this.lineArcPanel.ResumeLayout(false);
|
||||
this.lineArcPanel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox informationGroupBox;
|
||||
private System.Windows.Forms.DataGridView informationDataGridView;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn typeColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn numberColumn;
|
||||
private System.Windows.Forms.GroupBox creationGroupBox;
|
||||
private System.Windows.Forms.Button createButton;
|
||||
private System.Windows.Forms.Button closeButton;
|
||||
private System.Windows.Forms.Panel lineArcPanel;
|
||||
private System.Windows.Forms.Label thirdPointLabel;
|
||||
private System.Windows.Forms.Label secondPointLabel;
|
||||
private System.Windows.Forms.Label firstPointLabel;
|
||||
private System.Windows.Forms.Panel otherPanel;
|
||||
private System.Windows.Forms.Label otherInfoLabel;
|
||||
private System.Windows.Forms.Label offsetLabel;
|
||||
private System.Windows.Forms.Label copyFromLabel;
|
||||
private System.Windows.Forms.ComboBox elementIdComboBox;
|
||||
private System.Windows.Forms.RadioButton NurbSplineRadioButton;
|
||||
private System.Windows.Forms.RadioButton hermiteSplineRadioButton;
|
||||
private System.Windows.Forms.RadioButton ellipseRadioButton;
|
||||
private System.Windows.Forms.RadioButton arcRadioButton;
|
||||
private System.Windows.Forms.RadioButton lineRadioButton;
|
||||
private PointUserControl offsetPointUserControl;
|
||||
private PointUserControl thirdPointUserControl;
|
||||
private PointUserControl secondPointUserControl;
|
||||
private PointUserControl firstPointUserControl;
|
||||
private System.Windows.Forms.Button createSketchPlaneButton;
|
||||
private System.Windows.Forms.ComboBox sketchPlaneComboBox;
|
||||
private System.Windows.Forms.Label sketchPlaneLabel;
|
||||
private System.Windows.Forms.Label lineArcInfoLabel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,432 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ModelLines.CS
|
||||
{
|
||||
public partial class ModelLinesForm : System.Windows.Forms.Form
|
||||
{
|
||||
#region Enum Define
|
||||
|
||||
/// <summary>
|
||||
/// Define the model line types in revit
|
||||
/// </summary>
|
||||
public enum LineType
|
||||
{
|
||||
ModelLine = 0, // ModelLine
|
||||
ModelArc = 1, // ModelArc
|
||||
ModelEllipse = 2, // ModelEllipse
|
||||
ModelHermiteSpline = 3, // ModelHermiteSpline
|
||||
ModelNurbSpline = 4 // ModelNurbSpline
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
// Private members
|
||||
ModelLines m_dataBuffer; // A reference of ModelLines.
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Constructor of ModelLinesForm
|
||||
/// </summary>
|
||||
/// <param name="dataBuffer">A reference of ModelLines class</param>
|
||||
public ModelLinesForm(ModelLines dataBuffer)
|
||||
{
|
||||
// Required for Windows Form Designer support
|
||||
InitializeComponent();
|
||||
|
||||
//Get a reference of ModelLines
|
||||
m_dataBuffer = dataBuffer;
|
||||
|
||||
// Initialize the information data grid view control
|
||||
InitializeInformationGrid();
|
||||
|
||||
// Initialize the sketch plane comboBox control
|
||||
BindComboBox(sketchPlaneComboBox, m_dataBuffer.SketchPlaneIDArray);
|
||||
sketchPlaneComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
|
||||
// Initialize the creation group information
|
||||
lineRadioButton.Checked = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region helper Fuctions
|
||||
|
||||
/// <summary>
|
||||
/// Bind the DataSource of the information DataGridView
|
||||
/// </summary>
|
||||
void InitializeInformationGrid()
|
||||
{
|
||||
// In order to change column name, disable AutoGenerateColumns property
|
||||
informationDataGridView.AutoGenerateColumns = false;
|
||||
// Bind the DataSource to corresponding property.
|
||||
informationDataGridView.DataSource = m_dataBuffer.InformationMap;
|
||||
typeColumn.DataPropertyName = "TypeName"; // set data property name
|
||||
typeColumn.Width = informationDataGridView.Width * 3 / 5; // set column width
|
||||
|
||||
numberColumn.DataPropertyName = "Number"; // set data property name
|
||||
numberColumn.Width = informationDataGridView.Width * 2 / 5 - 2; // set column width
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check the data which the user input are integrated or not
|
||||
/// </summary>
|
||||
/// <param name="createType"></param>
|
||||
/// <returns>If the data are integrated return true, otherwise false</returns>
|
||||
bool AssertDataIntegrity(LineType createType)
|
||||
{
|
||||
// check whether the user has selected a sketch plane
|
||||
if (null == sketchPlaneComboBox.SelectedValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check integrity according to the curve type
|
||||
switch (createType)
|
||||
{
|
||||
case LineType.ModelLine:
|
||||
// If the user want to create a line, check first and second points
|
||||
return (firstPointUserControl.AssertPointIntegrity()
|
||||
&& secondPointUserControl.AssertPointIntegrity());
|
||||
case LineType.ModelArc:
|
||||
// If the user create an arc, must check first, second and third points
|
||||
return (firstPointUserControl.AssertPointIntegrity()
|
||||
&& secondPointUserControl.AssertPointIntegrity()
|
||||
&& thirdPointUserControl.AssertPointIntegrity());
|
||||
case LineType.ModelEllipse: // ellipse
|
||||
case LineType.ModelHermiteSpline: // hermite spline
|
||||
case LineType.ModelNurbSpline: // nurb spline
|
||||
// If the user create ellipse, hermite or nurb spline,
|
||||
// check offset point and whether an element id has been selected
|
||||
if (null == elementIdComboBox.SelectedValue)
|
||||
{
|
||||
// Because this is a combobox, only when no element id to be selected,
|
||||
// the SelectedValue property is null. So give information as following
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Can't create line, please draw a same line first.");
|
||||
return false;
|
||||
}
|
||||
return (offsetPointUserControl.AssertPointIntegrity());
|
||||
|
||||
default:
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Invalid create type has been found.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the curve type for creation from the UI
|
||||
/// </summary>
|
||||
/// <returns>the curve type enum selected by the user</returns>
|
||||
LineType GetCurveType()
|
||||
{
|
||||
if (lineRadioButton.Checked) // the user check lineRadioButton
|
||||
{
|
||||
return LineType.ModelLine;
|
||||
}
|
||||
else if (arcRadioButton.Checked)// the user check lineRadioButton
|
||||
{
|
||||
return LineType.ModelArc;
|
||||
}
|
||||
else if (ellipseRadioButton.Checked)// the user check ellipseRadioButton
|
||||
{
|
||||
return LineType.ModelEllipse;
|
||||
}
|
||||
else if (hermiteSplineRadioButton.Checked) // the user check hermiteSplineRadioButton
|
||||
{
|
||||
return LineType.ModelHermiteSpline;
|
||||
}
|
||||
else // the user check nurbSplineRadioButton
|
||||
{
|
||||
return LineType.ModelNurbSpline;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bind the data source of the ComboBox
|
||||
/// </summary>
|
||||
/// <param name="control">the object of the ComboBox</param>
|
||||
/// <param name="dataSource">the data source object</param>
|
||||
void BindComboBox(ComboBox control, Object dataSource)
|
||||
{
|
||||
control.DataSource = null; // clear the DataSource first
|
||||
control.DataSource = dataSource; // rebind data source
|
||||
control.DisplayMember = "DisplayText"; // reset the DisplayMember
|
||||
control.ValueMember = "Id"; // reset the ValueMember
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Rebind the data source of the elementIdComboBox control according to the line type
|
||||
/// </summary>
|
||||
/// <param name="type">indicate which type element(line)</param>
|
||||
void ReBindElementIdComboBox(LineType type)
|
||||
{
|
||||
// Store the selected index property
|
||||
int selectedIndex = elementIdComboBox.SelectedIndex;
|
||||
switch (type)
|
||||
{
|
||||
case LineType.ModelEllipse: // if it is model ellipse
|
||||
BindComboBox(elementIdComboBox, m_dataBuffer.EllispeIDArray);
|
||||
break;
|
||||
case LineType.ModelHermiteSpline: // if it is model hermite spline
|
||||
BindComboBox(elementIdComboBox, m_dataBuffer.HermiteSplineIDArray);
|
||||
break;
|
||||
case LineType.ModelNurbSpline: // if it is model nurb spline
|
||||
BindComboBox(elementIdComboBox, m_dataBuffer.NurbSplineIDArray);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset the selected index property
|
||||
elementIdComboBox.SelectedIndex = selectedIndex;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region UI Event
|
||||
|
||||
/// <summary>
|
||||
/// When the user click the create button, invoke method to create ReferencePlane
|
||||
/// </summary>
|
||||
void createButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Define some local data
|
||||
Autodesk.Revit.DB.XYZ firstPoint; // Store the data of first point for line or arc
|
||||
Autodesk.Revit.DB.XYZ secondPoint; // Store the data of second point for line or arc
|
||||
Autodesk.Revit.DB.XYZ thirdPoint; // Store the data of third point only for arc
|
||||
Autodesk.Revit.DB.XYZ offsetPoint; // Store the data of offset point for other lines
|
||||
int modelLineId; // Store the selected element id using in creation
|
||||
int sketchPlaneId; // Store the selected sketch id using in creation
|
||||
|
||||
// First, get the create curve type.
|
||||
LineType createType = GetCurveType();
|
||||
|
||||
// Second, check data integrity
|
||||
if (!AssertDataIntegrity(createType)) // Check whether the data are integrity
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please make the data integrated first.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Third, get the data from UI and then invoke method to create.
|
||||
try
|
||||
{
|
||||
// Get the sketch plane id from the combobox control
|
||||
sketchPlaneId = (int)sketchPlaneComboBox.SelectedValue;
|
||||
|
||||
// get other necessary information to create model lines
|
||||
switch (createType)
|
||||
{
|
||||
case LineType.ModelArc:
|
||||
firstPoint = firstPointUserControl.GetPointData(); // first point
|
||||
secondPoint = secondPointUserControl.GetPointData();// second point
|
||||
thirdPoint = thirdPointUserControl.GetPointData(); // third point
|
||||
// Invoke the CreateArc method to create a model arc
|
||||
m_dataBuffer.CreateArc(sketchPlaneId, firstPoint, secondPoint, thirdPoint);
|
||||
break;
|
||||
case LineType.ModelLine:
|
||||
firstPoint = firstPointUserControl.GetPointData(); // first point
|
||||
secondPoint = secondPointUserControl.GetPointData();// second point
|
||||
// Invoke the CreateLine method to create a model line
|
||||
m_dataBuffer.CreateLine(sketchPlaneId, firstPoint, secondPoint);
|
||||
break;
|
||||
case LineType.ModelEllipse: // to create model ellipse
|
||||
case LineType.ModelHermiteSpline: // to create model hermite spline
|
||||
case LineType.ModelNurbSpline: // to create model nurb spline
|
||||
// Get the selected element id which copy curve from
|
||||
modelLineId = (int)elementIdComboBox.SelectedValue;
|
||||
offsetPoint = offsetPointUserControl.GetPointData();// offset point
|
||||
m_dataBuffer.CreateOthers(sketchPlaneId, modelLineId, offsetPoint);
|
||||
// Rebind the data source of the elementIdComboBox to refresh it
|
||||
ReBindElementIdComboBox(createType);
|
||||
break;
|
||||
default: // the route should never arrive
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Invalid create type has been found.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// If some error occur during the creation, just show it
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", ex.Message);
|
||||
}
|
||||
|
||||
// Refresh the form display.
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the user click the close button, just close the form
|
||||
/// </summary>
|
||||
private void closeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the lineRadioButton checked state changed, this method is called
|
||||
/// If it is checked, make lineArcPanel visible and disable third point
|
||||
/// </summary>
|
||||
private void lineRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (false == lineRadioButton.Checked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the prompt information
|
||||
lineArcInfoLabel.Text = "New line need information:";
|
||||
|
||||
// Disable the input TextBox for third point
|
||||
thirdPointUserControl.Enabled = false;
|
||||
|
||||
// Change the panel visible property
|
||||
lineArcPanel.Visible = true; // make the lineArcPanel visible
|
||||
otherPanel.Visible = false; // make the otherPanel not visible
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the arcRadioButton checked state changed, this method is called
|
||||
/// If it is checked, make lineArcPanel visible and able third point
|
||||
/// </summary>
|
||||
private void arcRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (false == arcRadioButton.Checked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the prompt information
|
||||
lineArcInfoLabel.Text = "New arc need information:";
|
||||
|
||||
// Enable the input TextBox for third point
|
||||
thirdPointUserControl.Enabled = true;
|
||||
|
||||
// Change the panel visible property
|
||||
lineArcPanel.Visible = true; // make the lineArcPanel visible
|
||||
otherPanel.Visible = false; // make the otherPanel not visible
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the ellipseRadioButton checked state changed, this method is called
|
||||
/// If it is checked, make otherPanel visible and reset the elementIdComboBox
|
||||
/// </summary>
|
||||
private void ellipseRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (false == ellipseRadioButton.Checked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the prompt information
|
||||
otherInfoLabel.Text = "New ellipse need information:";
|
||||
|
||||
// Bing the elementIdComboBox DataSource to EllispeIDArray
|
||||
BindComboBox(elementIdComboBox, m_dataBuffer.EllispeIDArray);
|
||||
|
||||
// Change the panel visible property
|
||||
otherPanel.Visible = true; // make the otherPanel visible
|
||||
lineArcPanel.Visible = false; // make the lineArcPanel not visible
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the hermiteSplineRadioButton checked state changed, this method is called
|
||||
/// If it is checked, make otherPanel visible and reset the elementIdComboBox
|
||||
/// </summary>
|
||||
private void hermiteSplineRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (false == hermiteSplineRadioButton.Checked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the prompt information
|
||||
otherInfoLabel.Text = "New hermite spline need information:";
|
||||
|
||||
// Bing the elementIdComboBox DataSource to HermiteSplineIDArray
|
||||
BindComboBox(elementIdComboBox, m_dataBuffer.HermiteSplineIDArray);
|
||||
|
||||
// Change the panel visible property
|
||||
lineArcPanel.Visible = false; // make the lineArcPanel not visible
|
||||
otherPanel.Visible = true; // make the otherPanel visible
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the NurbSplineRadioButton checked state changed, this method is called
|
||||
/// If it is checked, make otherPanel visible and reset the elementIdComboBox
|
||||
/// </summary>
|
||||
private void NurbSplineRadioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (false == NurbSplineRadioButton.Checked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the prompt information
|
||||
otherInfoLabel.Text = "New nurb spline need information:";
|
||||
|
||||
// Bing the elementIdComboBox DataSource to NurbSplineIDArray
|
||||
BindComboBox(elementIdComboBox, m_dataBuffer.NurbSplineIDArray);
|
||||
|
||||
// Change the panel visible property
|
||||
lineArcPanel.Visible = false; // make the lineArcPanel not visible
|
||||
otherPanel.Visible = true; // make the otherPanel visible
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When click the createSketchPlaneButton, create a new sketch plane in revit
|
||||
/// </summary>
|
||||
private void createSketchPlaneButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Display a form to collect some necessary data
|
||||
using (SketchPlaneForm displayForm = new SketchPlaneForm(m_dataBuffer))
|
||||
{
|
||||
displayForm.ShowDialog();
|
||||
}
|
||||
|
||||
// Rebind the data source of the sketchPlaneComboBox to refresh data
|
||||
BindComboBox(sketchPlaneComboBox, m_dataBuffer.SketchPlaneIDArray);
|
||||
// Set the selected Item to be the new created one
|
||||
sketchPlaneComboBox.SelectedIndex = sketchPlaneComboBox.Items.Count - 1;
|
||||
|
||||
// Refresh the form display.
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?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>
|
||||
<metadata name="typeColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="numberColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
namespace Revit.SDK.Samples.ModelLines.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Stand for the point data of this user control
|
||||
/// </summary>
|
||||
partial class PointUserControl
|
||||
{
|
||||
/// <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 Component 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.secondBracketLabel = new System.Windows.Forms.Label();
|
||||
this.secondCommaLabel = new System.Windows.Forms.Label();
|
||||
this.firstCommaLabel = new System.Windows.Forms.Label();
|
||||
this.zCoordinateTextBox = new System.Windows.Forms.TextBox();
|
||||
this.yCoordinateTextBox = new System.Windows.Forms.TextBox();
|
||||
this.xCoordinateTextBox = new System.Windows.Forms.TextBox();
|
||||
this.firstBracketLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// secondBracketLabel
|
||||
//
|
||||
this.secondBracketLabel.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
|
||||
this.secondBracketLabel.AutoSize = true;
|
||||
this.secondBracketLabel.Location = new System.Drawing.Point(203, 4);
|
||||
this.secondBracketLabel.Name = "secondBracketLabel";
|
||||
this.secondBracketLabel.Size = new System.Drawing.Size(10, 13);
|
||||
this.secondBracketLabel.TabIndex = 7;
|
||||
this.secondBracketLabel.Text = ")";
|
||||
//
|
||||
// secondCommaLabel
|
||||
//
|
||||
this.secondCommaLabel.AutoSize = true;
|
||||
this.secondCommaLabel.Location = new System.Drawing.Point(134, 7);
|
||||
this.secondCommaLabel.Name = "secondCommaLabel";
|
||||
this.secondCommaLabel.Size = new System.Drawing.Size(10, 13);
|
||||
this.secondCommaLabel.TabIndex = 5;
|
||||
this.secondCommaLabel.Text = ",";
|
||||
//
|
||||
// firstCommaLabel
|
||||
//
|
||||
this.firstCommaLabel.AutoSize = true;
|
||||
this.firstCommaLabel.Location = new System.Drawing.Point(66, 8);
|
||||
this.firstCommaLabel.Name = "firstCommaLabel";
|
||||
this.firstCommaLabel.Size = new System.Drawing.Size(10, 13);
|
||||
this.firstCommaLabel.TabIndex = 3;
|
||||
this.firstCommaLabel.Text = ",";
|
||||
//
|
||||
// zCoordinateTextBox
|
||||
//
|
||||
this.zCoordinateTextBox.Location = new System.Drawing.Point(152, 1);
|
||||
this.zCoordinateTextBox.Name = "zCoordinateTextBox";
|
||||
this.zCoordinateTextBox.Size = new System.Drawing.Size(45, 20);
|
||||
this.zCoordinateTextBox.TabIndex = 6;
|
||||
this.zCoordinateTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.CoordinateTextBox_Validating);
|
||||
//
|
||||
// yCoordinateTextBox
|
||||
//
|
||||
this.yCoordinateTextBox.Location = new System.Drawing.Point(84, 1);
|
||||
this.yCoordinateTextBox.Name = "yCoordinateTextBox";
|
||||
this.yCoordinateTextBox.Size = new System.Drawing.Size(45, 20);
|
||||
this.yCoordinateTextBox.TabIndex = 4;
|
||||
this.yCoordinateTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.CoordinateTextBox_Validating);
|
||||
//
|
||||
// xCoordinateTextBox
|
||||
//
|
||||
this.xCoordinateTextBox.Location = new System.Drawing.Point(17, 1);
|
||||
this.xCoordinateTextBox.Name = "xCoordinateTextBox";
|
||||
this.xCoordinateTextBox.Size = new System.Drawing.Size(45, 20);
|
||||
this.xCoordinateTextBox.TabIndex = 2;
|
||||
this.xCoordinateTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.CoordinateTextBox_Validating);
|
||||
//
|
||||
// firstBracketLabel
|
||||
//
|
||||
this.firstBracketLabel.AutoSize = true;
|
||||
this.firstBracketLabel.Location = new System.Drawing.Point(-1, 2);
|
||||
this.firstBracketLabel.Name = "firstBracketLabel";
|
||||
this.firstBracketLabel.Size = new System.Drawing.Size(10, 13);
|
||||
this.firstBracketLabel.TabIndex = 1;
|
||||
this.firstBracketLabel.Text = "(";
|
||||
//
|
||||
// PointUserControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.secondBracketLabel);
|
||||
this.Controls.Add(this.secondCommaLabel);
|
||||
this.Controls.Add(this.firstCommaLabel);
|
||||
this.Controls.Add(this.zCoordinateTextBox);
|
||||
this.Controls.Add(this.yCoordinateTextBox);
|
||||
this.Controls.Add(this.xCoordinateTextBox);
|
||||
this.Controls.Add(this.firstBracketLabel);
|
||||
this.Name = "PointUserControl";
|
||||
this.Size = new System.Drawing.Size(213, 24);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label secondBracketLabel;
|
||||
private System.Windows.Forms.Label secondCommaLabel;
|
||||
private System.Windows.Forms.Label firstCommaLabel;
|
||||
private System.Windows.Forms.TextBox zCoordinateTextBox;
|
||||
private System.Windows.Forms.TextBox yCoordinateTextBox;
|
||||
private System.Windows.Forms.TextBox xCoordinateTextBox;
|
||||
private System.Windows.Forms.Label firstBracketLabel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.ModelLines.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Stand for the point data of this user control
|
||||
/// </summary>
|
||||
public partial class PointUserControl : UserControl
|
||||
{
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor of ModelLinesForm
|
||||
/// </summary>
|
||||
public PointUserControl()
|
||||
{
|
||||
// Required for Windows Form Designer support
|
||||
InitializeComponent();
|
||||
|
||||
// initialize the TextBox data
|
||||
xCoordinateTextBox.Text = "0";
|
||||
yCoordinateTextBox.Text = "0";
|
||||
zCoordinateTextBox.Text = "0";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Get the point data of this user control
|
||||
/// </summary>
|
||||
/// <returns>the point data stored in this control</returns>
|
||||
public Autodesk.Revit.DB.XYZ GetPointData()
|
||||
{
|
||||
double x = 0; // Store the temporary x coordinate
|
||||
double y = 0; // Store the temporary y coordinate
|
||||
double z = 0; // Store the temporary z coordinate
|
||||
x = Convert.ToDouble(xCoordinateTextBox.Text); // Get x coordinate
|
||||
y = Convert.ToDouble(yCoordinateTextBox.Text); // Get x coordinate
|
||||
z = Convert.ToDouble(zCoordinateTextBox.Text); // Get x coordinate
|
||||
return new Autodesk.Revit.DB.XYZ(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Check the point data which the user input are integrated or not
|
||||
/// </summary>
|
||||
/// <returns>If the data are integrated return true, otherwise false</returns>
|
||||
public bool AssertPointIntegrity()
|
||||
{
|
||||
if (String.IsNullOrEmpty(xCoordinateTextBox.Text) // x coordinate empty
|
||||
|| String.IsNullOrEmpty(yCoordinateTextBox.Text) // y coordinate empty
|
||||
|| String.IsNullOrEmpty(zCoordinateTextBox.Text)) // z coordinate empty
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If all coordinates are not empty, return true
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
/// <summary>
|
||||
/// This method is called to Validate whether the TextBox data is a number.
|
||||
/// </summary>
|
||||
/// <param name="sender">the event sender(can be all TextBox)</param>
|
||||
/// <param name="e">contain event data(not used)</param>
|
||||
void CoordinateTextBox_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
// Check whether the sender is a TextBox reference
|
||||
TextBox numberTextBox = sender as TextBox;
|
||||
if (null == numberTextBox)
|
||||
{
|
||||
// If it is not a TextBox, just return
|
||||
return;
|
||||
}
|
||||
|
||||
// Invoke IsNumber() method to judge whether the input data are right
|
||||
if (!IsNumber(numberTextBox.Text))
|
||||
{
|
||||
// If not, give error information, and set the text to be empty
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Please input a double data.");
|
||||
//numberTextBox.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the string data can represent a double number
|
||||
/// </summary>
|
||||
/// <param name="number">The test string</param>
|
||||
/// <returns>If the string can represent a number return true, otherwise false</returns>
|
||||
bool IsNumber(String number)
|
||||
{
|
||||
// First check whether the string is empty
|
||||
if (String.IsNullOrEmpty(number))
|
||||
{
|
||||
// If the string is empty, return true
|
||||
return true;
|
||||
}
|
||||
|
||||
// Use Convert.ToDouble() method to changed string to double,
|
||||
// If an exception is thrown out, that means the string can't change
|
||||
try
|
||||
{
|
||||
// Invoke Convert.ToDouble() method
|
||||
Convert.ToDouble(number);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If everything goes well, return true
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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,58 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ModelLines")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ModelLines")]
|
||||
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2009")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("6e10ef7c-9517-46b0-a109-3bb47fc67fc3")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Binary file not shown.
+165
@@ -0,0 +1,165 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
namespace Revit.SDK.Samples.ModelLines.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This UserControl is used to collect the information for sketch plane creation
|
||||
/// </summary>
|
||||
partial class SketchPlaneForm
|
||||
{
|
||||
/// <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.normalUserControl = new Revit.SDK.Samples.ModelLines.CS.PointUserControl();
|
||||
this.normalLabel = new System.Windows.Forms.Label();
|
||||
this.originLabel = new System.Windows.Forms.Label();
|
||||
this.originUserControl = new Revit.SDK.Samples.ModelLines.CS.PointUserControl();
|
||||
this.creationGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.creationGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// normalUserControl
|
||||
//
|
||||
this.normalUserControl.Location = new System.Drawing.Point(86, 19);
|
||||
this.normalUserControl.Name = "normalUserControl";
|
||||
this.normalUserControl.Size = new System.Drawing.Size(213, 25);
|
||||
this.normalUserControl.TabIndex = 1;
|
||||
//
|
||||
// normalLabel
|
||||
//
|
||||
this.normalLabel.AutoSize = true;
|
||||
this.normalLabel.Location = new System.Drawing.Point(10, 23);
|
||||
this.normalLabel.Name = "normalLabel";
|
||||
this.normalLabel.Size = new System.Drawing.Size(73, 13);
|
||||
this.normalLabel.TabIndex = 5;
|
||||
this.normalLabel.Text = "Plane Normal:";
|
||||
//
|
||||
// originLabel
|
||||
//
|
||||
this.originLabel.AutoSize = true;
|
||||
this.originLabel.Location = new System.Drawing.Point(11, 55);
|
||||
this.originLabel.Name = "originLabel";
|
||||
this.originLabel.Size = new System.Drawing.Size(67, 13);
|
||||
this.originLabel.TabIndex = 6;
|
||||
this.originLabel.Text = "Plane Origin:";
|
||||
//
|
||||
// originUserControl
|
||||
//
|
||||
this.originUserControl.Location = new System.Drawing.Point(86, 53);
|
||||
this.originUserControl.Name = "originUserControl";
|
||||
this.originUserControl.Size = new System.Drawing.Size(213, 25);
|
||||
this.originUserControl.TabIndex = 2;
|
||||
//
|
||||
// creationGroupBox
|
||||
//
|
||||
this.creationGroupBox.Controls.Add(this.normalUserControl);
|
||||
this.creationGroupBox.Controls.Add(this.originUserControl);
|
||||
this.creationGroupBox.Controls.Add(this.normalLabel);
|
||||
this.creationGroupBox.Controls.Add(this.originLabel);
|
||||
this.creationGroupBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.creationGroupBox.Name = "creationGroupBox";
|
||||
this.creationGroupBox.Size = new System.Drawing.Size(305, 84);
|
||||
this.creationGroupBox.TabIndex = 8;
|
||||
this.creationGroupBox.TabStop = false;
|
||||
this.creationGroupBox.Text = "Sketch Plane Creation";
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(161, 102);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 3;
|
||||
this.okButton.Text = "&Ok";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(242, 102);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cancelButton.TabIndex = 4;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// SketchPlaneForm
|
||||
//
|
||||
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(329, 131);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.creationGroupBox);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "SketchPlaneForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Sketch Plane";
|
||||
this.creationGroupBox.ResumeLayout(false);
|
||||
this.creationGroupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Revit.SDK.Samples.ModelLines.CS.PointUserControl normalUserControl;
|
||||
private System.Windows.Forms.Label normalLabel;
|
||||
private System.Windows.Forms.Label originLabel;
|
||||
private Revit.SDK.Samples.ModelLines.CS.PointUserControl originUserControl;
|
||||
private System.Windows.Forms.GroupBox creationGroupBox;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.ModelLines.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This UserControl is used to collect the information for sketch plane creation
|
||||
/// </summary>
|
||||
public partial class SketchPlaneForm : System.Windows.Forms.Form
|
||||
{
|
||||
// Private members
|
||||
ModelLines m_dataBuffer; // A reference of ModelLines.
|
||||
|
||||
/// <summary>
|
||||
/// Constructor of SketchPlaneForm
|
||||
/// </summary>
|
||||
/// <param name="dataBuffer">a reference of ModelLines class</param>
|
||||
public SketchPlaneForm(ModelLines dataBuffer)
|
||||
{
|
||||
// Required for Windows Form Designer support
|
||||
InitializeComponent();
|
||||
|
||||
//Get a reference of ModelLines
|
||||
m_dataBuffer = dataBuffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check the data which the user input are integrated or not
|
||||
/// </summary>
|
||||
/// <returns>If the data are integrated return true, otherwise false</returns>
|
||||
bool AssertDataIntegrity()
|
||||
{
|
||||
return (normalUserControl.AssertPointIntegrity()
|
||||
&& originUserControl.AssertPointIntegrity());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The event method for okButton click
|
||||
/// </summary>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// First, check data integrity
|
||||
if (!AssertDataIntegrity())
|
||||
{
|
||||
TaskDialog.Show("Revit", "Please make the data integrated first.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Get the necessary information and invoke the method to create sketch plane
|
||||
Autodesk.Revit.DB.XYZ normal = normalUserControl.GetPointData();
|
||||
Autodesk.Revit.DB.XYZ origin = originUserControl.GetPointData();
|
||||
m_dataBuffer.CreateSketchPlane(normal, origin);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskDialog.Show("Revit", ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the creation is successful, close this form
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The event method for cancelButton click
|
||||
/// </summary>
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user