mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-09 13:22:20 +00:00
added Revit 2020 SDK files
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
//
|
||||
// (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;
|
||||
using System.Drawing;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.NewPathReinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The entrance of this example, implement the Execute method of IExternalCommand
|
||||
/// </summary>
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
|
||||
public class Command : IExternalCommand
|
||||
{
|
||||
#region IExternalCommand Members Implementation
|
||||
///<summary>
|
||||
/// Implement this method as an external command for Revit.
|
||||
/// </summary>
|
||||
/// <param name="commandData">An object that is passed to the external application
|
||||
/// which contains data related to the command,
|
||||
/// such as the application object and active view.</param>
|
||||
/// <param name="message">A message that can be set by the external application
|
||||
/// which will be displayed if a failure or cancellation is returned by
|
||||
/// the external command.</param>
|
||||
/// <param name="elements">A set of elements to which the external application
|
||||
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
/// <returns>Return the status of the external command.
|
||||
/// A result of Succeeded means that the API external method functioned as expected.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation
|
||||
/// at some point. Failure should be returned if the application is unable to proceed with
|
||||
/// the operation.</returns>
|
||||
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
|
||||
ref string message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
try
|
||||
{
|
||||
Wall wall = null;
|
||||
Floor floor = null;
|
||||
|
||||
ElementSet elems = new ElementSet();
|
||||
foreach (ElementId elementId in commandData.Application.ActiveUIDocument.Selection.GetElementIds())
|
||||
{
|
||||
elems.Insert(commandData.Application.ActiveUIDocument.Document.GetElement(elementId));
|
||||
}
|
||||
#region selection handle -- select one Slab (or Structure Wall)
|
||||
//if user had some wrong selection, give user an Error message
|
||||
string errorMessage =
|
||||
"Please select one Slab (or Structure Wall) to create PathReinforcement.";
|
||||
if (1 != elems.Size)
|
||||
{
|
||||
message = errorMessage;
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
|
||||
Autodesk.Revit.DB.Element selectElem = null;
|
||||
IEnumerator iter = elems.GetEnumerator();
|
||||
iter.Reset();
|
||||
if (iter.MoveNext())
|
||||
{
|
||||
selectElem = (Autodesk.Revit.DB.Element)iter.Current;
|
||||
}
|
||||
|
||||
if (selectElem is Wall)
|
||||
{
|
||||
wall = selectElem as Wall;
|
||||
if (null == wall.GetAnalyticalModel())
|
||||
{
|
||||
message = errorMessage;
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
}
|
||||
else if (selectElem is Floor)
|
||||
{
|
||||
floor = selectElem as Floor;
|
||||
if (null == floor.GetAnalyticalModel())
|
||||
{
|
||||
message = errorMessage;
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message = errorMessage;
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
#endregion
|
||||
try
|
||||
{
|
||||
if (null != wall)
|
||||
{
|
||||
ProfileWall profileWall = new ProfileWall(wall, commandData);
|
||||
NewPathReinforcementForm newPathReinforcementForm =
|
||||
new NewPathReinforcementForm(profileWall);
|
||||
newPathReinforcementForm.ShowDialog();
|
||||
}
|
||||
else if (null != floor)
|
||||
{
|
||||
ProfileFloor profileFloor = new ProfileFloor(floor, commandData);
|
||||
NewPathReinforcementForm newPathReinforcementForm =
|
||||
new NewPathReinforcementForm(profileFloor);
|
||||
newPathReinforcementForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
message = e.Message;
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Revit.SDK.Samples.NewPathReinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// tool used to draw line
|
||||
/// </summary>
|
||||
public class LineTool
|
||||
{
|
||||
# region members
|
||||
private List<Point> m_points = new List<Point>(); // Field used to store points of a line
|
||||
private Pen m_backGroundPen; // background pen used to Erase the preview line
|
||||
private Pen m_foreGroundPen; // foreground pen used to draw lines
|
||||
private Point m_preMovePoint; // store the mouse position when mouse move in pictureBox
|
||||
private bool m_finished; // indicate whether user have finished drawing
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Finished property to define whether curve was finished
|
||||
/// </summary>
|
||||
public bool Finished
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_finished;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_finished = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PointsNumber property to get the number of points stored
|
||||
/// </summary>
|
||||
public int PointsNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_points.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// default constructor
|
||||
/// </summary>
|
||||
public LineTool()
|
||||
{
|
||||
m_backGroundPen = new Pen(System.Drawing.Color.White);
|
||||
m_backGroundPen.Width *= 2;
|
||||
m_foreGroundPen = new Pen(System.Drawing.Color.Black);
|
||||
m_foreGroundPen.Width *= 2;
|
||||
m_finished = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get all lines drawn in pictureBox
|
||||
/// </summary>
|
||||
public List<Point> GetPoints()
|
||||
{
|
||||
return m_points;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// clear all the points in the tool
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
m_points.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw a line from end point of tool to the location where mouse move
|
||||
/// </summary>
|
||||
/// <param name="graphic">graphic object, used to draw geometry</param>
|
||||
/// <param name="e">mouse event args</param>
|
||||
public void OnMouseMove(System.Drawing.Graphics graphic, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if(m_points.Count != 0 && !m_finished)
|
||||
{
|
||||
graphic.DrawLine(m_backGroundPen, m_points[m_points.Count - 1], m_preMovePoint);
|
||||
m_preMovePoint = e.Location;
|
||||
graphic.DrawLine(m_foreGroundPen, m_points[m_points.Count - 1], e.Location);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// restore the location point where mouse click
|
||||
/// </summary>
|
||||
/// <param name="e">mouse event args</param>
|
||||
public void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
//when user click right button of mouse, then erase last line
|
||||
if (MouseButtons.Right == e.Button && m_points.Count >= 2)
|
||||
{
|
||||
m_finished = true;
|
||||
}
|
||||
|
||||
if (MouseButtons.Left == e.Button && !m_finished)
|
||||
{
|
||||
m_preMovePoint = e.Location;
|
||||
m_points.Add(e.Location);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw lines stored in the tool
|
||||
/// </summary>
|
||||
/// <param name="graphic">Graphics object, use to draw geometry</param>
|
||||
public void Draw(Graphics graphic)
|
||||
{
|
||||
for (int i = 0; i < m_points.Count - 1; i++)
|
||||
{
|
||||
graphic.DrawLine(m_foreGroundPen, m_points[i], m_points[i + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,460 @@
|
||||
//
|
||||
// (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.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.NewPathReinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Vector4 class use to store vector
|
||||
/// and contain method to handle the vector
|
||||
/// </summary>
|
||||
public class Vector4
|
||||
{
|
||||
#region Class member variables and properties
|
||||
private float m_x;
|
||||
private float m_y;
|
||||
private float m_z;
|
||||
private float m_w = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// X property to get/set x value of Vector4
|
||||
/// </summary>
|
||||
public float X
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_x;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_x = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Y property to get/set y value of Vector4
|
||||
/// </summary>
|
||||
public float Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_y;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_y = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Z property to get/set z value of Vector4
|
||||
/// </summary>
|
||||
public float Z
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_z;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_z = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// W property to get/set fourth value of Vector4
|
||||
/// </summary>
|
||||
public float W
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_w;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_w = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
public Vector4(float x, float y, float z)
|
||||
{
|
||||
this.X = x; this.Y = y; this.Z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor, transfer Autodesk.Revit.DB.XYZ to vector
|
||||
/// </summary>
|
||||
/// <param name="v">Autodesk.Revit.DB.XYZ structure which need to be transferred</param>
|
||||
public Vector4(Autodesk.Revit.DB.XYZ v)
|
||||
{
|
||||
this.X = (float)v.X; this.Y = (float)v.Y; this.Z = (float)v.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// adds two vectors
|
||||
/// </summary>
|
||||
/// <param name="va">first vector</param>
|
||||
/// <param name="vb">second vector</param>
|
||||
public static Vector4 operator+ (Vector4 va, Vector4 vb)
|
||||
{
|
||||
return new Vector4(va.X + vb.X, va.Y + vb.Y, va.Z + vb.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// subtracts two vectors
|
||||
/// </summary>
|
||||
/// <param name="va">first vector</param>
|
||||
/// <param name="vb">second vector</param>
|
||||
/// <returns>subtraction of two vector</returns>
|
||||
public static Vector4 operator- (Vector4 va, Vector4 vb)
|
||||
{
|
||||
return new Vector4(va.X - vb.X, va.Y - vb.Y, va.Z - vb.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// multiplies a vector by a floating type value
|
||||
/// </summary>
|
||||
/// <param name="v">vector</param>
|
||||
/// <param name="factor">multiplier of floating type</param>
|
||||
/// <returns> the result vector </returns>
|
||||
public static Vector4 operator* (Vector4 v,float factor)
|
||||
{
|
||||
return new Vector4(v.X * factor, v.Y * factor, v.Z * factor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// divides vector by an floating type value
|
||||
/// </summary>
|
||||
/// <param name="v">vector</param>
|
||||
/// <param name="factor">floating type value</param>
|
||||
/// <returns> vector divided by a floating type value </returns>
|
||||
public static Vector4 operator /(Vector4 v, float factor)
|
||||
{
|
||||
return new Vector4(v.X / factor, v.Y / factor, v.Z / factor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dot multiply vector
|
||||
/// </summary>
|
||||
/// <param name="v"> the result vector </param>
|
||||
public float DotProduct(Vector4 v)
|
||||
{
|
||||
return (this.X * v.X + this.Y * v.Y + this.Z * v.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get normal vector of two vectors
|
||||
/// </summary>
|
||||
/// <param name="v">second vector</param>
|
||||
/// <returns> normal vector of two vectors</returns>
|
||||
public Vector4 CrossProduct(Vector4 v)
|
||||
{
|
||||
return new Vector4(this.Y * v.Z - this.Z * v.Y,this.Z * v.X
|
||||
- this.X * v.Z,this.X * v.Y - this.Y * v.X);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dot multiply two vectors
|
||||
/// </summary>
|
||||
/// <param name="va">first vector</param>
|
||||
/// <param name="vb">second vector</param>
|
||||
public static float DotProduct(Vector4 va, Vector4 vb)
|
||||
{
|
||||
return (va.X * vb.X + va.Y * vb.Y + va.Z * vb.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get normal vector of two vectors
|
||||
/// </summary>
|
||||
/// <param name="va">first vector</param>
|
||||
/// <param name="vb">second vector</param>
|
||||
/// <returns> normal vector of two vectors </returns>
|
||||
public static Vector4 CrossProduct(Vector4 va, Vector4 vb)
|
||||
{
|
||||
return new Vector4(va.Y * vb.Z - va.Z * vb.Y, va.Z * vb.X
|
||||
- va.X * vb.Z, va.X * vb.Y - va.Y * vb.X);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get unit vector
|
||||
/// </summary>
|
||||
public void Normalize()
|
||||
{
|
||||
float length = Length();
|
||||
if(length == 0)
|
||||
{
|
||||
length = 1;
|
||||
}
|
||||
this.X /= length;
|
||||
this.Y /= length;
|
||||
this.Z /= length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate the length of vector
|
||||
/// </summary>
|
||||
public float Length()
|
||||
{
|
||||
return (float)Math.Sqrt(this.X * this.X + this.Y * this.Y + this.Z * this.Z);
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Matrix used to transform between ucs coordinate and world coordinate.
|
||||
/// </summary>
|
||||
public class Matrix4
|
||||
{
|
||||
#region MatrixType
|
||||
/// <summary>
|
||||
/// Matrix Type Enum use to define function of matrix
|
||||
/// </summary>
|
||||
public enum MatrixType
|
||||
{
|
||||
/// <summary>
|
||||
/// matrix use to rotate
|
||||
/// </summary>
|
||||
Rotation,
|
||||
|
||||
/// <summary>
|
||||
/// matrix used to Translation
|
||||
/// </summary>
|
||||
Translation,
|
||||
|
||||
/// <summary>
|
||||
/// matrix used to Scale
|
||||
/// </summary>
|
||||
Scale,
|
||||
|
||||
/// <summary>
|
||||
/// matrix used to Rotation and Translation
|
||||
/// </summary>
|
||||
RotationAndTranslation,
|
||||
|
||||
/// <summary>
|
||||
/// normal matrix
|
||||
/// </summary>
|
||||
Normal
|
||||
};
|
||||
private float[,] m_matrix = new float[4,4];
|
||||
private MatrixType m_type;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// default ctor
|
||||
/// </summary>
|
||||
public Matrix4()
|
||||
{
|
||||
m_type = MatrixType.Normal;
|
||||
Identity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor,rotation matrix,origin at (0,0,0)
|
||||
/// </summary>
|
||||
/// <param name="xAxis">identity of x axis</param>
|
||||
/// <param name="yAxis">identity of y axis</param>
|
||||
/// <param name="zAxis">identity of z axis</param>
|
||||
public Matrix4(Vector4 xAxis,Vector4 yAxis, Vector4 zAxis)
|
||||
{
|
||||
m_type = MatrixType.Rotation;
|
||||
Identity();
|
||||
m_matrix[0, 0] = xAxis.X; m_matrix[0, 1] = xAxis.Y; m_matrix[0, 2] = xAxis.Z;
|
||||
m_matrix[1, 0] = yAxis.X; m_matrix[1, 1] = yAxis.Y; m_matrix[1, 2] = yAxis.Z;
|
||||
m_matrix[2, 0] = zAxis.X; m_matrix[2, 1] = zAxis.Y; m_matrix[2, 2] = zAxis.Z;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor,translation matrix.
|
||||
/// </summary>
|
||||
/// <param name="origin">origin of ucs in world coordinate</param>
|
||||
public Matrix4(Vector4 origin)
|
||||
{
|
||||
m_type = MatrixType.Translation;
|
||||
Identity();
|
||||
m_matrix[3, 0] = origin.X; m_matrix[3, 1] = origin.Y; m_matrix[3, 2] = origin.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// rotation and translation matrix constructor
|
||||
/// </summary>
|
||||
/// <param name="xAxis">x Axis</param>
|
||||
/// <param name="yAxis">y Axis</param>
|
||||
/// <param name="zAxis">z Axis</param>
|
||||
/// <param name="origin">origin</param>
|
||||
public Matrix4(Vector4 xAxis, Vector4 yAxis, Vector4 zAxis, Vector4 origin)
|
||||
{
|
||||
m_type = MatrixType.RotationAndTranslation;
|
||||
Identity();
|
||||
m_matrix[0, 0] = xAxis.X; m_matrix[0, 1] = xAxis.Y; m_matrix[0, 2] = xAxis.Z;
|
||||
m_matrix[1, 0] = yAxis.X; m_matrix[1, 1] = yAxis.Y; m_matrix[1, 2] = yAxis.Z;
|
||||
m_matrix[2, 0] = zAxis.X; m_matrix[2, 1] = zAxis.Y; m_matrix[2, 2] = zAxis.Z;
|
||||
m_matrix[3, 0] = origin.X; m_matrix[3, 1] = origin.Y; m_matrix[3, 2] = origin.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// scale matrix constructor
|
||||
/// </summary>
|
||||
/// <param name="scale">scale factor</param>
|
||||
public Matrix4(float scale)
|
||||
{
|
||||
m_type = MatrixType.Scale;
|
||||
Identity();
|
||||
m_matrix[0, 0] = m_matrix[1, 1] = m_matrix[2, 2] = scale;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// indexer of matrix
|
||||
/// </summary>
|
||||
/// <param name="row">row number</param>
|
||||
/// <param name="column">column number</param>
|
||||
/// <returns></returns>
|
||||
public float this[int row, int column]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_matrix[row, column];
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_matrix[row, column] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identity matrix
|
||||
/// </summary>
|
||||
public void Identity()
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
this.m_matrix[i, j] = 0.0f;
|
||||
}
|
||||
}
|
||||
this.m_matrix[0, 0] = 1.0f;
|
||||
this.m_matrix[1, 1] = 1.0f;
|
||||
this.m_matrix[2, 2] = 1.0f;
|
||||
this.m_matrix[3, 3] = 1.0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// multiply matrix left and right
|
||||
/// </summary>
|
||||
/// <param name="left">left matrix</param>
|
||||
/// <param name="right">right matrix</param>
|
||||
/// <returns></returns>
|
||||
public static Matrix4 Multiply(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
Matrix4 result = new Matrix4();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
result[i, j] = left[i, 0] * right[0, j] + left[i, 1] * right[1, j]
|
||||
+ left[i, 2] * right[2, j] + left[i, 3] * right[3, j];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// transform point use this matrix
|
||||
/// </summary>
|
||||
/// <param name="point">point needed to be transformed</param>
|
||||
/// <returns>transform result</returns>
|
||||
public Vector4 Transform(Vector4 point)
|
||||
{
|
||||
return new Vector4(point.X * this[0, 0] + point.Y * this[1, 0]
|
||||
+ point.Z * this[2, 0]+ point.W * this[3, 0],
|
||||
point.X * this[0, 1] + point.Y * this[1, 1]
|
||||
+ point.Z * this[2, 1]+ point.W * this[3, 1],
|
||||
point.X * this[0, 2] + point.Y * this[1, 2]
|
||||
+ point.Z * this[2, 2]+ point.W * this[3, 2]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if m_matrix is a rotation matrix,this method can get the rotation inverse matrix.
|
||||
/// </summary>
|
||||
/// <returns>rotation inverse matrix</returns>
|
||||
public Matrix4 RotationInverse()
|
||||
{
|
||||
return new Matrix4(new Vector4(this[0, 0], this[1, 0], this[2, 0]),
|
||||
new Vector4(this[0, 1], this[1, 1], this[2, 1]),
|
||||
new Vector4(this[0, 2], this[1, 2], this[2, 2]));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if this m_matrix is a translation matrix,
|
||||
/// this method can get the translation inverse matrix.
|
||||
/// </summary>
|
||||
/// <returns>translation inverse matrix</returns>
|
||||
public Matrix4 TranslationInverse()
|
||||
{
|
||||
return new Matrix4(new Vector4(-this[3, 0], -this[3, 1], -this[3, 2]));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get inverse matrix
|
||||
/// </summary>
|
||||
/// <returns>inverse matrix</returns>
|
||||
public Matrix4 Inverse()
|
||||
{
|
||||
switch(m_type)
|
||||
{
|
||||
case MatrixType.Rotation:
|
||||
return RotationInverse();
|
||||
|
||||
case MatrixType.Translation:
|
||||
return TranslationInverse();
|
||||
|
||||
case MatrixType.RotationAndTranslation:
|
||||
return Multiply(TranslationInverse(),RotationInverse());
|
||||
|
||||
case MatrixType.Scale:
|
||||
return ScaleInverse();
|
||||
|
||||
case MatrixType.Normal:
|
||||
return new Matrix4();
|
||||
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if m_matrix is a scale matrix,this method can get the scale inverse matrix.
|
||||
/// </summary>
|
||||
/// <returns>scale inverse matrix</returns>
|
||||
public Matrix4 ScaleInverse()
|
||||
{
|
||||
return new Matrix4(1 / m_matrix[0,0]);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>NewPathReinforcement.dll</Assembly>
|
||||
<ClientId>17cac1c5-88be-40d8-ab03-a2b574e53cde</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.NewPathReinforcement.CS.Command</FullClassName>
|
||||
<Text>NewPathReinforcement</Text>
|
||||
<Description>Create PathReinforcement on wall or slab.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,102 @@
|
||||
<?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>{6EEC8736-C09A-4154-8070-5075CBCE42E2}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NewPathReinforcement</RootNamespace>
|
||||
<AssemblyName>NewPathReinforcement</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="LineTool.cs" />
|
||||
<Compile Include="MathTools.cs" />
|
||||
<Compile Include="NewPathReinforcementForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NewPathReinforcementForm.Designer.cs">
|
||||
<DependentUpon>NewPathReinforcementForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Profile.cs" />
|
||||
<Compile Include="ProfileFloor.cs" />
|
||||
<Compile Include="ProfileWall.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="NewPathReinforcementForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>NewPathReinforcementForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
|
||||
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,177 @@
|
||||
//
|
||||
// (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.NewPathReinforcement.CS
|
||||
{
|
||||
partial class NewPathReinforcementForm
|
||||
{
|
||||
/// <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.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.createButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.flipCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.labelNote = new System.Windows.Forms.Label();
|
||||
this.previewButton = new System.Windows.Forms.Button();
|
||||
this.cleanButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBox.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.pictureBox.Location = new System.Drawing.Point(14, 12);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(446, 314);
|
||||
this.pictureBox.TabIndex = 0;
|
||||
this.pictureBox.TabStop = false;
|
||||
this.pictureBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PictureBox_MouseDown);
|
||||
this.pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.PictureBox_MouseMove);
|
||||
this.pictureBox.Paint += new System.Windows.Forms.PaintEventHandler(this.PictureBox_Paint);
|
||||
//
|
||||
// createButton
|
||||
//
|
||||
this.createButton.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.createButton.Location = new System.Drawing.Point(279, 403);
|
||||
this.createButton.Name = "createButton";
|
||||
this.createButton.Size = new System.Drawing.Size(87, 23);
|
||||
this.createButton.TabIndex = 1;
|
||||
this.createButton.Text = "C&reate";
|
||||
this.createButton.UseVisualStyleBackColor = true;
|
||||
this.createButton.Click += new System.EventHandler(this.CreateButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.cancelButton.Location = new System.Drawing.Point(373, 403);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(87, 23);
|
||||
this.cancelButton.TabIndex = 2;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.CancelButton_Click);
|
||||
//
|
||||
// flipCheckBox
|
||||
//
|
||||
this.flipCheckBox.AutoSize = true;
|
||||
this.flipCheckBox.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.flipCheckBox.Location = new System.Drawing.Point(415, 332);
|
||||
this.flipCheckBox.Name = "flipCheckBox";
|
||||
this.flipCheckBox.Size = new System.Drawing.Size(45, 17);
|
||||
this.flipCheckBox.TabIndex = 3;
|
||||
this.flipCheckBox.Text = "Flip";
|
||||
this.flipCheckBox.UseVisualStyleBackColor = true;
|
||||
this.flipCheckBox.CheckedChanged += new System.EventHandler(this.FlipCheckBox_CheckedChanged);
|
||||
//
|
||||
// labelNote
|
||||
//
|
||||
this.labelNote.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.labelNote.Location = new System.Drawing.Point(11, 336);
|
||||
this.labelNote.Name = "labelNote";
|
||||
this.labelNote.Size = new System.Drawing.Size(245, 33);
|
||||
this.labelNote.TabIndex = 4;
|
||||
this.labelNote.Text = "Click mouse left button and drag to draw a curve. Right click to finish drawing.";
|
||||
//
|
||||
// previewButton
|
||||
//
|
||||
this.previewButton.Enabled = false;
|
||||
this.previewButton.Location = new System.Drawing.Point(373, 364);
|
||||
this.previewButton.Name = "previewButton";
|
||||
this.previewButton.Size = new System.Drawing.Size(87, 23);
|
||||
this.previewButton.TabIndex = 5;
|
||||
this.previewButton.Text = "&Preview";
|
||||
this.previewButton.UseVisualStyleBackColor = true;
|
||||
this.previewButton.Click += new System.EventHandler(this.ButtonPreview_Click);
|
||||
//
|
||||
// cleanButton
|
||||
//
|
||||
this.cleanButton.Location = new System.Drawing.Point(279, 364);
|
||||
this.cleanButton.Name = "cleanButton";
|
||||
this.cleanButton.Size = new System.Drawing.Size(87, 23);
|
||||
this.cleanButton.TabIndex = 6;
|
||||
this.cleanButton.Text = "C&lean";
|
||||
this.cleanButton.UseVisualStyleBackColor = true;
|
||||
this.cleanButton.Click += new System.EventHandler(this.ButtonClean_Click);
|
||||
//
|
||||
// NewPathReinforcementForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(472, 438);
|
||||
this.Controls.Add(this.cleanButton);
|
||||
this.Controls.Add(this.previewButton);
|
||||
this.Controls.Add(this.labelNote);
|
||||
this.Controls.Add(this.flipCheckBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.createButton);
|
||||
this.Controls.Add(this.pictureBox);
|
||||
this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "NewPathReinforcementForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "New Path Reinforcement";
|
||||
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.NewPathReinforcementForm_KeyPress);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox pictureBox;
|
||||
private System.Windows.Forms.Button createButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.CheckBox flipCheckBox;
|
||||
private System.Windows.Forms.Label labelNote;
|
||||
private System.Windows.Forms.Button previewButton;
|
||||
private System.Windows.Forms.Button cleanButton;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,394 @@
|
||||
//
|
||||
// (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.DB.Structure;
|
||||
using Point = System.Drawing.Point;
|
||||
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.NewPathReinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// window form contains one picture box to show the
|
||||
/// profile of wall (or slab), and four command buttons and a check box.
|
||||
/// User can draw PathReinforcement on picture box.
|
||||
/// </summary>
|
||||
public partial class NewPathReinforcementForm : System.Windows.Forms.Form
|
||||
{
|
||||
#region class members
|
||||
private Profile m_profile; //save the profile date (ProfileFloor or ProfileWall)
|
||||
private Matrix4 m_to2DMatrix; //save the matrix use to transform 3D to 2D
|
||||
private Matrix4 m_moveToCenterMatrix; //save the matrix use to move point to origin
|
||||
private Matrix4 m_scaleMatrix; //save the matrix use to scale
|
||||
private Matrix4 m_transMatrix; //save the final matrix
|
||||
private LineTool m_tool = null; //current using tool
|
||||
private bool m_previewMode = false; //indicate whether in the Preview Mode
|
||||
private List<List<XYZ>> m_pointsPreview; //store all the points of the preview
|
||||
Size m_sizePictureBox; //size of picture box
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
public NewPathReinforcementForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="profile">ProfileWall or ProfileFloor</param>
|
||||
public NewPathReinforcementForm(Profile profile)
|
||||
: this()
|
||||
{
|
||||
m_profile = profile;
|
||||
m_to2DMatrix = m_profile.To2DMatrix;
|
||||
m_moveToCenterMatrix = m_profile.ToCenterMatrix();
|
||||
m_tool = new LineTool();
|
||||
this.KeyPreview = true; //respond Form events first
|
||||
m_pointsPreview = new List<List<XYZ>>();
|
||||
m_sizePictureBox = this.pictureBox.Size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store mouse location when mouse down
|
||||
/// </summary>
|
||||
/// <param name="sender">object who sent this event</param>
|
||||
/// <param name="e">event args</param>
|
||||
private void PictureBox_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!m_previewMode)
|
||||
{
|
||||
Graphics graphics = this.pictureBox.CreateGraphics();
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
m_tool.OnMouseDown(e);
|
||||
this.pictureBox.Refresh();
|
||||
if (m_tool.PointsNumber >= 2)
|
||||
{
|
||||
this.previewButton.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw the line to where mouse moved
|
||||
/// </summary>
|
||||
/// <param name="sender">object who sent this event</param>
|
||||
/// <param name="e">event args</param>
|
||||
private void PictureBox_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
this.pictureBox.Refresh();
|
||||
Graphics graphics = this.pictureBox.CreateGraphics();
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
m_tool.OnMouseMove(graphics, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw the curve of slab (or wall) and path of PathReinforcement
|
||||
/// </summary>
|
||||
/// <param name="sender">object who sent this event</param>
|
||||
/// <param name="e">event args</param>
|
||||
private void PictureBox_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
if (m_previewMode)
|
||||
{
|
||||
//Draw the geometry of Path Reinforcement
|
||||
DrawPreview(e.Graphics);
|
||||
//move the gdi origin to the picture center
|
||||
e.Graphics.Transform = new
|
||||
System.Drawing.Drawing2D.Matrix(1, 0, 0, 1, 0, 0);
|
||||
m_tool.Draw(e.Graphics);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Draw the pictures in the m_tools list
|
||||
m_tool.Draw(e.Graphics);
|
||||
}
|
||||
|
||||
//move the gdi origin to the picture center
|
||||
e.Graphics.Transform = new System.Drawing.Drawing2D.Matrix(
|
||||
1, 0, 0, 1, m_sizePictureBox.Width / 2, m_sizePictureBox.Height / 2);
|
||||
|
||||
//get matrix
|
||||
Size scaleSize = new Size((int)(0.85 * m_sizePictureBox.Width),
|
||||
(int)(0.85 * m_sizePictureBox.Height));
|
||||
m_scaleMatrix = ComputeScaleMatrix(scaleSize);
|
||||
m_transMatrix = Compute3DTo2DMatrix();
|
||||
|
||||
//draw profile
|
||||
m_profile.Draw2D(e.Graphics, Pens.Blue, m_transMatrix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw all the curves of PathReinforcement when click "Preview" Button
|
||||
/// </summary>
|
||||
/// <param name="sender">object who sent this event</param>
|
||||
/// <param name="e">event args</param>
|
||||
private void ButtonPreview_Click(object sender, EventArgs e)
|
||||
{
|
||||
m_previewMode = true;
|
||||
m_tool.Finished = true;
|
||||
//get points to create PathReinforcement
|
||||
List<Point> points = m_tool.GetPoints();
|
||||
if (points.Count <= 1)
|
||||
{
|
||||
TaskDialog.Show("Revit", "Please draw Path of Reinforcement before create!");
|
||||
return;
|
||||
}
|
||||
List<Vector4> ps3D = Transform2DTo3D(points.ToArray());
|
||||
|
||||
//begin Transaction, so action here can be aborted.
|
||||
Transaction transaction = new Transaction(m_profile.CommandData.Application.ActiveUIDocument.Document, "CreatePathReinforcement");
|
||||
transaction.Start();
|
||||
|
||||
PathReinforcement pathRein = m_profile.CreatePathReinforcement(ps3D, this.flipCheckBox.Checked);
|
||||
m_pointsPreview = GetGeometry(pathRein);
|
||||
|
||||
//Abort Transaction here, cancel what RevitAPI do after begin Transaction
|
||||
transaction.RollBack();
|
||||
|
||||
this.pictureBox.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// redraw curve of PathReinforcement when "flip" changed
|
||||
/// </summary>
|
||||
/// <param name="sender">object who sent this event</param>
|
||||
/// <param name="e">event args</param>
|
||||
private void FlipCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (m_previewMode)
|
||||
{
|
||||
ButtonPreview_Click(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// clean all the points of the PathReinforcement when click "Clean" Button
|
||||
/// </summary>
|
||||
/// <param name="sender">object who sent this event</param>
|
||||
/// <param name="e">event args</param>
|
||||
private void ButtonClean_Click(object sender, EventArgs e)
|
||||
{
|
||||
m_tool.Clear();
|
||||
m_tool.Finished = false;
|
||||
m_previewMode = false;
|
||||
this.previewButton.Enabled = false;
|
||||
this.pictureBox.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// stop drawing path when click "Escape" button
|
||||
/// </summary>
|
||||
/// <param name="sender">object who sent this event</param>
|
||||
/// <param name="e">event args</param>
|
||||
private void NewPathReinforcementForm_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
//finish the sketch when press "Escape"
|
||||
if (27 == (int)e.KeyChar && m_tool.PointsNumber >= 2 && !m_tool.Finished)
|
||||
{
|
||||
m_tool.Finished = true;
|
||||
this.pictureBox.Refresh();
|
||||
}
|
||||
//Close form if sketch has finished when press "Escape"
|
||||
else if (27 == (int)e.KeyChar && (m_tool.Finished || 0 == m_tool.PointsNumber))
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create PathReinforcement in Revit
|
||||
/// </summary>
|
||||
/// <param name="sender">object who sent this event</param>
|
||||
/// <param name="e">event args</param>
|
||||
private void CreateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<Point> points = m_tool.GetPoints();
|
||||
|
||||
if (0 == points.Count || 1 == points.Count)
|
||||
{
|
||||
TaskDialog.Show("Revit", "Please draw Path of Reinforcement before create!");
|
||||
return;
|
||||
}
|
||||
|
||||
//begin Transaction, so action here can be aborted.
|
||||
Transaction transaction = new Transaction(m_profile.CommandData.Application.ActiveUIDocument.Document, "CreatePathReinforcement");
|
||||
transaction.Start();
|
||||
|
||||
List<Vector4> ps3D = Transform2DTo3D(points.ToArray());
|
||||
m_profile.CreatePathReinforcement(ps3D, this.flipCheckBox.Checked);
|
||||
|
||||
transaction.Commit();
|
||||
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// close the form
|
||||
/// </summary>
|
||||
/// <param name="sender">object who sent this event</param>
|
||||
/// <param name="e">event args</param>
|
||||
private void CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// transform the point on Form to 3d world coordinate of revit
|
||||
/// </summary>
|
||||
/// <param name="ps">contain the points to be transformed</param>
|
||||
private List<Vector4> Transform2DTo3D(Point[] ps)
|
||||
{
|
||||
List<Vector4> result = new List<Vector4>();
|
||||
TransformPoints(ps);
|
||||
Matrix4 transformMatrix = Matrix4.Multiply(
|
||||
m_scaleMatrix.Inverse(), m_moveToCenterMatrix);
|
||||
transformMatrix = Matrix4.Multiply(transformMatrix, m_to2DMatrix);
|
||||
foreach (Point point in ps)
|
||||
{
|
||||
Vector4 v = new Vector4(point.X, point.Y, 0);
|
||||
v = transformMatrix.Transform(v);
|
||||
result.Add(v);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate the matrix use to scale
|
||||
/// </summary>
|
||||
/// <param name="size">pictureBox size</param>
|
||||
private Matrix4 ComputeScaleMatrix(Size size)
|
||||
{
|
||||
PointF[] boundPoints = m_profile.GetFaceBounds();
|
||||
float width = ((float)size.Width) / (boundPoints[1].X - boundPoints[0].X);
|
||||
float hight = ((float)size.Height) / (boundPoints[1].Y - boundPoints[0].Y);
|
||||
float factor = width <= hight ? width : hight;
|
||||
return new Matrix4(factor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate the matrix used to transform 3D to 2D
|
||||
/// </summary>
|
||||
private Matrix4 Compute3DTo2DMatrix()
|
||||
{
|
||||
Matrix4 result = Matrix4.Multiply(
|
||||
m_to2DMatrix.Inverse(), m_moveToCenterMatrix.Inverse());
|
||||
result = Matrix4.Multiply(result, m_scaleMatrix);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// use matrix to transform point
|
||||
/// </summary>
|
||||
/// <param name="pts">contain the points to be transform</param>
|
||||
private void TransformPoints(Point[] pts)
|
||||
{
|
||||
System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix(
|
||||
1, 0, 0, 1, this.pictureBox.Width / 2, this.pictureBox.Height / 2);
|
||||
matrix.Invert();
|
||||
matrix.TransformPoints(pts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get geometry of the pathReinforcement
|
||||
/// </summary>
|
||||
/// <param name="pathRein">pathReinforcement created</param>
|
||||
private List<List<XYZ>> GetGeometry(PathReinforcement pathRein)
|
||||
{
|
||||
Options options = m_profile.CommandData.Application.Application.Create.NewGeometryOptions();
|
||||
options.DetailLevel = ViewDetailLevel.Medium;
|
||||
options.ComputeReferences = true;
|
||||
Autodesk.Revit.DB.GeometryElement geoElem = pathRein.get_Geometry(options);
|
||||
List<Curve> curvesList = new List<Curve>();
|
||||
//GeometryObjectArray gObjects = geoElem.Objects;
|
||||
IEnumerator<GeometryObject> Objects = geoElem.GetEnumerator();
|
||||
//foreach (GeometryObject geo in gObjects)
|
||||
while (Objects.MoveNext())
|
||||
{
|
||||
GeometryObject geo = Objects.Current;
|
||||
|
||||
Curve curve = geo as Curve;
|
||||
curvesList.Add(curve);
|
||||
}
|
||||
List<List<XYZ>> pointsPreview = new List<List<XYZ>>();
|
||||
foreach (Curve curve in curvesList)
|
||||
{
|
||||
pointsPreview.Add(curve.Tessellate() as List<XYZ>);
|
||||
}
|
||||
return pointsPreview;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw points in the List on the form
|
||||
/// </summary>
|
||||
/// <param name="graphics">form graphic</param>
|
||||
/// <param name="pen">pen used to draw line in pictureBox</param>
|
||||
/// <param name="matrix4">Matrix used to transform 3d to 2d
|
||||
/// and make picture in right scale </param>
|
||||
/// <param name="points">points need to be drawn</param>
|
||||
private void DrawPoints(Graphics graphics, Pen pen, Matrix4 matrix4, List<List<XYZ>> points)
|
||||
{
|
||||
foreach (List<XYZ> xyzArray in points)
|
||||
{
|
||||
for (int i = 0; i < xyzArray.Count - 1; i++)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ point1 = xyzArray[i];
|
||||
Autodesk.Revit.DB.XYZ point2 = xyzArray[i + 1];
|
||||
|
||||
Vector4 v1 = new Vector4(point1);
|
||||
Vector4 v2 = new Vector4(point2);
|
||||
|
||||
v1 = matrix4.Transform(v1);
|
||||
v2 = matrix4.Transform(v2);
|
||||
graphics.DrawLine(pen, new Point((int)v1.X, (int)v1.Y),
|
||||
new Point((int)v2.X, (int)v2.Y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw preview of Path Reinforcement on the form
|
||||
/// </summary>
|
||||
private void DrawPreview(Graphics graphics)
|
||||
{
|
||||
if (null == m_pointsPreview)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//move the gdi origin to the picture center
|
||||
graphics.Transform = new System.Drawing.Drawing2D.Matrix(
|
||||
1, 0, 0, 1, m_sizePictureBox.Width / 2, m_sizePictureBox.Height / 2);
|
||||
DrawPoints(graphics, Pens.Red, m_transMatrix, m_pointsPreview);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,291 @@
|
||||
//
|
||||
// (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.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
using Autodesk.Revit;
|
||||
using System.Drawing;
|
||||
using Point = System.Drawing.Point;
|
||||
|
||||
namespace Revit.SDK.Samples.NewPathReinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// base class of ProfileFloor and ProfileWall
|
||||
/// contains the profile information and can make matrix to transform point to 2D plane
|
||||
/// </summary>
|
||||
public abstract class Profile
|
||||
{
|
||||
#region class member variables
|
||||
/// <summary>
|
||||
/// store all the points on the needed face
|
||||
/// </summary>
|
||||
protected List<List<XYZ>> m_points;
|
||||
|
||||
/// <summary>
|
||||
/// object which contains reference to Revit Application
|
||||
/// </summary>
|
||||
protected Autodesk.Revit.UI.ExternalCommandData m_commandData;
|
||||
|
||||
/// <summary>
|
||||
/// used to create new instances of utility objects.
|
||||
/// </summary>
|
||||
protected Autodesk.Revit.Creation.Application m_appCreator;
|
||||
|
||||
/// <summary>
|
||||
/// Revit DB document
|
||||
/// </summary>
|
||||
protected Autodesk.Revit.DB.Document m_document;
|
||||
|
||||
/// <summary>
|
||||
/// store the Matrix used to transform 3D points to 2D
|
||||
/// </summary>
|
||||
protected Matrix4 m_to2DMatrix = null;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// CommandData property get object which contains reference to Revit Application
|
||||
/// </summary>
|
||||
public Autodesk.Revit.UI.ExternalCommandData CommandData
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_commandData;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To2DMatrix property to get Matrix used to transform 3D points to 2D
|
||||
/// </summary>
|
||||
public Matrix4 To2DMatrix
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_to2DMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="commandData">object which contains reference to Revit Application</param>
|
||||
protected Profile(ExternalCommandData commandData)
|
||||
{
|
||||
m_commandData = commandData;
|
||||
m_appCreator = m_commandData.Application.Application.Create;
|
||||
m_document = m_commandData.Application.ActiveUIDocument.Document;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// abstract method to create PathReinforcement
|
||||
/// </summary>
|
||||
/// <returns>new created PathReinforcement</returns>
|
||||
/// <param name="points">points used to create PathReinforcement</param>
|
||||
/// <param name="flip">used to specify whether new PathReinforcement is Filp</param>
|
||||
public abstract PathReinforcement CreatePathReinforcement(List<Vector4> points, bool flip);
|
||||
|
||||
/// <summary>
|
||||
/// Get points in first face
|
||||
/// </summary>
|
||||
/// <param name="faces">edges in all faces</param>
|
||||
/// <returns>points in first face</returns>
|
||||
public abstract List<List<XYZ>> GetNeedPoints(List<List<Edge>> faces);
|
||||
|
||||
/// <summary>
|
||||
/// Get a matrix which can transform points to 2D
|
||||
/// </summary>
|
||||
public abstract Matrix4 GetTo2DMatrix();
|
||||
|
||||
/// <summary>
|
||||
/// draw profile of wall or floor in 2D
|
||||
/// </summary>
|
||||
/// <param name="graphics">form graphic</param>
|
||||
/// <param name="pen">pen used to draw line in pictureBox</param>
|
||||
/// <param name="matrix4">Matrix used to transform 3d to 2d
|
||||
/// and make picture in right scale </param>
|
||||
public void Draw2D(Graphics graphics, Pen pen, Matrix4 matrix4)
|
||||
{
|
||||
for (int i = 0; i < m_points.Count; i++)
|
||||
{
|
||||
List<XYZ> points = m_points[i];
|
||||
for (int j = 0; j < points.Count - 1; j++)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ point1 = points[j];
|
||||
Autodesk.Revit.DB.XYZ point2 = points[j + 1];
|
||||
|
||||
Vector4 v1 = new Vector4(point1);
|
||||
Vector4 v2 = new Vector4(point2);
|
||||
|
||||
v1 = matrix4.Transform(v1);
|
||||
v2 = matrix4.Transform(v2);
|
||||
graphics.DrawLine(pen, new Point((int)v1.X, (int)v1.Y),
|
||||
new Point((int)v2.X, (int)v2.Y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get edges of element's profile
|
||||
/// </summary>
|
||||
/// <param name="elem">selected element</param>
|
||||
/// <returns>all the faces in the selected Element</returns>
|
||||
public List<List<Edge>> GetFaces(Autodesk.Revit.DB.Element elem)
|
||||
{
|
||||
List<List<Edge>> faceEdges = new List<List<Edge>>();
|
||||
Options options = m_appCreator.NewGeometryOptions();
|
||||
options.DetailLevel = ViewDetailLevel.Medium;
|
||||
options.ComputeReferences = true; //make sure references to geometric objects are computed.
|
||||
Autodesk.Revit.DB.GeometryElement geoElem = elem.get_Geometry(options);
|
||||
//GeometryObjectArray gObjects = geoElem.Objects;
|
||||
IEnumerator<GeometryObject> Objects = geoElem.GetEnumerator();
|
||||
//get all the edges in the Geometry object
|
||||
//foreach (GeometryObject geo in gObjects)
|
||||
while (Objects.MoveNext())
|
||||
{
|
||||
GeometryObject geo = Objects.Current;
|
||||
|
||||
Solid solid = geo as Solid;
|
||||
if (solid != null)
|
||||
{
|
||||
FaceArray faces = solid.Faces;
|
||||
foreach (Face face in faces)
|
||||
{
|
||||
EdgeArrayArray edgeArrarr = face.EdgeLoops;
|
||||
foreach (EdgeArray edgeArr in edgeArrarr)
|
||||
{
|
||||
List<Edge> edgesList = new List<Edge>();
|
||||
foreach (Edge edge in edgeArr)
|
||||
{
|
||||
edgesList.Add(edge);
|
||||
}
|
||||
faceEdges.Add(edgesList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return faceEdges;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get normal of face
|
||||
/// </summary>
|
||||
/// <param name="face">edges in a face</param>
|
||||
/// <returns>vector stands for normal of the face</returns>
|
||||
public Vector4 GetFaceNormal(List<Edge> face)
|
||||
{
|
||||
Edge eg0 = face[0];
|
||||
Edge eg1 = face[1];
|
||||
|
||||
//get two lines from the face
|
||||
List<XYZ> points = eg0.Tessellate() as List<XYZ>;
|
||||
Autodesk.Revit.DB.XYZ start = points[0];
|
||||
Autodesk.Revit.DB.XYZ end = points[1];
|
||||
|
||||
Vector4 vStart = new Vector4((float)start.X, (float)start.Y, (float)start.Z);
|
||||
Vector4 vEnd = new Vector4((float)end.X, (float)end.Y, (float)end.Z);
|
||||
Vector4 vSub = vEnd - vStart;
|
||||
|
||||
points = eg1.Tessellate() as List<XYZ>;
|
||||
start = points[0];
|
||||
end = points[1];
|
||||
|
||||
vStart = new Vector4((float)start.X, (float)start.Y, (float)start.Z);
|
||||
vEnd = new Vector4((float)end.X, (float)end.Y, (float)end.Z);
|
||||
Vector4 vSub2 = vEnd - vStart;
|
||||
|
||||
//get the normal with two lines got from face
|
||||
Vector4 result = vSub.CrossProduct(vSub2);
|
||||
result.Normalize();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a matrix which can move points to center
|
||||
/// </summary>
|
||||
/// <returns>matrix used to move point to center of graphics</returns>
|
||||
public Matrix4 ToCenterMatrix()
|
||||
{
|
||||
//translate the origin to bound center
|
||||
PointF[] bounds = GetFaceBounds();
|
||||
PointF min = bounds[0];
|
||||
PointF max = bounds[1];
|
||||
PointF center = new PointF((min.X + max.X) / 2, (min.Y + max.Y) / 2);
|
||||
return new Matrix4(new Vector4(center.X, center.Y, 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the bound of a face
|
||||
/// </summary>
|
||||
/// <returns>points array store the bound of the face</returns>
|
||||
public PointF[] GetFaceBounds()
|
||||
{
|
||||
Matrix4 matrix = m_to2DMatrix;
|
||||
Matrix4 inverseMatrix = matrix.Inverse();
|
||||
float minX = 0, maxX = 0, minY = 0, maxY = 0;
|
||||
bool bFirstPoint = true;
|
||||
|
||||
//get the max and min point on the face
|
||||
for (int i = 0; i < m_points.Count; i++)
|
||||
{
|
||||
List<XYZ> points = m_points[i];
|
||||
foreach (Autodesk.Revit.DB.XYZ point in points)
|
||||
{
|
||||
Vector4 v = new Vector4(point);
|
||||
Vector4 v1 = inverseMatrix.Transform(v);
|
||||
|
||||
if (bFirstPoint)
|
||||
{
|
||||
minX = maxX = v1.X;
|
||||
minY = maxY = v1.Y;
|
||||
bFirstPoint = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (v1.X < minX)
|
||||
{
|
||||
minX = v1.X;
|
||||
}
|
||||
else if (v1.X > maxX)
|
||||
{
|
||||
maxX = v1.X;
|
||||
}
|
||||
|
||||
if (v1.Y < minY)
|
||||
{
|
||||
minY = v1.Y;
|
||||
}
|
||||
else if (v1.Y > maxY)
|
||||
{
|
||||
maxY = v1.Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//return an array with max and min value of face
|
||||
PointF[] resultPoints = new PointF[2] {
|
||||
new PointF(minX, minY), new PointF(maxX, maxY) };
|
||||
return resultPoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// (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.Linq;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
using Autodesk.Revit;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace Revit.SDK.Samples.NewPathReinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// ProfileFloor class contains the information about profile of floor,
|
||||
/// and contains method used to create PathReinforcement on floor
|
||||
/// </summary>
|
||||
public class ProfileFloor : Profile
|
||||
{
|
||||
private Floor m_data = null;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="floor">floor to create reinforcement on</param>
|
||||
/// <param name="commandData">object which contains reference to Revit Application</param>
|
||||
public ProfileFloor(Floor floor, ExternalCommandData commandData)
|
||||
: base(commandData)
|
||||
{
|
||||
m_data = floor;
|
||||
List<List<Edge>> faces = GetFaces(m_data);
|
||||
m_points = GetNeedPoints(faces);
|
||||
m_to2DMatrix = GetTo2DMatrix();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get points of the first face
|
||||
/// </summary>
|
||||
/// <param name="faces">edges in all faces</param>
|
||||
/// <returns>points of first face</returns>
|
||||
public override List<List<XYZ>> GetNeedPoints(List<List<Edge>> faces)
|
||||
{
|
||||
List<List<XYZ>> needPoints = new List<List<XYZ>>();
|
||||
foreach (Edge edge in faces[0])
|
||||
{
|
||||
List<XYZ> edgexyzs = edge.Tessellate() as List<XYZ>;
|
||||
needPoints.Add(edgexyzs);
|
||||
}
|
||||
return needPoints;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a matrix which can transform points to 2D
|
||||
/// </summary>
|
||||
/// <returns>matrix which can transform points to 2D</returns>
|
||||
public override Matrix4 GetTo2DMatrix()
|
||||
{
|
||||
View viewLevel2 = null;
|
||||
|
||||
// select the view which is named "Level 2"
|
||||
// Once use the View type to filterrrr the element ,please skip the view templates
|
||||
// because they're behind-the-scene and invisible in project browser; also invalid for API.
|
||||
IEnumerable<View> views = from elem in
|
||||
(new FilteredElementCollector(m_commandData.Application.ActiveUIDocument.Document)).OfClass(typeof(ViewPlan)).ToElements()
|
||||
let view = elem as View
|
||||
where (view != null) && (!view.IsTemplate) && (view.Name == "Level 2")
|
||||
select view;
|
||||
viewLevel2 = views.First();
|
||||
|
||||
Vector4 xAxis = new Vector4(viewLevel2.RightDirection);
|
||||
//Because Y axis in windows UI is downward, so we should Multiply(-1) here
|
||||
Vector4 yAxis = new Vector4(viewLevel2.UpDirection.Multiply(-1));
|
||||
Vector4 zAxis = new Vector4(viewLevel2.ViewDirection);
|
||||
|
||||
Matrix4 result = new Matrix4(xAxis, yAxis, zAxis);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create PathReinforcement on floor
|
||||
/// </summary>
|
||||
/// <param name="points">points used to create PathReinforcement</param>
|
||||
/// <param name="flip">used to specify whether new PathReinforcement is Filp</param>
|
||||
/// <returns>new created PathReinforcement</returns>
|
||||
public override PathReinforcement CreatePathReinforcement(List<Vector4> points, bool flip)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ p1, p2; Line curve;
|
||||
IList<Curve> curves = new List<Curve>();
|
||||
for (int i = 0; i < points.Count - 1; i++)
|
||||
{
|
||||
p1 = new Autodesk.Revit.DB.XYZ(points[i].X, points[i].Y, points[i].Z);
|
||||
p2 = new Autodesk.Revit.DB.XYZ(points[i + 1].X, points[i + 1].Y, points[i + 1].Z);
|
||||
curve = Line.CreateBound(p1, p2);
|
||||
curves.Add(curve);
|
||||
}
|
||||
ElementId pathReinforcementTypeId = PathReinforcementType.CreateDefaultPathReinforcementType(m_document);
|
||||
ElementId rebarBarTypeId = RebarBarType.CreateDefaultRebarBarType(m_document);
|
||||
ElementId rebarHookTypeId = RebarHookType.CreateDefaultRebarHookType(m_document);
|
||||
return PathReinforcement.Create(m_document, m_data, curves, flip, pathReinforcementTypeId, rebarBarTypeId, rebarHookTypeId, rebarHookTypeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
//
|
||||
// (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.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
using Autodesk.Revit;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Revit.SDK.Samples.NewPathReinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// ProfileWall class contains the information about profile of wall,
|
||||
/// and contains method to create PathReinforcement on wall
|
||||
/// </summary>
|
||||
public class ProfileWall : Profile
|
||||
{
|
||||
private Wall m_data;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="wall">wall to create reinforcement on</param>
|
||||
/// <param name="commandData">object which contains reference to Revit Application</param>
|
||||
public ProfileWall(Wall wall, ExternalCommandData commandData)
|
||||
: base(commandData)
|
||||
{
|
||||
m_data = wall;
|
||||
List<List<Edge>> faces = GetFaces(m_data);
|
||||
m_points = GetNeedPoints(faces);
|
||||
m_to2DMatrix = GetTo2DMatrix();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get points of first face
|
||||
/// </summary>
|
||||
/// <param name="faces">edges in all faces</param>
|
||||
/// <returns>points of first face</returns>
|
||||
public override List<List<XYZ>> GetNeedPoints(List<List<Edge>> faces)
|
||||
{
|
||||
List<Edge> needFace = new List<Edge>();
|
||||
List<List<XYZ>> needPoints = new List<List<XYZ>>();
|
||||
LocationCurve location = m_data.Location as LocationCurve;
|
||||
Curve curve = location.Curve;
|
||||
List<XYZ> xyzs = curve.Tessellate() as List<XYZ>;
|
||||
Vector4 zAxis = new Vector4(0, 0, 1);
|
||||
|
||||
//if Location curve of wall is line, then return first face
|
||||
if (xyzs.Count == 2)
|
||||
{
|
||||
needFace = faces[0];
|
||||
}
|
||||
|
||||
//else we return the face whose normal is Z axis
|
||||
foreach (List<Edge> face in faces)
|
||||
{
|
||||
foreach (Edge edge in face)
|
||||
{
|
||||
List<XYZ> edgexyzs = edge.Tessellate() as List<XYZ>;
|
||||
if (xyzs.Count == edgexyzs.Count)
|
||||
{
|
||||
Vector4 normal = GetFaceNormal(face); //get the normal of face
|
||||
Vector4 cross = Vector4.CrossProduct(zAxis, normal);
|
||||
cross.Normalize();
|
||||
if (cross.Length() == 1)
|
||||
{
|
||||
needFace = face;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
needFace = faces[0];
|
||||
|
||||
//get points array in edges
|
||||
foreach (Edge edge in needFace)
|
||||
{
|
||||
List<XYZ> edgexyzs = edge.Tessellate() as List<XYZ>;
|
||||
needPoints.Add(edgexyzs);
|
||||
}
|
||||
return needPoints;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a matrix which can transform points to 2D
|
||||
/// </summary>
|
||||
/// <returns>matrix which can transform points to 2D</returns>
|
||||
public override Matrix4 GetTo2DMatrix()
|
||||
{
|
||||
//get the location curve
|
||||
LocationCurve location = m_data.Location as LocationCurve;
|
||||
Vector4 xAxis = new Vector4(1, 0, 0);
|
||||
Vector4 yAxis = new Vector4(0, 1, 0);
|
||||
Vector4 zAxis = new Vector4(0, 0, 1);
|
||||
Vector4 origin = new Vector4(0, 0, 0);
|
||||
if (location != null)
|
||||
{
|
||||
Curve curve = location.Curve;
|
||||
|
||||
if (!(curve is Autodesk.Revit.DB.Line))
|
||||
{
|
||||
throw new Exception("Path Reinforcement cannot build on this Wall");
|
||||
}
|
||||
|
||||
Autodesk.Revit.DB.XYZ start = curve.GetEndPoint(0);
|
||||
Autodesk.Revit.DB.XYZ end = curve.GetEndPoint(1);
|
||||
|
||||
//because we create PathReinforcement on the back of wall
|
||||
//so we need make X axis reverse
|
||||
xAxis = new Vector4(-(float)(end.X - start.X),
|
||||
-(float)(end.Y - start.Y), -(float)(end.Z - start.Z));
|
||||
xAxis.Normalize();
|
||||
|
||||
//because in the windows UI, Y axis is downward
|
||||
yAxis = new Vector4(0, 0, -1);
|
||||
|
||||
zAxis = Vector4.CrossProduct(xAxis, yAxis);
|
||||
zAxis.Normalize();
|
||||
|
||||
origin = new Vector4((float)(end.X + start.X) / 2,
|
||||
(float)(end.Y + start.Y) / 2, (float)(end.Z + start.Z) / 2);
|
||||
}
|
||||
return new Matrix4(xAxis, yAxis, zAxis, origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create PathReinforcement on wall
|
||||
/// </summary>
|
||||
/// <param name="points">points used to create PathReinforcement</param>
|
||||
/// <param name="flip">used to specify whether new PathReinforcement is Filp</param>
|
||||
/// <returns>new created PathReinforcement</returns>
|
||||
public override PathReinforcement CreatePathReinforcement(List<Vector4> points, bool flip)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ p1, p2; Line curve;
|
||||
IList<Curve> curves = new List<Curve>();
|
||||
for (int i = 0; i < points.Count - 1; i++)
|
||||
{
|
||||
p1 = new Autodesk.Revit.DB.XYZ(points[i].X, points[i].Y, points[i].Z);
|
||||
p2 = new Autodesk.Revit.DB.XYZ(points[i + 1].X, points[i + 1].Y, points[i + 1].Z);
|
||||
curve = Line.CreateBound(p1, p2);
|
||||
curves.Add(curve);
|
||||
}
|
||||
|
||||
//draw PathReinforcement on wall
|
||||
ElementId pathReinforcementTypeId = PathReinforcementType.CreateDefaultPathReinforcementType(m_document);
|
||||
ElementId rebarBarTypeId = RebarBarType.CreateDefaultRebarBarType(m_document);
|
||||
ElementId rebarHookTypeId = RebarHookType.CreateDefaultRebarHookType(m_document);
|
||||
return PathReinforcement.Create(m_document, m_data, curves, flip, pathReinforcementTypeId, rebarBarTypeId, rebarHookTypeId, rebarHookTypeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// (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("NewPathReinforcement")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NewPathReinforcement")]
|
||||
[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("f0f80856-1bcf-4a62-8319-f8de23b9f40c")]
|
||||
|
||||
// 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.
Reference in New Issue
Block a user