mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-10 22:06:41 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,420 @@
|
||||
//
|
||||
// (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 Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The class derived from FramReinMaker shows how to create the rebars for a beam
|
||||
/// </summary>
|
||||
public class BeamFramReinMaker : FramReinMaker
|
||||
{
|
||||
#region Private Members
|
||||
|
||||
BeamGeometrySupport m_geometry; // The geometry support for beam rebar creation
|
||||
|
||||
// The rebar type, hook type and spacing information
|
||||
RebarBarType m_topEndType = null; //type of the end rebar in the top of beam
|
||||
RebarBarType m_topCenterType = null; //type of the center rebar in the center of beam
|
||||
RebarBarType m_bottomType = null; //type of the rebar on bottom of the beam
|
||||
RebarBarType m_transverseType = null; //type of the transverse rebar
|
||||
|
||||
RebarHookType m_topHookType = null; //type of the hook in the top end rebar
|
||||
RebarHookType m_transverseHookType = null; // type of the hook in the transverse rebar
|
||||
|
||||
double m_transverseEndSpacing = 0; //the spacing value of end transverse rebar
|
||||
double m_transverseCenterSpacing = 0; //the spacing value of center transverse rebar
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// get and set the type of the end rebar in the top of beam
|
||||
/// </summary>
|
||||
public RebarBarType TopEndRebarType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_topEndType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_topEndType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the type of the center rebar in the top of beam
|
||||
/// </summary>
|
||||
public RebarBarType TopCenterRebarType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_topCenterType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_topCenterType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the type of the rebar in the bottom of beam
|
||||
/// </summary>
|
||||
public RebarBarType BottomRebarType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bottomType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bottomType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the type of the transverse rebar
|
||||
/// </summary>
|
||||
public RebarBarType TransverseRebarType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transverseType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_transverseType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the spacing value of end transverse rebar
|
||||
/// </summary>
|
||||
public double TransverseEndSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transverseEndSpacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (0 > value)
|
||||
{
|
||||
throw new Exception("Transverse end spacing should be above zero");
|
||||
}
|
||||
m_transverseEndSpacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the spacing value of center transverse rebar
|
||||
/// </summary>
|
||||
public double TransverseCenterSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transverseCenterSpacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (0 > value)
|
||||
{
|
||||
throw new Exception("Transverse center spacing should be above zero");
|
||||
}
|
||||
m_transverseCenterSpacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the hook type of top end rebar
|
||||
/// </summary>
|
||||
public RebarHookType TopHookType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_topHookType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_topHookType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the hook type of transverse rebar
|
||||
/// </summary>
|
||||
public RebarHookType TransverseHookType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transverseHookType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_transverseHookType = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Constructor of the BeamFramReinMaker
|
||||
/// </summary>
|
||||
/// <param name="commandData">the ExternalCommandData reference</param>
|
||||
/// <param name="hostObject">the host beam</param>
|
||||
public BeamFramReinMaker(ExternalCommandData commandData, FamilyInstance hostObject)
|
||||
: base(commandData, hostObject)
|
||||
{
|
||||
//create new options for current project
|
||||
Options geoOptions = commandData.Application.Application.Create.NewGeometryOptions();
|
||||
geoOptions.ComputeReferences = true;
|
||||
|
||||
//create a BeamGeometrySupport instance.
|
||||
m_geometry = new BeamGeometrySupport(hostObject, geoOptions);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Override Methods
|
||||
/// <summary>
|
||||
/// Override method to do some further checks
|
||||
/// </summary>
|
||||
/// <returns>true if the the data is right and enough, otherwise false.</returns>
|
||||
protected override bool AssertData()
|
||||
{
|
||||
return base.AssertData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Display a form to collect the information for beam reinforcement creation
|
||||
/// </summary>
|
||||
/// <returns>true if the information collection is successful, otherwise false</returns>
|
||||
protected override bool DisplayForm()
|
||||
{
|
||||
// Display BeamFramReinMakerForm for the user to input information
|
||||
using (BeamFramReinMakerForm displayForm = new BeamFramReinMakerForm(this))
|
||||
{
|
||||
if (DialogResult.OK != displayForm.ShowDialog())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return base.DisplayForm();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override method to create rebar on the selected beam
|
||||
/// </summary>
|
||||
/// <returns>true if the creation is successful, otherwise false</returns>
|
||||
protected override bool FillWithBars()
|
||||
{
|
||||
// create the top rebars
|
||||
bool flag = FillTopBars();
|
||||
|
||||
// create the bottom rebars
|
||||
flag = flag && FillBottomBars();
|
||||
|
||||
// create the transverse rebars
|
||||
flag = flag && FillTransverseBars();
|
||||
|
||||
return base.FillWithBars();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create the rebar at the bottom of beam
|
||||
/// </summary>
|
||||
/// <returns>true if the creation is successful, otherwise false</returns>
|
||||
public bool FillBottomBars()
|
||||
{
|
||||
// get the geometry information of the bottom rebar
|
||||
RebarGeometry geomInfo = m_geometry.GetBottomRebar();
|
||||
|
||||
// create the rebar
|
||||
Rebar rebar = PlaceRebars(m_bottomType, null, null, geomInfo,
|
||||
RebarHookOrientation.Left, RebarHookOrientation.Left);
|
||||
return (null != rebar);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the transverse rebars
|
||||
/// </summary>
|
||||
/// <returns>true if the creation is successful, otherwise false</returns>
|
||||
public bool FillTransverseBars()
|
||||
{
|
||||
// create all kinds of transverse rebars according to the TransverseRebarLocation
|
||||
foreach (TransverseRebarLocation location in Enum.GetValues(
|
||||
typeof(TransverseRebarLocation)))
|
||||
{
|
||||
Rebar createdRebar = FillTransverseBar(location);
|
||||
//judge whether the transverse rebar creation is successful
|
||||
if (null == createdRebar)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the transverse rebars, according to the location of transverse rebars
|
||||
/// </summary>
|
||||
/// <param name="location">location of rebar which need to be created</param>
|
||||
/// <returns>the created rebar, return null if the creation is unsuccessful</returns>
|
||||
public Rebar FillTransverseBar(TransverseRebarLocation location)
|
||||
{
|
||||
// Get the geometry information which support rebar creation
|
||||
RebarGeometry geomInfo = new RebarGeometry();
|
||||
switch (location)
|
||||
{
|
||||
case TransverseRebarLocation.Start: // start transverse rebar
|
||||
case TransverseRebarLocation.End: // end transverse rebar
|
||||
geomInfo = m_geometry.GetTransverseRebar(location, m_transverseEndSpacing);
|
||||
break;
|
||||
case TransverseRebarLocation.Center:// center transverse rebar
|
||||
geomInfo = m_geometry.GetTransverseRebar(location, m_transverseCenterSpacing);
|
||||
break;
|
||||
}
|
||||
|
||||
RebarHookOrientation startHook = RebarHookOrientation.Right;
|
||||
RebarHookOrientation endHook = RebarHookOrientation.Left;
|
||||
if (!GeomUtil.IsInRightDir(geomInfo.Normal))
|
||||
{
|
||||
startHook = RebarHookOrientation.Left;
|
||||
endHook = RebarHookOrientation.Right;
|
||||
}
|
||||
|
||||
// create the rebar
|
||||
return PlaceRebars(m_transverseType, m_transverseHookType, m_transverseHookType,
|
||||
geomInfo, startHook, endHook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the hook orient of the top rebar
|
||||
/// </summary>
|
||||
/// <param name="geomInfo">the rebar geometry support information</param>
|
||||
/// <param name="location">the location of top rebar</param>
|
||||
/// <returns>the hook orient of the top hook</returns>
|
||||
private RebarHookOrientation GetTopHookOrient(RebarGeometry geomInfo, TopRebarLocation location)
|
||||
{
|
||||
// Top center rebar doesn't need hook.
|
||||
if (TopRebarLocation.Center == location)
|
||||
{
|
||||
throw new Exception("Center top rebar doesn't have any hook.");
|
||||
}
|
||||
|
||||
// Get the hook direction, rebar normal and rebar line
|
||||
Autodesk.Revit.DB.XYZ hookVec = m_geometry.GetDownDirection();
|
||||
Autodesk.Revit.DB.XYZ normal = geomInfo.Normal;
|
||||
Line rebarLine = geomInfo.Curves[0] as Line;
|
||||
|
||||
// get the top start hook orient
|
||||
if (TopRebarLocation.Start == location)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ curveVec = GeomUtil.SubXYZ(rebarLine.GetEndPoint(1), rebarLine.GetEndPoint(0));
|
||||
return GeomUtil.GetHookOrient(curveVec, normal, hookVec);
|
||||
}
|
||||
else // get the top end hook orient
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ curveVec = GeomUtil.SubXYZ(rebarLine.GetEndPoint(0), rebarLine.GetEndPoint(1));
|
||||
return GeomUtil.GetHookOrient(curveVec, normal, hookVec);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create the rebar at the top of beam
|
||||
/// </summary>
|
||||
/// <returns>true if the creation is successful, otherwise false</returns>
|
||||
private bool FillTopBars()
|
||||
{
|
||||
// create all kinds of top rebars according to the TopRebarLocation
|
||||
foreach (TopRebarLocation location in Enum.GetValues(typeof(TopRebarLocation)))
|
||||
{
|
||||
Rebar createdRebar = FillTopBar(location);
|
||||
//judge whether the top rebar creation is successful
|
||||
if (null == createdRebar)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the rebar at the top of beam, according to the top rebar location
|
||||
/// </summary>
|
||||
/// <param name="location">location of rebar which need to be created</param>
|
||||
/// <returns>the created rebar, return null if the creation is unsuccessful</returns>
|
||||
private Rebar FillTopBar(TopRebarLocation location)
|
||||
{
|
||||
//get the geometry information of the rebar
|
||||
RebarGeometry geomInfo = m_geometry.GetTopRebar(location);
|
||||
|
||||
RebarHookType startHookType = null; //the start hook type of the rebar
|
||||
RebarHookType endHookType = null; // the end hook type of the rebar
|
||||
RebarBarType rebarType = null; // the rebar type
|
||||
RebarHookOrientation startOrient = RebarHookOrientation.Right;// the start hook orient
|
||||
RebarHookOrientation endOrient = RebarHookOrientation.Left; // the end hook orient
|
||||
|
||||
// decide the rebar type, hook type and hook orient according to location
|
||||
switch (location)
|
||||
{
|
||||
case TopRebarLocation.Start:
|
||||
startHookType = m_topHookType; // start hook type
|
||||
rebarType = m_topEndType; // rebar type
|
||||
startOrient = GetTopHookOrient(geomInfo, location); // start hook orient
|
||||
break;
|
||||
case TopRebarLocation.Center:
|
||||
rebarType = m_topCenterType; // rebar type
|
||||
break;
|
||||
case TopRebarLocation.End:
|
||||
endHookType = m_topHookType; // end hook type
|
||||
rebarType = m_topEndType; // rebar type
|
||||
endOrient = GetTopHookOrient(geomInfo, location); // end hook orient
|
||||
break;
|
||||
}
|
||||
|
||||
// create the rebar
|
||||
return PlaceRebars(rebarType, startHookType, endHookType,
|
||||
geomInfo, startOrient, endOrient);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
//
|
||||
// (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.Reinforcement.CS
|
||||
{
|
||||
partial class BeamFramReinMakerForm
|
||||
{
|
||||
/// <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.barTypeGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.transverseRebarTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.transverseBarLabel = new System.Windows.Forms.Label();
|
||||
this.bottomRebarTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.bottomBarLabel3 = new System.Windows.Forms.Label();
|
||||
this.topCenterRebarTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.topEndRebarTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.topCenterBarLabel = new System.Windows.Forms.Label();
|
||||
this.topEndBarLabel = new System.Windows.Forms.Label();
|
||||
this.barSpacingGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.centerUnitLabel = new System.Windows.Forms.Label();
|
||||
this.endUnitLabel = new System.Windows.Forms.Label();
|
||||
this.transverseCenterSpacingTextBox = new System.Windows.Forms.TextBox();
|
||||
this.transverseEndSpacingTextBox = new System.Windows.Forms.TextBox();
|
||||
this.transverseCenterLabel = new System.Windows.Forms.Label();
|
||||
this.transverseEndSpacingLabel = new System.Windows.Forms.Label();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.hookTypeGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.transverseBarHookComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.topBarHookComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.transverseBraHookLabel = new System.Windows.Forms.Label();
|
||||
this.topHookLabel = new System.Windows.Forms.Label();
|
||||
this.barTypeGroupBox.SuspendLayout();
|
||||
this.barSpacingGroupBox.SuspendLayout();
|
||||
this.hookTypeGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// barTypeGroupBox
|
||||
//
|
||||
this.barTypeGroupBox.Controls.Add(this.transverseRebarTypeComboBox);
|
||||
this.barTypeGroupBox.Controls.Add(this.transverseBarLabel);
|
||||
this.barTypeGroupBox.Controls.Add(this.bottomRebarTypeComboBox);
|
||||
this.barTypeGroupBox.Controls.Add(this.bottomBarLabel3);
|
||||
this.barTypeGroupBox.Controls.Add(this.topCenterRebarTypeComboBox);
|
||||
this.barTypeGroupBox.Controls.Add(this.topEndRebarTypeComboBox);
|
||||
this.barTypeGroupBox.Controls.Add(this.topCenterBarLabel);
|
||||
this.barTypeGroupBox.Controls.Add(this.topEndBarLabel);
|
||||
this.barTypeGroupBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.barTypeGroupBox.Name = "barTypeGroupBox";
|
||||
this.barTypeGroupBox.Size = new System.Drawing.Size(305, 160);
|
||||
this.barTypeGroupBox.TabIndex = 0;
|
||||
this.barTypeGroupBox.TabStop = false;
|
||||
this.barTypeGroupBox.Text = " Bar Type";
|
||||
//
|
||||
// transverseRebarTypeComboBox
|
||||
//
|
||||
this.transverseRebarTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.transverseRebarTypeComboBox.FormattingEnabled = true;
|
||||
this.transverseRebarTypeComboBox.Location = new System.Drawing.Point(110, 126);
|
||||
this.transverseRebarTypeComboBox.Name = "transverseRebarTypeComboBox";
|
||||
this.transverseRebarTypeComboBox.Size = new System.Drawing.Size(189, 21);
|
||||
this.transverseRebarTypeComboBox.TabIndex = 8;
|
||||
//
|
||||
// transverseBarLabel
|
||||
//
|
||||
this.transverseBarLabel.AutoSize = true;
|
||||
this.transverseBarLabel.Location = new System.Drawing.Point(7, 129);
|
||||
this.transverseBarLabel.Name = "transverseBarLabel";
|
||||
this.transverseBarLabel.Size = new System.Drawing.Size(82, 13);
|
||||
this.transverseBarLabel.TabIndex = 4;
|
||||
this.transverseBarLabel.Text = "Transverse Bar:";
|
||||
//
|
||||
// bottomRebarTypeComboBox
|
||||
//
|
||||
this.bottomRebarTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.bottomRebarTypeComboBox.FormattingEnabled = true;
|
||||
this.bottomRebarTypeComboBox.Location = new System.Drawing.Point(110, 91);
|
||||
this.bottomRebarTypeComboBox.Name = "bottomRebarTypeComboBox";
|
||||
this.bottomRebarTypeComboBox.Size = new System.Drawing.Size(189, 21);
|
||||
this.bottomRebarTypeComboBox.TabIndex = 7;
|
||||
//
|
||||
// bottomBarLabel3
|
||||
//
|
||||
this.bottomBarLabel3.AutoSize = true;
|
||||
this.bottomBarLabel3.Location = new System.Drawing.Point(7, 94);
|
||||
this.bottomBarLabel3.Name = "bottomBarLabel3";
|
||||
this.bottomBarLabel3.Size = new System.Drawing.Size(62, 13);
|
||||
this.bottomBarLabel3.TabIndex = 3;
|
||||
this.bottomBarLabel3.Text = "Bottom Bar:";
|
||||
//
|
||||
// topCenterRebarTypeComboBox
|
||||
//
|
||||
this.topCenterRebarTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.topCenterRebarTypeComboBox.FormattingEnabled = true;
|
||||
this.topCenterRebarTypeComboBox.Location = new System.Drawing.Point(110, 56);
|
||||
this.topCenterRebarTypeComboBox.Name = "topCenterRebarTypeComboBox";
|
||||
this.topCenterRebarTypeComboBox.Size = new System.Drawing.Size(189, 21);
|
||||
this.topCenterRebarTypeComboBox.TabIndex = 6;
|
||||
//
|
||||
// topEndRebarTypeComboBox
|
||||
//
|
||||
this.topEndRebarTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.topEndRebarTypeComboBox.FormattingEnabled = true;
|
||||
this.topEndRebarTypeComboBox.Location = new System.Drawing.Point(110, 21);
|
||||
this.topEndRebarTypeComboBox.Name = "topEndRebarTypeComboBox";
|
||||
this.topEndRebarTypeComboBox.Size = new System.Drawing.Size(189, 21);
|
||||
this.topEndRebarTypeComboBox.TabIndex = 5;
|
||||
//
|
||||
// topCenterBarLabel
|
||||
//
|
||||
this.topCenterBarLabel.AutoSize = true;
|
||||
this.topCenterBarLabel.Location = new System.Drawing.Point(7, 59);
|
||||
this.topCenterBarLabel.Name = "topCenterBarLabel";
|
||||
this.topCenterBarLabel.Size = new System.Drawing.Size(82, 13);
|
||||
this.topCenterBarLabel.TabIndex = 2;
|
||||
this.topCenterBarLabel.Text = "Top Center Bar:";
|
||||
//
|
||||
// topEndBarLabel
|
||||
//
|
||||
this.topEndBarLabel.AutoSize = true;
|
||||
this.topEndBarLabel.Location = new System.Drawing.Point(7, 24);
|
||||
this.topEndBarLabel.Name = "topEndBarLabel";
|
||||
this.topEndBarLabel.Size = new System.Drawing.Size(70, 13);
|
||||
this.topEndBarLabel.TabIndex = 1;
|
||||
this.topEndBarLabel.Text = "Top End Bar:";
|
||||
//
|
||||
// barSpacingGroupBox
|
||||
//
|
||||
this.barSpacingGroupBox.Controls.Add(this.centerUnitLabel);
|
||||
this.barSpacingGroupBox.Controls.Add(this.endUnitLabel);
|
||||
this.barSpacingGroupBox.Controls.Add(this.transverseCenterSpacingTextBox);
|
||||
this.barSpacingGroupBox.Controls.Add(this.transverseEndSpacingTextBox);
|
||||
this.barSpacingGroupBox.Controls.Add(this.transverseCenterLabel);
|
||||
this.barSpacingGroupBox.Controls.Add(this.transverseEndSpacingLabel);
|
||||
this.barSpacingGroupBox.Location = new System.Drawing.Point(12, 293);
|
||||
this.barSpacingGroupBox.Name = "barSpacingGroupBox";
|
||||
this.barSpacingGroupBox.Size = new System.Drawing.Size(305, 86);
|
||||
this.barSpacingGroupBox.TabIndex = 14;
|
||||
this.barSpacingGroupBox.TabStop = false;
|
||||
this.barSpacingGroupBox.Text = "Bar Spacing";
|
||||
//
|
||||
// centerUnitLabel
|
||||
//
|
||||
this.centerUnitLabel.AutoSize = true;
|
||||
this.centerUnitLabel.Location = new System.Drawing.Point(271, 56);
|
||||
this.centerUnitLabel.Name = "centerUnitLabel";
|
||||
this.centerUnitLabel.Size = new System.Drawing.Size(28, 13);
|
||||
this.centerUnitLabel.TabIndex = 22;
|
||||
this.centerUnitLabel.Text = "Feet";
|
||||
//
|
||||
// endUnitLabel
|
||||
//
|
||||
this.endUnitLabel.AutoSize = true;
|
||||
this.endUnitLabel.Location = new System.Drawing.Point(271, 24);
|
||||
this.endUnitLabel.Name = "endUnitLabel";
|
||||
this.endUnitLabel.Size = new System.Drawing.Size(28, 13);
|
||||
this.endUnitLabel.TabIndex = 21;
|
||||
this.endUnitLabel.Text = "Feet";
|
||||
//
|
||||
// transverseCenterSpacingTextBox
|
||||
//
|
||||
this.transverseCenterSpacingTextBox.Location = new System.Drawing.Point(110, 53);
|
||||
this.transverseCenterSpacingTextBox.Name = "transverseCenterSpacingTextBox";
|
||||
this.transverseCenterSpacingTextBox.Size = new System.Drawing.Size(155, 20);
|
||||
this.transverseCenterSpacingTextBox.TabIndex = 18;
|
||||
//
|
||||
// transverseEndSpacingTextBox
|
||||
//
|
||||
this.transverseEndSpacingTextBox.Location = new System.Drawing.Point(110, 21);
|
||||
this.transverseEndSpacingTextBox.Name = "transverseEndSpacingTextBox";
|
||||
this.transverseEndSpacingTextBox.Size = new System.Drawing.Size(155, 20);
|
||||
this.transverseEndSpacingTextBox.TabIndex = 17;
|
||||
//
|
||||
// transverseCenterLabel
|
||||
//
|
||||
this.transverseCenterLabel.AutoSize = true;
|
||||
this.transverseCenterLabel.Location = new System.Drawing.Point(7, 56);
|
||||
this.transverseCenterLabel.Name = "transverseCenterLabel";
|
||||
this.transverseCenterLabel.Size = new System.Drawing.Size(97, 13);
|
||||
this.transverseCenterLabel.TabIndex = 16;
|
||||
this.transverseCenterLabel.Text = "Transverse Center:";
|
||||
//
|
||||
// transverseEndSpacingLabel
|
||||
//
|
||||
this.transverseEndSpacingLabel.AutoSize = true;
|
||||
this.transverseEndSpacingLabel.Location = new System.Drawing.Point(7, 24);
|
||||
this.transverseEndSpacingLabel.Name = "transverseEndSpacingLabel";
|
||||
this.transverseEndSpacingLabel.Size = new System.Drawing.Size(85, 13);
|
||||
this.transverseEndSpacingLabel.TabIndex = 15;
|
||||
this.transverseEndSpacingLabel.Text = "Transverse End:";
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(131, 398);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(90, 25);
|
||||
this.okButton.TabIndex = 19;
|
||||
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(227, 398);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(90, 25);
|
||||
this.cancelButton.TabIndex = 20;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// hookTypeGroupBox
|
||||
//
|
||||
this.hookTypeGroupBox.Controls.Add(this.transverseBarHookComboBox);
|
||||
this.hookTypeGroupBox.Controls.Add(this.topBarHookComboBox);
|
||||
this.hookTypeGroupBox.Controls.Add(this.transverseBraHookLabel);
|
||||
this.hookTypeGroupBox.Controls.Add(this.topHookLabel);
|
||||
this.hookTypeGroupBox.Location = new System.Drawing.Point(12, 188);
|
||||
this.hookTypeGroupBox.Name = "hookTypeGroupBox";
|
||||
this.hookTypeGroupBox.Size = new System.Drawing.Size(305, 87);
|
||||
this.hookTypeGroupBox.TabIndex = 9;
|
||||
this.hookTypeGroupBox.TabStop = false;
|
||||
this.hookTypeGroupBox.Text = "Hook Type";
|
||||
//
|
||||
// transverseBarHookComboBox
|
||||
//
|
||||
this.transverseBarHookComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.transverseBarHookComboBox.FormattingEnabled = true;
|
||||
this.transverseBarHookComboBox.Location = new System.Drawing.Point(110, 55);
|
||||
this.transverseBarHookComboBox.Name = "transverseBarHookComboBox";
|
||||
this.transverseBarHookComboBox.Size = new System.Drawing.Size(189, 21);
|
||||
this.transverseBarHookComboBox.TabIndex = 13;
|
||||
//
|
||||
// topBarHookComboBox
|
||||
//
|
||||
this.topBarHookComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.topBarHookComboBox.FormattingEnabled = true;
|
||||
this.topBarHookComboBox.Location = new System.Drawing.Point(110, 19);
|
||||
this.topBarHookComboBox.Name = "topBarHookComboBox";
|
||||
this.topBarHookComboBox.Size = new System.Drawing.Size(189, 21);
|
||||
this.topBarHookComboBox.TabIndex = 12;
|
||||
//
|
||||
// transverseBraHookLabel
|
||||
//
|
||||
this.transverseBraHookLabel.AutoSize = true;
|
||||
this.transverseBraHookLabel.Location = new System.Drawing.Point(7, 58);
|
||||
this.transverseBraHookLabel.Name = "transverseBraHookLabel";
|
||||
this.transverseBraHookLabel.Size = new System.Drawing.Size(92, 13);
|
||||
this.transverseBraHookLabel.TabIndex = 11;
|
||||
this.transverseBraHookLabel.Text = "Transverse Hook:";
|
||||
//
|
||||
// topHookLabel
|
||||
//
|
||||
this.topHookLabel.AutoSize = true;
|
||||
this.topHookLabel.Location = new System.Drawing.Point(7, 22);
|
||||
this.topHookLabel.Name = "topHookLabel";
|
||||
this.topHookLabel.Size = new System.Drawing.Size(58, 13);
|
||||
this.topHookLabel.TabIndex = 10;
|
||||
this.topHookLabel.Text = "Top Hook:";
|
||||
//
|
||||
// BeamFramReinMakerForm
|
||||
//
|
||||
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, 435);
|
||||
this.Controls.Add(this.hookTypeGroupBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.barSpacingGroupBox);
|
||||
this.Controls.Add(this.barTypeGroupBox);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "BeamFramReinMakerForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Beam Reinforcment";
|
||||
this.barTypeGroupBox.ResumeLayout(false);
|
||||
this.barTypeGroupBox.PerformLayout();
|
||||
this.barSpacingGroupBox.ResumeLayout(false);
|
||||
this.barSpacingGroupBox.PerformLayout();
|
||||
this.hookTypeGroupBox.ResumeLayout(false);
|
||||
this.hookTypeGroupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox barTypeGroupBox;
|
||||
private System.Windows.Forms.ComboBox topEndRebarTypeComboBox;
|
||||
private System.Windows.Forms.Label topCenterBarLabel;
|
||||
private System.Windows.Forms.Label topEndBarLabel;
|
||||
private System.Windows.Forms.ComboBox topCenterRebarTypeComboBox;
|
||||
private System.Windows.Forms.Label transverseBarLabel;
|
||||
private System.Windows.Forms.ComboBox bottomRebarTypeComboBox;
|
||||
private System.Windows.Forms.Label bottomBarLabel3;
|
||||
private System.Windows.Forms.GroupBox barSpacingGroupBox;
|
||||
private System.Windows.Forms.ComboBox transverseRebarTypeComboBox;
|
||||
private System.Windows.Forms.Label transverseCenterLabel;
|
||||
private System.Windows.Forms.Label transverseEndSpacingLabel;
|
||||
private System.Windows.Forms.TextBox transverseCenterSpacingTextBox;
|
||||
private System.Windows.Forms.TextBox transverseEndSpacingTextBox;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.GroupBox hookTypeGroupBox;
|
||||
private System.Windows.Forms.Label transverseBraHookLabel;
|
||||
private System.Windows.Forms.Label topHookLabel;
|
||||
private System.Windows.Forms.ComboBox transverseBarHookComboBox;
|
||||
private System.Windows.Forms.ComboBox topBarHookComboBox;
|
||||
private System.Windows.Forms.Label centerUnitLabel;
|
||||
private System.Windows.Forms.Label endUnitLabel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
//
|
||||
// (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 Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The form is used for collecting information of beam reinforcement creation
|
||||
/// </summary>
|
||||
public partial class BeamFramReinMakerForm : System.Windows.Forms.Form
|
||||
{
|
||||
// Private members
|
||||
BeamFramReinMaker m_dataBuffer = null;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="dataBuffer">the BeamFramReinMaker reference</param>
|
||||
public BeamFramReinMakerForm(BeamFramReinMaker dataBuffer)
|
||||
{
|
||||
// Required for Windows Form Designer support
|
||||
InitializeComponent();
|
||||
|
||||
// Store the reference of BeamFramReinMaker
|
||||
m_dataBuffer = dataBuffer;
|
||||
|
||||
// Bing the data source for all combo boxes
|
||||
BingingDataSource();
|
||||
|
||||
// set the initialization data of the spacing
|
||||
transverseCenterSpacingTextBox.Text = 0.1.ToString("0.0");
|
||||
transverseEndSpacingTextBox.Text = 0.1.ToString("0.0");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bing the data source for all combo boxes
|
||||
/// </summary>
|
||||
private void BingingDataSource()
|
||||
{
|
||||
// bind the topEndRebarTypeComboBox
|
||||
topEndRebarTypeComboBox.DataSource = m_dataBuffer.RebarTypes;
|
||||
topEndRebarTypeComboBox.DisplayMember = "Name";
|
||||
|
||||
// bind the topCenterRebarTypeComboBox
|
||||
topCenterRebarTypeComboBox.DataSource = m_dataBuffer.RebarTypes;
|
||||
topCenterRebarTypeComboBox.DisplayMember = "Name";
|
||||
|
||||
// bind the bottomRebarTypeComboBox
|
||||
bottomRebarTypeComboBox.DataSource = m_dataBuffer.RebarTypes;
|
||||
bottomRebarTypeComboBox.DisplayMember = "Name";
|
||||
|
||||
// bind the transverseRebarTypeComboBox
|
||||
transverseRebarTypeComboBox.DataSource = m_dataBuffer.RebarTypes;
|
||||
transverseRebarTypeComboBox.DisplayMember = "Name";
|
||||
|
||||
// bind the topBarHookComboBox
|
||||
topBarHookComboBox.DataSource = m_dataBuffer.HookTypes;
|
||||
topBarHookComboBox.DisplayMember = "Name";
|
||||
|
||||
// bind the transverseBarHookComboBox
|
||||
transverseBarHookComboBox.DataSource = m_dataBuffer.HookTypes;
|
||||
transverseBarHookComboBox.DisplayMember = "Name";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the user click ok, refresh the data of BeamFramReinMaker and close form
|
||||
/// </summary>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// set TopEndRebarType data
|
||||
RebarBarType type = topEndRebarTypeComboBox.SelectedItem as RebarBarType;
|
||||
m_dataBuffer.TopEndRebarType = type;
|
||||
|
||||
// set TopCenterRebarType data
|
||||
type = topCenterRebarTypeComboBox.SelectedItem as RebarBarType;
|
||||
m_dataBuffer.TopCenterRebarType = type;
|
||||
|
||||
// set BottomRebarType data
|
||||
type = bottomRebarTypeComboBox.SelectedItem as RebarBarType;
|
||||
m_dataBuffer.BottomRebarType = type;
|
||||
|
||||
// set TransverseRebarType data
|
||||
type = transverseRebarTypeComboBox.SelectedItem as RebarBarType;
|
||||
m_dataBuffer.TransverseRebarType = type;
|
||||
|
||||
// set TopHookType data
|
||||
RebarHookType hookType = topBarHookComboBox.SelectedItem as RebarHookType;
|
||||
m_dataBuffer.TopHookType = hookType;
|
||||
|
||||
// set TransverseHookType data
|
||||
hookType = transverseBarHookComboBox.SelectedItem as RebarHookType;
|
||||
m_dataBuffer.TransverseHookType = hookType;
|
||||
|
||||
try
|
||||
{
|
||||
// set TransverseEndSpacing data
|
||||
double spacing = Convert.ToDouble(transverseEndSpacingTextBox.Text);
|
||||
m_dataBuffer.TransverseEndSpacing = spacing;
|
||||
|
||||
// set TransverseCenterSpacing data
|
||||
spacing = Convert.ToDouble(transverseCenterSpacingTextBox.Text);
|
||||
m_dataBuffer.TransverseCenterSpacing = spacing;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
// spacing text boxes should only input number information
|
||||
TaskDialog.Show("Revit", "Please input double number in spacing TextBox.");
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// other unexpected error, just show the information
|
||||
TaskDialog.Show("Revit", ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
this.DialogResult = DialogResult.OK; // set dialog result
|
||||
this.Close(); // close the form
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the user click the cancel, just close the form
|
||||
/// </summary>
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;// set dialog result
|
||||
this.Close(); // close the form
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,276 @@
|
||||
//
|
||||
// (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.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The geometry support for reinforcement creation on beam.
|
||||
/// It can prepare the geometry information for top rebar, bottom and transverse rebar creation
|
||||
/// </summary>
|
||||
public class BeamGeometrySupport : GeometrySupport
|
||||
{
|
||||
// Private members
|
||||
double m_beamLength; //the length of the beam
|
||||
double m_beamWidth; //the width of the beam
|
||||
double m_beamHeight; //the height of the beam
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="element">the beam which the rebars are placed on</param>
|
||||
/// <param name="geoOptions">the geometry option</param>
|
||||
public BeamGeometrySupport(FamilyInstance element, Options geoOptions)
|
||||
: base(element, geoOptions)
|
||||
{
|
||||
// assert the host element is a beam
|
||||
if (!element.StructuralType.Equals(StructuralType.Beam))
|
||||
{
|
||||
throw new Exception("BeamGeometrySupport can only work for beam instance.");
|
||||
}
|
||||
|
||||
// Get the length, width and height of the beam.
|
||||
m_beamLength = GetDrivingLineLength();
|
||||
m_beamWidth = GetBeamWidth();
|
||||
m_beamHeight = GetBeamHeight();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the geometry information for top rebar
|
||||
/// </summary>
|
||||
/// <param name="location">indicate where top rebar is placed</param>
|
||||
/// <returns>the gotten geometry information</returns>
|
||||
public RebarGeometry GetTopRebar(TopRebarLocation location)
|
||||
{
|
||||
// sort the points of the swept profile
|
||||
XYZHeightComparer comparer = new XYZHeightComparer();
|
||||
m_points.Sort(comparer);
|
||||
|
||||
// Get the normal parameter for rebar creation
|
||||
List<Autodesk.Revit.DB.XYZ > directions = GetRelatedVectors(m_points[3]);
|
||||
directions.Sort(comparer);
|
||||
Autodesk.Revit.DB.XYZ normal = directions[1];
|
||||
|
||||
double offset = 0; //the offset from the beam surface to the rebar
|
||||
double startPointOffset = 0; // the offset of start point from swept profile
|
||||
double rebarLength = m_beamLength / 3; //the length of the rebar
|
||||
int rebarNumber = BeamRebarData.TopRebarNumber; //the number of the rebar
|
||||
|
||||
// set offset and startPointOffset according to the location of rebar
|
||||
switch (location)
|
||||
{
|
||||
case TopRebarLocation.Start: // top start rebar
|
||||
offset = BeamRebarData.TopEndOffset;
|
||||
break;
|
||||
case TopRebarLocation.Center: // top center rebar
|
||||
offset = BeamRebarData.TopCenterOffset;
|
||||
startPointOffset = m_beamLength / 3 - 0.5;
|
||||
rebarLength = m_beamLength / 3 + 1;
|
||||
break;
|
||||
case TopRebarLocation.End: // top end rebar
|
||||
offset = BeamRebarData.TopEndOffset;
|
||||
startPointOffset = m_beamLength * 2 / 3;
|
||||
break;
|
||||
default:
|
||||
throw new Exception("The program should never go here.");
|
||||
}
|
||||
|
||||
// Get the curve which define the shape of the top rebar curve
|
||||
List<Autodesk.Revit.DB.XYZ > movedPoints = OffsetPoints(offset);
|
||||
Autodesk.Revit.DB.XYZ startPoint = movedPoints[movedPoints.Count - 1];
|
||||
|
||||
// offset the start point according startPointOffset
|
||||
startPoint = GeomUtil.OffsetPoint(startPoint, m_drivingVector, startPointOffset);
|
||||
// get the coordinate of endpoint
|
||||
Autodesk.Revit.DB.XYZ endPoint = GeomUtil.OffsetPoint(startPoint, m_drivingVector, rebarLength);
|
||||
IList<Curve> curves = new List<Curve>(); //the profile of the top rebar
|
||||
curves.Add(Line.CreateBound(startPoint, endPoint));
|
||||
|
||||
// the spacing of the rebar
|
||||
double spacing = spacing = (m_beamWidth - 2 * offset) / (rebarNumber - 1);
|
||||
|
||||
// return the rebar geometry information
|
||||
return new RebarGeometry(normal, curves, rebarNumber, spacing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the geometry information of bottom rebar
|
||||
/// </summary>
|
||||
/// <returns>the gotten geometry information</returns>
|
||||
public RebarGeometry GetBottomRebar()
|
||||
{
|
||||
// sort the points of the swept profile
|
||||
XYZHeightComparer comparer = new XYZHeightComparer();
|
||||
m_points.Sort(comparer);
|
||||
|
||||
// Get the normal parameter for bottom rebar creation
|
||||
List<Autodesk.Revit.DB.XYZ > directions = GetRelatedVectors(m_points[0]);
|
||||
directions.Sort(comparer);
|
||||
Autodesk.Revit.DB.XYZ normal = directions[0];
|
||||
|
||||
double offset = BeamRebarData.BottomOffset; //offset value of the rebar
|
||||
int rebarNumber = BeamRebarData.BottomRebarNumber; //the number of the rebar
|
||||
// the spacing of the rebar
|
||||
double spacing = (m_beamWidth - 2 * offset) / (rebarNumber - 1);
|
||||
|
||||
// Get the curve which define the shape of the bottom rebar curve
|
||||
List<Autodesk.Revit.DB.XYZ > movedPoints = OffsetPoints(offset);
|
||||
Autodesk.Revit.DB.XYZ startPoint = movedPoints[0]; //get the coordinate of startpoint
|
||||
//get the coordinate of endpoint
|
||||
Autodesk.Revit.DB.XYZ endPoint = GeomUtil.OffsetPoint(startPoint, m_drivingVector, m_beamLength);
|
||||
|
||||
IList<Curve> curves = new List<Curve>(); //the profile of the bottom rebar
|
||||
curves.Add(Line.CreateBound(startPoint, endPoint));
|
||||
|
||||
// return the rebar geometry information
|
||||
return new RebarGeometry(normal, curves, rebarNumber, spacing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the geometry information of transverse rebar
|
||||
/// </summary>
|
||||
/// <param name="location">indicate which part of transverse rebar</param>
|
||||
/// <param name="spacing">the spacing of the rebar</param>
|
||||
/// <returns>the gotten geometry information</returns>
|
||||
public RebarGeometry GetTransverseRebar(TransverseRebarLocation location, double spacing)
|
||||
{
|
||||
// sort the points of the swept profile
|
||||
XYZHeightComparer comparer = new XYZHeightComparer();
|
||||
m_points.Sort(comparer);
|
||||
|
||||
// the offset from the beam surface to the rebar
|
||||
double offset = BeamRebarData.TransverseOffset;
|
||||
// the offset from the beam end to the transverse end
|
||||
double endOffset = BeamRebarData.TransverseEndOffset;
|
||||
// the offset between two transverses
|
||||
double betweenOffset = BeamRebarData.TransverseSpaceBetween;
|
||||
// the length of the transverse rebar
|
||||
double rebarLength = (m_beamLength - 2 * endOffset - 2 * betweenOffset) / 3;
|
||||
// the number of the transverse rebar
|
||||
int rebarNumber = (int)(rebarLength / spacing) + 1;
|
||||
|
||||
// get the origin and normal parameter for rebar creation
|
||||
Autodesk.Revit.DB.XYZ normal = m_drivingVector;
|
||||
double curveOffset = 0;
|
||||
|
||||
//judge the coordinate of transverse rebar according to the location
|
||||
switch (location)
|
||||
{
|
||||
case TransverseRebarLocation.Start: // start transverse rebar
|
||||
curveOffset = endOffset;
|
||||
break;
|
||||
case TransverseRebarLocation.Center: // center transverse rebar
|
||||
curveOffset = endOffset + rebarLength + betweenOffset;
|
||||
curveOffset = curveOffset + (rebarLength % spacing) / 2;
|
||||
break;
|
||||
case TransverseRebarLocation.End: // end transverse rebar
|
||||
curveOffset = m_beamLength - endOffset - rebarLength + (rebarLength % spacing);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("The program should never go here.");
|
||||
}
|
||||
|
||||
// get the profile of the transverse rebar
|
||||
List<Autodesk.Revit.DB.XYZ > movedPoints = OffsetPoints(offset);
|
||||
|
||||
// Translate curves points
|
||||
List<Autodesk.Revit.DB.XYZ > translatedPoints = new List<Autodesk.Revit.DB.XYZ >();
|
||||
foreach (Autodesk.Revit.DB.XYZ point in movedPoints)
|
||||
{
|
||||
translatedPoints.Add(GeomUtil.OffsetPoint(point, m_drivingVector, curveOffset));
|
||||
}
|
||||
|
||||
IList<Curve> curves = new List<Curve>();
|
||||
Autodesk.Revit.DB.XYZ first = translatedPoints[0];
|
||||
Autodesk.Revit.DB.XYZ second = translatedPoints[1];
|
||||
Autodesk.Revit.DB.XYZ third = translatedPoints[2];
|
||||
Autodesk.Revit.DB.XYZ fourth = translatedPoints[3];
|
||||
|
||||
curves.Add(Line.CreateBound(first, second));
|
||||
curves.Add(Line.CreateBound(second, fourth));
|
||||
curves.Add(Line.CreateBound(fourth, third));
|
||||
curves.Add(Line.CreateBound(third, first));
|
||||
|
||||
// return the rebar geometry information
|
||||
return new RebarGeometry(normal, curves, rebarNumber, spacing);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the down direction, which stand for the top hook direction
|
||||
/// </summary>
|
||||
/// <returns>the down direction</returns>
|
||||
public Autodesk.Revit.DB.XYZ GetDownDirection()
|
||||
{
|
||||
XYZHeightComparer comparer = new XYZHeightComparer();
|
||||
m_points.Sort(comparer);
|
||||
|
||||
Autodesk.Revit.DB.XYZ refPoint = m_points[3];
|
||||
List<Autodesk.Revit.DB.XYZ > directions = GetRelatedVectors(refPoint);
|
||||
directions.Sort(comparer);
|
||||
|
||||
return directions[0];
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the width of the beam
|
||||
/// </summary>
|
||||
/// <returns>the width data</returns>
|
||||
private double GetBeamWidth()
|
||||
{
|
||||
XYZHeightComparer comparer = new XYZHeightComparer();
|
||||
m_points.Sort(comparer);
|
||||
|
||||
Autodesk.Revit.DB.XYZ refPoint = m_points[0];
|
||||
List<Autodesk.Revit.DB.XYZ > directions = GetRelatedVectors(refPoint);
|
||||
directions.Sort(comparer);
|
||||
|
||||
return GeomUtil.GetLength(directions[0]);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the height of the beam
|
||||
/// </summary>
|
||||
/// <returns>the height data</returns>
|
||||
private double GetBeamHeight()
|
||||
{
|
||||
XYZHeightComparer comparer = new XYZHeightComparer();
|
||||
m_points.Sort(comparer);
|
||||
|
||||
Autodesk.Revit.DB.XYZ refPoint = m_points[0];
|
||||
List<Autodesk.Revit.DB.XYZ > directions = GetRelatedVectors(refPoint);
|
||||
directions.Sort(comparer);
|
||||
|
||||
return GeomUtil.GetLength(directions[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
//
|
||||
// (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 Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The class derived form FramReinMaker showes how to create the rebars for a column
|
||||
/// </summary>
|
||||
public class ColumnFramReinMaker : FramReinMaker
|
||||
{
|
||||
#region Private Members
|
||||
|
||||
ColumnGeometrySupport m_geometry; // The geometry support for column rebar creation
|
||||
|
||||
RebarBarType m_transverseEndType = null; //type of the end transverse rebar
|
||||
RebarBarType m_transverseCenterType = null; //type of the center transverse rebar
|
||||
RebarBarType m_verticalType = null; //type of the vertical rebar
|
||||
RebarHookType m_transverseHookType = null; //type of the hook
|
||||
|
||||
double m_transverseEndSpacing = 0; //the space value of end transverse rebar
|
||||
double m_transverseCenterSpacing = 0; //the space value of center transverse rebar
|
||||
int m_verticalRebarNumber = 0; //the number of the vertical rebar
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// get and set the type of the end transverse rebar
|
||||
/// </summary>
|
||||
public RebarBarType TransverseEndType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transverseEndType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_transverseEndType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the type of the center transverse rebar
|
||||
/// </summary>
|
||||
public RebarBarType TransverseCenterType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transverseCenterType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_transverseCenterType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the type of the vertical rebar
|
||||
/// </summary>
|
||||
public RebarBarType VerticalRebarType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_verticalType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_verticalType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the space value of end transverse rebar
|
||||
/// </summary>
|
||||
public double TransverseEndSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transverseEndSpacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (0 > value) // spacing data must be above 0
|
||||
{
|
||||
throw new Exception("Transverse end spacing should be above zero");
|
||||
}
|
||||
m_transverseEndSpacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the space value of center transverse rebar
|
||||
/// </summary>
|
||||
public double TransverseCenterSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transverseCenterSpacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (0 > value) // spacing data must be above 0
|
||||
{
|
||||
throw new Exception("Transverse center spacing should be above zero");
|
||||
}
|
||||
m_transverseCenterSpacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the number of vertical rebar
|
||||
/// </summary>
|
||||
public int VerticalRebarNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_verticalRebarNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (4 > value) // vertical rebar number must be above 3
|
||||
{
|
||||
throw new Exception("The minimum of vertical rebar number shouble be four.");
|
||||
}
|
||||
m_verticalRebarNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the hook type of transverse rebar
|
||||
/// </summary>
|
||||
public RebarHookType TransverseHookType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_transverseHookType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_transverseHookType = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Constructor of the ColumnFramReinMaker
|
||||
/// </summary>
|
||||
/// <param name="commandData">the ExternalCommandData reference</param>
|
||||
/// <param name="hostObject">the host column</param>
|
||||
public ColumnFramReinMaker(ExternalCommandData commandData, FamilyInstance hostObject)
|
||||
: base(commandData, hostObject)
|
||||
{
|
||||
//create a new options for current project
|
||||
Options geoOptions = commandData.Application.Application.Create.NewGeometryOptions();
|
||||
geoOptions.ComputeReferences = true;
|
||||
|
||||
//create a ColumnGeometrySupport instance
|
||||
m_geometry = new ColumnGeometrySupport(hostObject, geoOptions);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Override Methods
|
||||
|
||||
/// <summary>
|
||||
/// Override method to do some further checks
|
||||
/// </summary>
|
||||
/// <returns>true if the the data is right and enough, otherwise false.</returns>
|
||||
protected override bool AssertData()
|
||||
{
|
||||
return base.AssertData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Display a form to collect the information for column reinforcement creation
|
||||
/// </summary>
|
||||
/// <returns>true if the informatin collection is successful, otherwise false</returns>
|
||||
protected override bool DisplayForm()
|
||||
{
|
||||
// Display ColumnFramReinMakerForm for the user input information
|
||||
using (ColumnFramReinMakerForm displayForm = new ColumnFramReinMakerForm(this))
|
||||
{
|
||||
if (DialogResult.OK != displayForm.ShowDialog())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return base.DisplayForm();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override method to create rebars on the selected column
|
||||
/// </summary>
|
||||
/// <returns>true if the creation is successful, otherwise false.</returns>
|
||||
protected override bool FillWithBars()
|
||||
{
|
||||
// create the transverse rebars
|
||||
bool flag = FillTransverseBars();
|
||||
|
||||
// create the vertical rebars
|
||||
flag = flag && FillVerticalBars();
|
||||
|
||||
return base.FillWithBars();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// create the transverse rebars for the column
|
||||
/// </summary>
|
||||
/// <returns>true if the creation is successful, otherwise false</returns>
|
||||
public bool FillTransverseBars()
|
||||
{
|
||||
// create all kinds of transverse rebars according to the TransverseRebarLocation
|
||||
foreach (TransverseRebarLocation location in Enum.GetValues(
|
||||
typeof(TransverseRebarLocation)))
|
||||
{
|
||||
Rebar createdRebar = FillTransverseBar(location);
|
||||
//judge whether the transverse rebar creation is successful
|
||||
if (null == createdRebar)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the transverse rebars, according to the transverse rebar location
|
||||
/// </summary>
|
||||
/// <param name="location">location of rebar which need to be created</param>
|
||||
/// <returns>the created rebar, return null if the creation is unsuccessful</returns>
|
||||
public Rebar FillTransverseBar(TransverseRebarLocation location)
|
||||
{
|
||||
// Get the geometry information which support rebar creation
|
||||
RebarGeometry geomInfo = new RebarGeometry();
|
||||
RebarBarType barType = null;
|
||||
switch (location)
|
||||
{
|
||||
case TransverseRebarLocation.Start: // start transverse rebar
|
||||
case TransverseRebarLocation.End: // end transverse rebar
|
||||
geomInfo = m_geometry.GetTransverseRebar(location, m_transverseEndSpacing);
|
||||
barType = m_transverseEndType;
|
||||
break;
|
||||
case TransverseRebarLocation.Center:// center transverse rebar
|
||||
geomInfo = m_geometry.GetTransverseRebar(location, m_transverseCenterSpacing);
|
||||
barType = m_transverseCenterType;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// create the rebar
|
||||
return PlaceRebars(barType, m_transverseHookType, m_transverseHookType,
|
||||
geomInfo, RebarHookOrientation.Right, RebarHookOrientation.Left);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create the vertical rebar according the location
|
||||
/// </summary>
|
||||
/// <param name="location">location of rebar which need to be created</param>
|
||||
/// <returns>the created rebar, return null if the creation is unsuccessful</returns>
|
||||
public Rebar FillVerticalBar(VerticalRebarLocation location)
|
||||
{
|
||||
//calculate the rebar number in different location
|
||||
int rebarNubmer = m_verticalRebarNumber / 4;
|
||||
switch (location)
|
||||
{
|
||||
case VerticalRebarLocation.East: // the east vertical rebar
|
||||
if (0 < m_verticalRebarNumber % 4)
|
||||
{
|
||||
rebarNubmer++;
|
||||
}
|
||||
break;
|
||||
case VerticalRebarLocation.North: // the north vertical rebar
|
||||
if (2 < m_verticalRebarNumber % 4)
|
||||
{
|
||||
rebarNubmer++;
|
||||
}
|
||||
break;
|
||||
case VerticalRebarLocation.West: // the west vertical rebar
|
||||
if (1 < m_verticalRebarNumber % 4)
|
||||
{
|
||||
rebarNubmer++;
|
||||
}
|
||||
break;
|
||||
case VerticalRebarLocation.South: // the south vertical rebar
|
||||
break;
|
||||
}
|
||||
|
||||
// get the geometry information for rebar creation
|
||||
RebarGeometry geomInfo = m_geometry.GetVerticalRebar(location, rebarNubmer);
|
||||
|
||||
// create the rebar
|
||||
return PlaceRebars(m_verticalType, null, null, geomInfo,
|
||||
RebarHookOrientation.Left, RebarHookOrientation.Left);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// create the all the vertial rebar
|
||||
/// </summary>
|
||||
/// <returns>true if the creation is successful, otherwise false</returns>
|
||||
private bool FillVerticalBars()
|
||||
{
|
||||
// create all kinds of vertical rebars according to the VerticalRebarLocation
|
||||
foreach (VerticalRebarLocation location in Enum.GetValues(
|
||||
typeof(VerticalRebarLocation)))
|
||||
{
|
||||
Rebar createdRebar = FillVerticalBar(location);
|
||||
//judge whether the vertical rebar creation is successful
|
||||
if (null == createdRebar)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
//
|
||||
// (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.Reinforcement.CS
|
||||
{
|
||||
partial class ColumnFramReinMakerForm
|
||||
{
|
||||
/// <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.rebarTypesGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.centerTransverseRebarTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.endTransverseRebarTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.verticalRebarTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.centerTransverseRebarLabel = new System.Windows.Forms.Label();
|
||||
this.endTranseverseRebarLabel = new System.Windows.Forms.Label();
|
||||
this.verticalRebarTypeLabel = new System.Windows.Forms.Label();
|
||||
this.rebarSpacingGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.centerRebarUnitLabel = new System.Windows.Forms.Label();
|
||||
this.endRebarUnitLabel = new System.Windows.Forms.Label();
|
||||
this.centerSpacingTextBox = new System.Windows.Forms.TextBox();
|
||||
this.endSpacingTextBox = new System.Windows.Forms.TextBox();
|
||||
this.centerSpacingLabel = new System.Windows.Forms.Label();
|
||||
this.endSpacingLabel = new System.Windows.Forms.Label();
|
||||
this.rebarQuantityLabel = new System.Windows.Forms.Label();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.hookTypeGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.transverseRebarHookComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.transverseRebarHookLabel = new System.Windows.Forms.Label();
|
||||
this.rebarQuantityNumericUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.rebarTypesGroupBox.SuspendLayout();
|
||||
this.rebarSpacingGroupBox.SuspendLayout();
|
||||
this.hookTypeGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.rebarQuantityNumericUpDown)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// rebarTypesGroupBox
|
||||
//
|
||||
this.rebarTypesGroupBox.Controls.Add(this.centerTransverseRebarTypeComboBox);
|
||||
this.rebarTypesGroupBox.Controls.Add(this.endTransverseRebarTypeComboBox);
|
||||
this.rebarTypesGroupBox.Controls.Add(this.verticalRebarTypeComboBox);
|
||||
this.rebarTypesGroupBox.Controls.Add(this.centerTransverseRebarLabel);
|
||||
this.rebarTypesGroupBox.Controls.Add(this.endTranseverseRebarLabel);
|
||||
this.rebarTypesGroupBox.Controls.Add(this.verticalRebarTypeLabel);
|
||||
this.rebarTypesGroupBox.Location = new System.Drawing.Point(10, 12);
|
||||
this.rebarTypesGroupBox.Name = "rebarTypesGroupBox";
|
||||
this.rebarTypesGroupBox.Size = new System.Drawing.Size(307, 122);
|
||||
this.rebarTypesGroupBox.TabIndex = 0;
|
||||
this.rebarTypesGroupBox.TabStop = false;
|
||||
this.rebarTypesGroupBox.Text = "Bar Type";
|
||||
//
|
||||
// centerTransverseRebarTypeComboBox
|
||||
//
|
||||
this.centerTransverseRebarTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.centerTransverseRebarTypeComboBox.FormattingEnabled = true;
|
||||
this.centerTransverseRebarTypeComboBox.Location = new System.Drawing.Point(130, 89);
|
||||
this.centerTransverseRebarTypeComboBox.Name = "centerTransverseRebarTypeComboBox";
|
||||
this.centerTransverseRebarTypeComboBox.Size = new System.Drawing.Size(171, 21);
|
||||
this.centerTransverseRebarTypeComboBox.TabIndex = 6;
|
||||
//
|
||||
// endTransverseRebarTypeComboBox
|
||||
//
|
||||
this.endTransverseRebarTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.endTransverseRebarTypeComboBox.FormattingEnabled = true;
|
||||
this.endTransverseRebarTypeComboBox.Location = new System.Drawing.Point(130, 55);
|
||||
this.endTransverseRebarTypeComboBox.Name = "endTransverseRebarTypeComboBox";
|
||||
this.endTransverseRebarTypeComboBox.Size = new System.Drawing.Size(171, 21);
|
||||
this.endTransverseRebarTypeComboBox.TabIndex = 5;
|
||||
//
|
||||
// verticalRebarTypeComboBox
|
||||
//
|
||||
this.verticalRebarTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.verticalRebarTypeComboBox.FormattingEnabled = true;
|
||||
this.verticalRebarTypeComboBox.Location = new System.Drawing.Point(130, 21);
|
||||
this.verticalRebarTypeComboBox.Name = "verticalRebarTypeComboBox";
|
||||
this.verticalRebarTypeComboBox.Size = new System.Drawing.Size(171, 21);
|
||||
this.verticalRebarTypeComboBox.TabIndex = 4;
|
||||
//
|
||||
// centerTransverseRebarLabel
|
||||
//
|
||||
this.centerTransverseRebarLabel.AutoSize = true;
|
||||
this.centerTransverseRebarLabel.Location = new System.Drawing.Point(8, 92);
|
||||
this.centerTransverseRebarLabel.Name = "centerTransverseRebarLabel";
|
||||
this.centerTransverseRebarLabel.Size = new System.Drawing.Size(116, 13);
|
||||
this.centerTransverseRebarLabel.TabIndex = 3;
|
||||
this.centerTransverseRebarLabel.Text = "Center Transverse Bar:";
|
||||
//
|
||||
// endTranseverseRebarLabel
|
||||
//
|
||||
this.endTranseverseRebarLabel.AutoSize = true;
|
||||
this.endTranseverseRebarLabel.Location = new System.Drawing.Point(8, 58);
|
||||
this.endTranseverseRebarLabel.Name = "endTranseverseRebarLabel";
|
||||
this.endTranseverseRebarLabel.Size = new System.Drawing.Size(107, 13);
|
||||
this.endTranseverseRebarLabel.TabIndex = 2;
|
||||
this.endTranseverseRebarLabel.Text = "End Transverse Bar:";
|
||||
//
|
||||
// verticalRebarTypeLabel
|
||||
//
|
||||
this.verticalRebarTypeLabel.AutoSize = true;
|
||||
this.verticalRebarTypeLabel.Location = new System.Drawing.Point(8, 24);
|
||||
this.verticalRebarTypeLabel.Name = "verticalRebarTypeLabel";
|
||||
this.verticalRebarTypeLabel.Size = new System.Drawing.Size(64, 13);
|
||||
this.verticalRebarTypeLabel.TabIndex = 1;
|
||||
this.verticalRebarTypeLabel.Text = "Vertical Bar:";
|
||||
//
|
||||
// rebarSpacingGroupBox
|
||||
//
|
||||
this.rebarSpacingGroupBox.Controls.Add(this.centerRebarUnitLabel);
|
||||
this.rebarSpacingGroupBox.Controls.Add(this.endRebarUnitLabel);
|
||||
this.rebarSpacingGroupBox.Controls.Add(this.centerSpacingTextBox);
|
||||
this.rebarSpacingGroupBox.Controls.Add(this.endSpacingTextBox);
|
||||
this.rebarSpacingGroupBox.Controls.Add(this.centerSpacingLabel);
|
||||
this.rebarSpacingGroupBox.Controls.Add(this.endSpacingLabel);
|
||||
this.rebarSpacingGroupBox.Location = new System.Drawing.Point(10, 222);
|
||||
this.rebarSpacingGroupBox.Name = "rebarSpacingGroupBox";
|
||||
this.rebarSpacingGroupBox.Size = new System.Drawing.Size(307, 81);
|
||||
this.rebarSpacingGroupBox.TabIndex = 12;
|
||||
this.rebarSpacingGroupBox.TabStop = false;
|
||||
this.rebarSpacingGroupBox.Text = "Bar Spacing";
|
||||
//
|
||||
// centerRebarUnitLabel
|
||||
//
|
||||
this.centerRebarUnitLabel.AutoSize = true;
|
||||
this.centerRebarUnitLabel.Location = new System.Drawing.Point(273, 52);
|
||||
this.centerRebarUnitLabel.Name = "centerRebarUnitLabel";
|
||||
this.centerRebarUnitLabel.Size = new System.Drawing.Size(28, 13);
|
||||
this.centerRebarUnitLabel.TabIndex = 22;
|
||||
this.centerRebarUnitLabel.Text = "Feet";
|
||||
//
|
||||
// endRebarUnitLabel
|
||||
//
|
||||
this.endRebarUnitLabel.AutoSize = true;
|
||||
this.endRebarUnitLabel.Location = new System.Drawing.Point(273, 22);
|
||||
this.endRebarUnitLabel.Name = "endRebarUnitLabel";
|
||||
this.endRebarUnitLabel.Size = new System.Drawing.Size(28, 13);
|
||||
this.endRebarUnitLabel.TabIndex = 21;
|
||||
this.endRebarUnitLabel.Text = "Feet";
|
||||
//
|
||||
// centerSpacingTextBox
|
||||
//
|
||||
this.centerSpacingTextBox.Location = new System.Drawing.Point(130, 49);
|
||||
this.centerSpacingTextBox.Name = "centerSpacingTextBox";
|
||||
this.centerSpacingTextBox.Size = new System.Drawing.Size(140, 20);
|
||||
this.centerSpacingTextBox.TabIndex = 16;
|
||||
//
|
||||
// endSpacingTextBox
|
||||
//
|
||||
this.endSpacingTextBox.Location = new System.Drawing.Point(130, 19);
|
||||
this.endSpacingTextBox.Name = "endSpacingTextBox";
|
||||
this.endSpacingTextBox.Size = new System.Drawing.Size(140, 20);
|
||||
this.endSpacingTextBox.TabIndex = 15;
|
||||
//
|
||||
// centerSpacingLabel
|
||||
//
|
||||
this.centerSpacingLabel.AutoSize = true;
|
||||
this.centerSpacingLabel.Location = new System.Drawing.Point(8, 52);
|
||||
this.centerSpacingLabel.Name = "centerSpacingLabel";
|
||||
this.centerSpacingLabel.Size = new System.Drawing.Size(97, 13);
|
||||
this.centerSpacingLabel.TabIndex = 14;
|
||||
this.centerSpacingLabel.Text = "Transverse Center:";
|
||||
//
|
||||
// endSpacingLabel
|
||||
//
|
||||
this.endSpacingLabel.AutoSize = true;
|
||||
this.endSpacingLabel.Location = new System.Drawing.Point(8, 22);
|
||||
this.endSpacingLabel.Name = "endSpacingLabel";
|
||||
this.endSpacingLabel.Size = new System.Drawing.Size(85, 13);
|
||||
this.endSpacingLabel.TabIndex = 13;
|
||||
this.endSpacingLabel.Text = "Transverse End:";
|
||||
//
|
||||
// rebarQuantityLabel
|
||||
//
|
||||
this.rebarQuantityLabel.AutoSize = true;
|
||||
this.rebarQuantityLabel.Location = new System.Drawing.Point(18, 322);
|
||||
this.rebarQuantityLabel.Name = "rebarQuantityLabel";
|
||||
this.rebarQuantityLabel.Size = new System.Drawing.Size(118, 13);
|
||||
this.rebarQuantityLabel.TabIndex = 17;
|
||||
this.rebarQuantityLabel.Text = "Quantity of Vertical Bar:";
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(131, 359);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(90, 25);
|
||||
this.okButton.TabIndex = 19;
|
||||
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(227, 359);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(90, 25);
|
||||
this.cancelButton.TabIndex = 20;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// hookTypeGroupBox
|
||||
//
|
||||
this.hookTypeGroupBox.Controls.Add(this.transverseRebarHookComboBox);
|
||||
this.hookTypeGroupBox.Controls.Add(this.transverseRebarHookLabel);
|
||||
this.hookTypeGroupBox.Location = new System.Drawing.Point(10, 150);
|
||||
this.hookTypeGroupBox.Name = "hookTypeGroupBox";
|
||||
this.hookTypeGroupBox.Size = new System.Drawing.Size(307, 55);
|
||||
this.hookTypeGroupBox.TabIndex = 7;
|
||||
this.hookTypeGroupBox.TabStop = false;
|
||||
this.hookTypeGroupBox.Text = "Hook Type";
|
||||
//
|
||||
// transverseRebarHookComboBox
|
||||
//
|
||||
this.transverseRebarHookComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.transverseRebarHookComboBox.FormattingEnabled = true;
|
||||
this.transverseRebarHookComboBox.Location = new System.Drawing.Point(130, 20);
|
||||
this.transverseRebarHookComboBox.Name = "transverseRebarHookComboBox";
|
||||
this.transverseRebarHookComboBox.Size = new System.Drawing.Size(171, 21);
|
||||
this.transverseRebarHookComboBox.TabIndex = 11;
|
||||
//
|
||||
// transverseRebarHookLabel
|
||||
//
|
||||
this.transverseRebarHookLabel.AutoSize = true;
|
||||
this.transverseRebarHookLabel.Location = new System.Drawing.Point(8, 23);
|
||||
this.transverseRebarHookLabel.Name = "transverseRebarHookLabel";
|
||||
this.transverseRebarHookLabel.Size = new System.Drawing.Size(82, 13);
|
||||
this.transverseRebarHookLabel.TabIndex = 9;
|
||||
this.transverseRebarHookLabel.Text = "Transverse Bar:";
|
||||
//
|
||||
// rebarQuantityNumericUpDown
|
||||
//
|
||||
this.rebarQuantityNumericUpDown.Location = new System.Drawing.Point(140, 320);
|
||||
this.rebarQuantityNumericUpDown.Minimum = new decimal(new int[] {
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.rebarQuantityNumericUpDown.Name = "rebarQuantityNumericUpDown";
|
||||
this.rebarQuantityNumericUpDown.Size = new System.Drawing.Size(171, 20);
|
||||
this.rebarQuantityNumericUpDown.TabIndex = 18;
|
||||
this.rebarQuantityNumericUpDown.Value = new decimal(new int[] {
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// ColumnFramReinMakerForm
|
||||
//
|
||||
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, 393);
|
||||
this.Controls.Add(this.rebarQuantityNumericUpDown);
|
||||
this.Controls.Add(this.hookTypeGroupBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.rebarSpacingGroupBox);
|
||||
this.Controls.Add(this.rebarTypesGroupBox);
|
||||
this.Controls.Add(this.rebarQuantityLabel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ColumnFramReinMakerForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Column Reinforcement";
|
||||
this.rebarTypesGroupBox.ResumeLayout(false);
|
||||
this.rebarTypesGroupBox.PerformLayout();
|
||||
this.rebarSpacingGroupBox.ResumeLayout(false);
|
||||
this.rebarSpacingGroupBox.PerformLayout();
|
||||
this.hookTypeGroupBox.ResumeLayout(false);
|
||||
this.hookTypeGroupBox.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.rebarQuantityNumericUpDown)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox rebarTypesGroupBox;
|
||||
private System.Windows.Forms.GroupBox rebarSpacingGroupBox;
|
||||
private System.Windows.Forms.Label centerTransverseRebarLabel;
|
||||
private System.Windows.Forms.Label endTranseverseRebarLabel;
|
||||
private System.Windows.Forms.Label verticalRebarTypeLabel;
|
||||
private System.Windows.Forms.ComboBox verticalRebarTypeComboBox;
|
||||
private System.Windows.Forms.ComboBox centerTransverseRebarTypeComboBox;
|
||||
private System.Windows.Forms.ComboBox endTransverseRebarTypeComboBox;
|
||||
private System.Windows.Forms.Label centerSpacingLabel;
|
||||
private System.Windows.Forms.Label endSpacingLabel;
|
||||
private System.Windows.Forms.TextBox centerSpacingTextBox;
|
||||
private System.Windows.Forms.TextBox endSpacingTextBox;
|
||||
private System.Windows.Forms.Label rebarQuantityLabel;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.GroupBox hookTypeGroupBox;
|
||||
private System.Windows.Forms.ComboBox transverseRebarHookComboBox;
|
||||
private System.Windows.Forms.Label transverseRebarHookLabel;
|
||||
private System.Windows.Forms.Label centerRebarUnitLabel;
|
||||
private System.Windows.Forms.Label endRebarUnitLabel;
|
||||
private System.Windows.Forms.NumericUpDown rebarQuantityNumericUpDown;
|
||||
}
|
||||
}
|
||||
@@ -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.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The form is used for collecting information of column reinforcement creation
|
||||
/// </summary>
|
||||
public partial class ColumnFramReinMakerForm : System.Windows.Forms.Form
|
||||
{
|
||||
// Private members
|
||||
ColumnFramReinMaker m_dataBuffer = null;
|
||||
|
||||
/// <summary>
|
||||
/// constructor for ColumnFramReinMakerForm
|
||||
/// </summary>
|
||||
/// <param name="dataBuffer">the ColumnFramReinMaker reference</param>
|
||||
public ColumnFramReinMakerForm(ColumnFramReinMaker dataBuffer)
|
||||
{
|
||||
// Required for Windows Form Designer support
|
||||
InitializeComponent();
|
||||
|
||||
// Store the reference of ColumnFramReinMaker
|
||||
m_dataBuffer = dataBuffer;
|
||||
|
||||
// Bing the data source for all combo boxes
|
||||
BingingDataSource();
|
||||
|
||||
// set the initializtion data of the spacing
|
||||
centerSpacingTextBox.Text = 0.1.ToString("0.0");
|
||||
endSpacingTextBox.Text = 0.1.ToString("0.0");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bing the data source for all combo boxes
|
||||
/// </summary>
|
||||
private void BingingDataSource()
|
||||
{
|
||||
// bind the verticalRebarTypeComboBox
|
||||
verticalRebarTypeComboBox.DataSource = m_dataBuffer.RebarTypes;
|
||||
verticalRebarTypeComboBox.DisplayMember = "Name";
|
||||
|
||||
// bind the centerTransverseRebarTypeComboBox
|
||||
centerTransverseRebarTypeComboBox.DataSource = m_dataBuffer.RebarTypes;
|
||||
centerTransverseRebarTypeComboBox.DisplayMember = "Name";
|
||||
|
||||
// bind the endTransverseRebarTypeComboBox
|
||||
endTransverseRebarTypeComboBox.DataSource = m_dataBuffer.RebarTypes;
|
||||
endTransverseRebarTypeComboBox.DisplayMember = "Name";
|
||||
|
||||
// bind the transverseRebarHookComboBox
|
||||
transverseRebarHookComboBox.DataSource = m_dataBuffer.HookTypes;
|
||||
transverseRebarHookComboBox.DisplayMember = "Name";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the user click ok, refresh the data of BeamFramReinMaker and close form
|
||||
/// </summary>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// set TransverseCenterType data
|
||||
RebarBarType type = centerTransverseRebarTypeComboBox.SelectedItem as RebarBarType;
|
||||
m_dataBuffer.TransverseCenterType = type;
|
||||
|
||||
// set TransverseEndType data
|
||||
type = endTransverseRebarTypeComboBox.SelectedItem as RebarBarType;
|
||||
m_dataBuffer.TransverseEndType = type;
|
||||
|
||||
// set VerticalRebarType data
|
||||
type = verticalRebarTypeComboBox.SelectedItem as RebarBarType;
|
||||
m_dataBuffer.VerticalRebarType = type;
|
||||
|
||||
// set TransverseHookType data
|
||||
RebarHookType hookType = transverseRebarHookComboBox.SelectedItem as RebarHookType;
|
||||
m_dataBuffer.TransverseHookType = hookType;
|
||||
|
||||
// set VerticalRebarNumber data
|
||||
int number = (int)rebarQuantityNumericUpDown.Value;
|
||||
m_dataBuffer.VerticalRebarNumber = number;
|
||||
|
||||
try
|
||||
{
|
||||
// set TransverseCenterSpacing data
|
||||
double spacing = Convert.ToDouble(centerSpacingTextBox.Text);
|
||||
m_dataBuffer.TransverseCenterSpacing = spacing;
|
||||
|
||||
// set TransverseEndSpacing data
|
||||
spacing = Convert.ToDouble(endSpacingTextBox.Text);
|
||||
m_dataBuffer.TransverseEndSpacing = spacing;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
// spacing text boxes should only input number information
|
||||
TaskDialog.Show("Revit", "Please input double number in spacing TextBox.");
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// if other unexpected error, just show the information
|
||||
TaskDialog.Show("Revit", ex.Message);
|
||||
}
|
||||
|
||||
this.DialogResult = DialogResult.OK; // set dialog result
|
||||
this.Close(); // close the form
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// When the user click the cancel, just close the form
|
||||
/// </summary>
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;// set dialog result
|
||||
this.Close(); // close the form
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,225 @@
|
||||
//
|
||||
// (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;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The geometry support for reinforcement creation on conlumn.
|
||||
/// It can prepare the geometry information for transverse and vertical rebar creation
|
||||
/// </summary>
|
||||
class ColumnGeometrySupport : GeometrySupport
|
||||
{
|
||||
// Private members
|
||||
double m_columnLength; //the length of the column
|
||||
double m_columnWidth; //the width of the column
|
||||
double m_columnHeight; //the height of the column
|
||||
|
||||
/// <summary>
|
||||
/// constructor for the ColumnGeometrySupport
|
||||
/// </summary>
|
||||
/// <param name="element">the column which the rebars are placed on</param>
|
||||
/// <param name="geoOptions">the geometry option</param>
|
||||
public ColumnGeometrySupport(FamilyInstance element, Options geoOptions)
|
||||
: base(element, geoOptions)
|
||||
{
|
||||
// assert the host element is a column
|
||||
if (!element.StructuralType.Equals(StructuralType.Column))
|
||||
{
|
||||
throw new Exception("ColumnGeometrySupport can only work for column instance.");
|
||||
}
|
||||
|
||||
// Get the length, width and height of the column.
|
||||
m_columnHeight = GetDrivingLineLength();
|
||||
m_columnLength = GetColumnLength();
|
||||
m_columnWidth = GetColumnWidth();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the geometry information of the transverse rebar
|
||||
/// </summary>
|
||||
/// <param name="location">the location of transverse rebar</param>
|
||||
/// <param name="spacing">the spacing value of the rebar</param>
|
||||
/// <returns>the gotted geometry information</returns>
|
||||
public RebarGeometry GetTransverseRebar(TransverseRebarLocation location, double spacing)
|
||||
{
|
||||
// sort the points of the swept profile
|
||||
XYZHeightComparer comparer = new XYZHeightComparer();
|
||||
m_points.Sort(comparer);
|
||||
|
||||
// the offset from the column surface to the rebar
|
||||
double offset = ColumnRebarData.TransverseOffset;
|
||||
//the length of the transverse rebar
|
||||
double rebarLength = 0;
|
||||
|
||||
// get the origin and normal parameter for rebar creation
|
||||
Autodesk.Revit.DB.XYZ normal = m_drivingVector;
|
||||
double curveOffset = 0;
|
||||
|
||||
//set rebar length and origin according to the location of rebar
|
||||
switch (location)
|
||||
{
|
||||
case TransverseRebarLocation.Start: // start transverse rebar
|
||||
rebarLength = m_columnHeight / 4;
|
||||
break;
|
||||
case TransverseRebarLocation.Center: // center transverse rebar
|
||||
rebarLength = m_columnHeight / 2;
|
||||
curveOffset = m_columnHeight / 4 + (rebarLength % spacing) / 2;
|
||||
break;
|
||||
case TransverseRebarLocation.End: // end transverse rebar
|
||||
rebarLength = m_columnHeight / 4;
|
||||
curveOffset = m_columnHeight - rebarLength + (rebarLength % spacing);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("The program should never go here.");
|
||||
}
|
||||
|
||||
// the number of the transverse rebar
|
||||
int rebarNumber = (int)(rebarLength / spacing) + 1;
|
||||
// get the profile of the transverse rebar
|
||||
List<Autodesk.Revit.DB.XYZ> movedPoints = OffsetPoints(offset);
|
||||
|
||||
List<Autodesk.Revit.DB.XYZ> translatedPoints = new List<Autodesk.Revit.DB.XYZ>();
|
||||
foreach (Autodesk.Revit.DB.XYZ point in movedPoints)
|
||||
{
|
||||
translatedPoints.Add(GeomUtil.OffsetPoint(point, m_drivingVector, curveOffset));
|
||||
}
|
||||
|
||||
IList<Curve> curves = new List<Curve>(); //the profile of the transverse rebar
|
||||
Autodesk.Revit.DB.XYZ first = translatedPoints[0];
|
||||
Autodesk.Revit.DB.XYZ second = translatedPoints[1];
|
||||
Autodesk.Revit.DB.XYZ third = translatedPoints[2];
|
||||
Autodesk.Revit.DB.XYZ fourth = translatedPoints[3];
|
||||
curves.Add(Line.CreateBound(first, second));
|
||||
curves.Add(Line.CreateBound(second, fourth));
|
||||
curves.Add(Line.CreateBound(fourth, third));
|
||||
curves.Add(Line.CreateBound(third, first));
|
||||
|
||||
// return the rebar geometry information
|
||||
return new RebarGeometry(normal, curves, rebarNumber, spacing);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the geometry information of vertical rebar
|
||||
/// </summary>
|
||||
/// <param name="location">the location of vertical rebar</param>
|
||||
/// <param name="rebarNumber">the spacing value of the rebar</param>
|
||||
/// <returns>the gotted geometry information</returns>
|
||||
public RebarGeometry GetVerticalRebar(VerticalRebarLocation location, int rebarNumber)
|
||||
{
|
||||
// sort the points of the swept profile
|
||||
XYZHeightComparer comparer = new XYZHeightComparer();
|
||||
m_points.Sort(comparer);
|
||||
|
||||
// Get the offset and rebar length of rebar
|
||||
double offset = ColumnRebarData.VerticalOffset;
|
||||
double rebarLength = m_columnHeight + 3; //the length of rebar
|
||||
|
||||
// Get the start point of the vertical rebar curve
|
||||
Autodesk.Revit.DB.XYZ startPoint = m_drivingLine.GetEndPoint(0);
|
||||
|
||||
List<Autodesk.Revit.DB.XYZ> movedPoints = OffsetPoints(offset);
|
||||
movedPoints.Sort(comparer);
|
||||
|
||||
Autodesk.Revit.DB.XYZ normal = new Autodesk.Revit.DB.XYZ(); // the normal parameter
|
||||
double rebarOffset = 0; // rebar offset, equal to rebarNumber* spacing
|
||||
// get the normal, start point and rebar offset of vertical rebar
|
||||
switch (location)
|
||||
{
|
||||
case VerticalRebarLocation.East: //vertical rebar in east
|
||||
normal = new Autodesk.Revit.DB.XYZ(0, 1, 0);
|
||||
rebarOffset = m_columnWidth - 2 * offset;
|
||||
startPoint = movedPoints[1];
|
||||
break;
|
||||
case VerticalRebarLocation.North: //vertical rebar in north
|
||||
normal = new Autodesk.Revit.DB.XYZ(-1, 0, 0);
|
||||
rebarOffset = m_columnLength - 2 * offset;
|
||||
startPoint = movedPoints[3];
|
||||
break;
|
||||
case VerticalRebarLocation.West: //vertical rebar in west
|
||||
normal = new Autodesk.Revit.DB.XYZ(0, -1, 0);
|
||||
rebarOffset = m_columnWidth - 2 * offset;
|
||||
startPoint = movedPoints[2];
|
||||
break;
|
||||
case VerticalRebarLocation.South: //vertical rebar in south
|
||||
normal = new Autodesk.Revit.DB.XYZ(1, 0, 0);
|
||||
rebarOffset = m_columnLength - 2 * offset;
|
||||
startPoint = movedPoints[0];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
double spacing = rebarOffset / rebarNumber; //spacing value of the rebar
|
||||
Autodesk.Revit.DB.XYZ endPoint = GeomUtil.OffsetPoint(startPoint, m_drivingVector, rebarLength);
|
||||
|
||||
IList<Curve> curves = new List<Curve>(); //profile of the rebar
|
||||
curves.Add(Line.CreateBound(startPoint, endPoint));
|
||||
|
||||
// return the rebar geometry information
|
||||
return new RebarGeometry(normal, curves, rebarNumber, spacing);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the length of the column
|
||||
/// </summary>
|
||||
/// <returns>the length data</returns>
|
||||
private double GetColumnLength()
|
||||
{
|
||||
XYZHeightComparer comparer = new XYZHeightComparer();
|
||||
m_points.Sort(comparer);
|
||||
|
||||
Autodesk.Revit.DB.XYZ refPoint = m_points[0];
|
||||
List<Autodesk.Revit.DB.XYZ> directions = GetRelatedVectors(refPoint);
|
||||
directions.Sort(comparer);
|
||||
|
||||
return GeomUtil.GetLength(directions[0]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the width of the column
|
||||
/// </summary>
|
||||
/// <returns>the width data</returns>
|
||||
private double GetColumnWidth()
|
||||
{
|
||||
XYZHeightComparer comparer = new XYZHeightComparer();
|
||||
m_points.Sort(comparer);
|
||||
|
||||
Autodesk.Revit.DB.XYZ refPoint = m_points[0];
|
||||
List<Autodesk.Revit.DB.XYZ> directions = GetRelatedVectors(refPoint);
|
||||
directions.Sort(comparer);
|
||||
|
||||
return GeomUtil.GetLength(directions[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// (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.UI;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The entrance of this example, which create reinforcement rebars on
|
||||
/// the selected concrete beam and column without reinforcement.
|
||||
/// </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(ExternalCommandData commandData,
|
||||
ref string message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
Transaction transaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "External Tool");
|
||||
try
|
||||
{
|
||||
transaction.Start();
|
||||
// create a factory to create the corresponding FrameReinMaker
|
||||
FrameReinMakerFactory factory = new FrameReinMakerFactory(commandData);
|
||||
|
||||
// Do some data checks, such whether the user select concrete beam or column
|
||||
if (!factory.AssertData())
|
||||
{
|
||||
message = "Please select a concrete beam or column without reinforcement.";
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
|
||||
// Invoke work() method to create corresponding FrameReinMaker,
|
||||
// and create the reinforcement rebars
|
||||
factory.work();
|
||||
|
||||
// if everything goes well, return succeeded.
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
finally
|
||||
{
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
//
|
||||
// (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.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The interface for the family instance reinforcement creation.
|
||||
/// The main method is Run(), which used to create the reinforcement
|
||||
/// </summary>
|
||||
public interface IFrameReinMaker
|
||||
{
|
||||
/// <summary>
|
||||
/// Main function of Maker interface
|
||||
/// </summary>
|
||||
/// <returns>indicate the result of run</returns>
|
||||
bool Run();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The base class for family instance reinforcement creation.
|
||||
/// It only implement the Run() method. which give the flow process for creation.
|
||||
/// </summary>
|
||||
public class FramReinMaker : IFrameReinMaker
|
||||
{
|
||||
/// <summary>
|
||||
/// the API create handle
|
||||
/// </summary>
|
||||
protected Autodesk.Revit.DB.Document m_revitDoc;
|
||||
|
||||
/// <summary>
|
||||
/// the family instance to places rebar on
|
||||
/// </summary>
|
||||
protected FamilyInstance m_hostObject;
|
||||
|
||||
/// <summary>
|
||||
/// a set to store all the rebar types
|
||||
/// </summary>
|
||||
protected List<RebarBarType> m_rebarTypes = new List<RebarBarType>();
|
||||
|
||||
/// <summary>
|
||||
/// a list to store all the hook types
|
||||
/// </summary>
|
||||
protected List<RebarHookType> m_hookTypes = new List<RebarHookType>();
|
||||
|
||||
/// <summary>
|
||||
/// Show all the rebar types in revit
|
||||
/// </summary>
|
||||
public IList<RebarBarType> RebarTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_rebarTypes;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show all the rebar hook types in revit
|
||||
/// </summary>
|
||||
public IList<RebarHookType> HookTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_hookTypes;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement the Run() method of IFrameReinMaker interface.
|
||||
/// Give the flew process of the reinforcement creation.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IFrameReinMaker.Run()
|
||||
{
|
||||
// First, check the data whether is right and enough.
|
||||
if (!AssertData())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Second, show a form to the user to collect creation information
|
||||
if (!DisplayForm())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// At last, begin to create the reinforcement rebars
|
||||
if (!FillWithBars())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This is a virtual method which used to check the data whether is right and enough.
|
||||
/// </summary>
|
||||
/// <returns>true if the the data is right and enough, otherwise false.</returns>
|
||||
protected virtual bool AssertData()
|
||||
{
|
||||
return true; // only return true
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is a virtual method which used to collect creation information
|
||||
/// </summary>
|
||||
/// <returns>true if the informatin collection is successful, otherwise false</returns>
|
||||
protected virtual bool DisplayForm()
|
||||
{
|
||||
return true; // only return true
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This is a virtual method which used to create reinforcement.
|
||||
/// </summary>
|
||||
/// <returns>true if the creation is successful, otherwise false</returns>
|
||||
protected virtual bool FillWithBars()
|
||||
{
|
||||
return true; // only return true
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor of FramReinMaker
|
||||
/// </summary>
|
||||
/// <param name="commandData">the ExternalCommandData reference</param>
|
||||
/// <param name="hostObject">the host family instance</param>
|
||||
protected FramReinMaker(ExternalCommandData commandData, FamilyInstance hostObject)
|
||||
{
|
||||
// Get and store reinforcement create handle and host family instance
|
||||
m_revitDoc = commandData.Application.ActiveUIDocument.Document;
|
||||
m_hostObject = hostObject;
|
||||
|
||||
// Get all the rebar types in revit
|
||||
if (!GetRebarTypes(commandData))
|
||||
{
|
||||
throw new Exception("Can't get any rebar type from revit.");
|
||||
}
|
||||
|
||||
// Get all the rebar hook types in revit
|
||||
if (!GetHookTypes(commandData))
|
||||
{
|
||||
throw new Exception("Can't get any rebar hook type from revit.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The helper function to changed rebar number and spacing properties
|
||||
/// </summary>
|
||||
/// <param name="bar">The rebar instance which need to modify</param>
|
||||
/// <param name="number">The rebar number want to set</param>
|
||||
/// <param name="spacing">The spacing want to set</param>
|
||||
protected static void SetRebarSpaceAndNumber(Rebar bar, int number, double spacing)
|
||||
{
|
||||
// Asset the parameter is valid
|
||||
if (null == bar || 2 > number || 0 > spacing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Change the rebar number and spacing properties
|
||||
bar.GetShapeDrivenAccessor().SetLayoutAsNumberWithSpacing(number, spacing, true, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A wrap fuction which used to create the reinforcement.
|
||||
/// </summary>
|
||||
/// <param name="rebarType">The element of RebarBarType</param>
|
||||
/// <param name="startHook">The element of start RebarHookType</param>
|
||||
/// <param name="endHook">The element of end RebarHookType</param>
|
||||
/// <param name="geomInfo">The goemetry information of the rebar</param>
|
||||
/// <param name="startOrient">An Integer defines the orientation of the start hook</param>
|
||||
/// <param name="endOrient">An Integer defines the orientation of the end hook</param>
|
||||
/// <returns></returns>
|
||||
protected Rebar PlaceRebars(RebarBarType rebarType, RebarHookType startHook,
|
||||
RebarHookType endHook, RebarGeometry geomInfo,
|
||||
RebarHookOrientation startOrient, RebarHookOrientation endOrient)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ normal = geomInfo.Normal; // the direction of rebar distribution
|
||||
IList<Curve> curves = geomInfo.Curves; // the shape of the rebar curves
|
||||
|
||||
// Invoke the NewRebar() method to create rebar
|
||||
Rebar createdRebar = Rebar.CreateFromCurves(m_revitDoc, Autodesk.Revit.DB.Structure.RebarStyle.Standard, rebarType, startHook, endHook,
|
||||
m_hostObject, normal, curves,
|
||||
startOrient, endOrient, false, true);
|
||||
|
||||
if (null == createdRebar) // Assert the creation is successful
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Change the rebar number and spacing properties to the user wanted
|
||||
SetRebarSpaceAndNumber(createdRebar, geomInfo.RebarNumber, geomInfo.RebarSpacing);
|
||||
return createdRebar;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get all the hook types in current project, and store in m_hookTypes data
|
||||
/// </summary>
|
||||
/// <param name="commandData">the ExternalCommandData reference</param>
|
||||
/// <returns>true if some hook types can be gotton, otherwise false</returns>
|
||||
private bool GetHookTypes(ExternalCommandData commandData)
|
||||
{
|
||||
// Initialize the m_hookTypes which used to store all hook types.
|
||||
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document);
|
||||
filteredElementCollector.OfClass(typeof(RebarHookType));
|
||||
m_hookTypes = filteredElementCollector.Cast<RebarHookType>().ToList<RebarHookType>();
|
||||
|
||||
// If no hook types in revit return false, otherwise true
|
||||
return (0 == m_hookTypes.Count) ? false : true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get all the rebar types in current project, and store in m_rebarTypes data
|
||||
/// </summary>
|
||||
/// <param name="commandData">the ExternalCommandData reference</param>
|
||||
/// <returns>true if some rebar types can be gotton, otherwise false</returns>
|
||||
private bool GetRebarTypes(ExternalCommandData commandData)
|
||||
{
|
||||
// Initialize the m_rebarTypes which used to store all rebar types.
|
||||
// Get all rebar types in revit and add them in m_rebarTypes
|
||||
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document);
|
||||
filteredElementCollector.OfClass(typeof(RebarBarType));
|
||||
m_rebarTypes = filteredElementCollector.Cast<RebarBarType>().ToList<RebarBarType>();
|
||||
|
||||
// If no rebar types in revit return false, otherwise true
|
||||
return (0 == m_rebarTypes.Count) ? false : true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
//
|
||||
// (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;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The factory to create the corresponding FrameReinMaker, such as BeamFramReinMaker.
|
||||
/// </summary>
|
||||
class FrameReinMakerFactory
|
||||
{
|
||||
// Private members
|
||||
ExternalCommandData m_commandData; // the ExternalCommandData reference
|
||||
FamilyInstance m_hostObject; // the host object
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="commandData">the ExternalCommandData reference</param>
|
||||
public FrameReinMakerFactory(ExternalCommandData commandData)
|
||||
{
|
||||
m_commandData = commandData;
|
||||
|
||||
if (!GetHostObject())
|
||||
{
|
||||
throw new Exception("Please select a beam or column.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// check the condition of host object and see whether the rebars can be placed on
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool AssertData()
|
||||
{
|
||||
// judge whether is any rebar exist in the beam or column
|
||||
if (new FilteredElementCollector(m_commandData.Application.ActiveUIDocument.Document)
|
||||
.OfClass(typeof(Rebar))
|
||||
.Cast<Rebar>()
|
||||
.Where(x => x.GetHostId().IntegerValue == m_hostObject.Id.IntegerValue).Count() > 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The main method which create the corresponding FrameReinMaker according to
|
||||
/// the host object type, and invoke Run() method to create reinforcement rebars
|
||||
/// </summary>
|
||||
/// <returns>true if the creation is successful, otherwise false</returns>
|
||||
public bool work()
|
||||
{
|
||||
// define an IFrameReinMaker interface to create reinforcement rebars
|
||||
IFrameReinMaker maker = null;
|
||||
|
||||
// create FrameReinMaker instance according to host object type
|
||||
switch (m_hostObject.StructuralType)
|
||||
{
|
||||
case StructuralType.Beam: // if host object is a beam
|
||||
maker = new BeamFramReinMaker(m_commandData, m_hostObject);
|
||||
break;
|
||||
case StructuralType.Column: // if host object is a column
|
||||
maker = new ColumnFramReinMaker(m_commandData, m_hostObject);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// invoke Run() method to do the reinforcement creation
|
||||
maker.Run();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the selected element as the host object, also check if the selected element is expected host object
|
||||
/// </summary>
|
||||
/// <returns>true if get the selected element, otherwise false.</returns>
|
||||
private bool GetHostObject()
|
||||
{
|
||||
List<ElementId> selectedIds = new List<ElementId>();
|
||||
foreach (Autodesk.Revit.DB.ElementId elemId in m_commandData.Application.ActiveUIDocument.Selection.GetElementIds())
|
||||
{
|
||||
Autodesk.Revit.DB.Element elem = m_commandData.Application.ActiveUIDocument.Document.GetElement(elemId);
|
||||
selectedIds.Add(elem.Id);
|
||||
}
|
||||
if (selectedIds.Count != 1)
|
||||
return false;
|
||||
//
|
||||
// Construct filters to find expected host object:
|
||||
// . Host should be Beam/Column structural type.
|
||||
// . and it's material type should be Concrete
|
||||
// . and it should be FamilyInstance
|
||||
//
|
||||
// Structural type filters firstly
|
||||
LogicalOrFilter stFilter = new LogicalOrFilter(
|
||||
new ElementStructuralTypeFilter(StructuralType.Beam),
|
||||
new ElementStructuralTypeFilter(StructuralType.Column));
|
||||
// StructuralMaterialType should be Concrete
|
||||
LogicalAndFilter hostFilter = new LogicalAndFilter(stFilter,
|
||||
new StructuralMaterialTypeFilter(StructuralMaterialType.Concrete));
|
||||
//
|
||||
// Expected host object
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_commandData.Application.ActiveUIDocument.Document, selectedIds);
|
||||
m_hostObject = collector
|
||||
.OfClass(typeof(FamilyInstance)) // FamilyInstance
|
||||
.WherePasses(hostFilter) // Filters
|
||||
.FirstElement() as FamilyInstance;
|
||||
return (null != m_hostObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
//
|
||||
// (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.Reinforcement.CS
|
||||
{
|
||||
#region Struct Definition
|
||||
|
||||
/// <summary>
|
||||
/// a struct to store the geometry information of the rebar
|
||||
/// </summary>
|
||||
public struct RebarGeometry
|
||||
{
|
||||
// Private members
|
||||
Autodesk.Revit.DB.XYZ m_normal; // the direction of rebar distribution
|
||||
IList<Curve> m_curves; //the profile of the rebar
|
||||
int m_number; //the number of the rebar
|
||||
double m_spacing; //the spacing of the rebar
|
||||
|
||||
/// <summary>
|
||||
/// get and set the value of the normal
|
||||
/// </summary>
|
||||
public Autodesk.Revit.DB.XYZ Normal
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_normal;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_normal = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the value of curve array
|
||||
/// </summary>
|
||||
public IList<Curve> Curves
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_curves;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_curves = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the number of the rebar
|
||||
/// </summary>
|
||||
public int RebarNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_number;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_number = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get and set the value of the rebar spacing
|
||||
/// </summary>
|
||||
public double RebarSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_spacing;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_spacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// consturctor
|
||||
/// </summary>
|
||||
/// <param name="normal">the normal information</param>
|
||||
/// <param name="curves">the profile of the rebars</param>
|
||||
/// <param name="number">the number of the rebar</param>
|
||||
/// <param name="spacing">the number of the rebar</param>
|
||||
public RebarGeometry(Autodesk.Revit.DB.XYZ normal, IList<Curve> curves, int number, double spacing)
|
||||
{
|
||||
// initialize the data members
|
||||
m_normal = normal;
|
||||
m_curves = curves;
|
||||
m_number = number;
|
||||
m_spacing = spacing;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A struct to store the const data which support beam reinforcement creation
|
||||
/// </summary>
|
||||
public struct BeamRebarData
|
||||
{
|
||||
/// <summary>
|
||||
/// offset value of the top end rebar
|
||||
/// </summary>
|
||||
public const double TopEndOffset = 0.2;
|
||||
|
||||
/// <summary>
|
||||
///offset value of the top center rebar
|
||||
/// </summary>
|
||||
public const double TopCenterOffset = 0.23;
|
||||
|
||||
/// <summary>
|
||||
/// offset value of the transverse rebar
|
||||
/// </summary>
|
||||
public const double TransverseOffset = 0.125;
|
||||
|
||||
/// <summary>
|
||||
/// offset value of the end transverse rebar
|
||||
/// </summary>
|
||||
public const double TransverseEndOffset = 1.2;
|
||||
|
||||
/// <summary>
|
||||
/// the spacing value between end and center transvers rebar
|
||||
/// </summary>
|
||||
public const double TransverseSpaceBetween = 1;
|
||||
|
||||
/// <summary>
|
||||
///offset value of bottom rebar
|
||||
/// </summary>
|
||||
public const double BottomOffset = 0.271;
|
||||
|
||||
/// <summary>
|
||||
/// number of bottom rebar
|
||||
/// </summary>
|
||||
public const int BottomRebarNumber = 5;
|
||||
|
||||
/// <summary>
|
||||
/// number of top rebar
|
||||
/// </summary>
|
||||
public const int TopRebarNumber = 2;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A struct to store the const data which support column reinforcement creation
|
||||
/// </summary>
|
||||
public struct ColumnRebarData
|
||||
{
|
||||
/// <summary>
|
||||
/// offset value of transverse rebar
|
||||
/// </summary>
|
||||
public const double TransverseOffset = 0.125;
|
||||
|
||||
/// <summary>
|
||||
/// offset value of vertical rebar
|
||||
/// </summary>
|
||||
public const double VerticalOffset = 0.234;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enum Definition
|
||||
/// <summary>
|
||||
/// Indicate location of top rebar
|
||||
/// </summary>
|
||||
public enum TopRebarLocation
|
||||
{
|
||||
/// <summary>
|
||||
/// locate start
|
||||
/// </summary>
|
||||
Start,
|
||||
|
||||
/// <summary>
|
||||
/// locate center
|
||||
/// </summary>
|
||||
Center,
|
||||
|
||||
/// <summary>
|
||||
/// locate end
|
||||
/// </summary>
|
||||
End
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicate location of transverse rebar
|
||||
/// </summary>
|
||||
public enum TransverseRebarLocation
|
||||
{
|
||||
/// <summary>
|
||||
/// locate start
|
||||
/// </summary>
|
||||
Start,
|
||||
|
||||
/// <summary>
|
||||
/// locate center
|
||||
/// </summary>
|
||||
Center,
|
||||
|
||||
/// <summary>
|
||||
/// locate end
|
||||
/// </summary>
|
||||
End
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicate location of vertical rebar
|
||||
/// </summary>
|
||||
public enum VerticalRebarLocation
|
||||
{
|
||||
/// <summary>
|
||||
/// locate north
|
||||
/// </summary>
|
||||
North,
|
||||
|
||||
/// <summary>
|
||||
/// locate east
|
||||
/// </summary>
|
||||
East,
|
||||
|
||||
/// <summary>
|
||||
/// locate south
|
||||
/// </summary>
|
||||
South,
|
||||
|
||||
/// <summary>
|
||||
/// locate west
|
||||
/// </summary>
|
||||
West
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// A comparer for XYZ, and give a method to sort all the Autodesk.Revit.DB.XYZ points in a array
|
||||
/// </summary>
|
||||
public class XYZHeightComparer : IComparer<Autodesk.Revit.DB.XYZ>
|
||||
{
|
||||
int IComparer<Autodesk.Revit.DB.XYZ>.Compare(Autodesk.Revit.DB.XYZ first, Autodesk.Revit.DB.XYZ second)
|
||||
{
|
||||
// first compare z coordinate, then y coordinate, at last x coordinate
|
||||
if (GeomUtil.IsEqual(first.Z, second.Z))
|
||||
{
|
||||
if (GeomUtil.IsEqual(first.Y, second.Y))
|
||||
{
|
||||
if (GeomUtil.IsEqual(first.X, second.X))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return (first.X > second.X) ? 1 : -1;
|
||||
}
|
||||
return (first.Y > second.Y) ? 1 : -1;
|
||||
}
|
||||
return (first.Z > second.Z) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
//
|
||||
// (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.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
using GeoElement = Autodesk.Revit.DB.GeometryElement;
|
||||
using Element = Autodesk.Revit.DB.Element;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The class which give the base geometry operation, it is a static class.
|
||||
/// </summary>
|
||||
static class GeomUtil
|
||||
{
|
||||
// Private members
|
||||
const double Precision = 0.00001; //precision when judge whether two doubles are equal
|
||||
|
||||
/// <summary>
|
||||
/// Judge whether the two double data are equal
|
||||
/// </summary>
|
||||
/// <param name="d1">The first double data</param>
|
||||
/// <param name="d2">The second double data</param>
|
||||
/// <returns>true if two double data is equal, otherwise false</returns>
|
||||
public static bool IsEqual(double d1, double d2)
|
||||
{
|
||||
//get the absolute value;
|
||||
double diff = Math.Abs(d1 - d2);
|
||||
return diff < Precision;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Judge whether the two Autodesk.Revit.DB.XYZ point are equal
|
||||
/// </summary>
|
||||
/// <param name="first">The first Autodesk.Revit.DB.XYZ point</param>
|
||||
/// <param name="second">The second Autodesk.Revit.DB.XYZ point</param>
|
||||
/// <returns>true if two Autodesk.Revit.DB.XYZ point is equal, otherwise false</returns>
|
||||
public static bool IsEqual(Autodesk.Revit.DB.XYZ first, Autodesk.Revit.DB.XYZ second)
|
||||
{
|
||||
bool flag = true;
|
||||
flag = flag && IsEqual(first.X, second.X);
|
||||
flag = flag && IsEqual(first.Y, second.Y);
|
||||
flag = flag && IsEqual(first.Z, second.Z);
|
||||
return flag;
|
||||
}
|
||||
|
||||
/// <param name="face"></param>
|
||||
/// <param name="line"></param>
|
||||
/// <returns>return true when line is perpendicular to the face</returns>
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Judge whether the line is perpendicular to the face
|
||||
/// </summary>
|
||||
/// <param name="face">the face reference</param>
|
||||
/// <param name="line">the line reference</param>
|
||||
/// <param name="faceTrans">the transform for the face</param>
|
||||
/// <param name="lineTrans">the transform for the line</param>
|
||||
/// <returns>true if line is perpendicular to the face, otherwise false</returns>
|
||||
public static bool IsVertical(Face face, Line line,
|
||||
Transform faceTrans, Transform lineTrans)
|
||||
{
|
||||
//get points which the face contains
|
||||
List<XYZ> points = face.Triangulate().Vertices as List<XYZ>;
|
||||
if (3 > points.Count) // face's point number should be above 2
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// get three points from the face points
|
||||
Autodesk.Revit.DB.XYZ first = points[0];
|
||||
Autodesk.Revit.DB.XYZ second = points[1];
|
||||
Autodesk.Revit.DB.XYZ third = points[2];
|
||||
|
||||
// get start and end point of line
|
||||
Autodesk.Revit.DB.XYZ lineStart = line.GetEndPoint(0);
|
||||
Autodesk.Revit.DB.XYZ lineEnd = line.GetEndPoint(1);
|
||||
|
||||
// transForm the three points if necessary
|
||||
if (null != faceTrans)
|
||||
{
|
||||
first = TransformPoint(first, faceTrans);
|
||||
second = TransformPoint(second, faceTrans);
|
||||
third = TransformPoint(third, faceTrans);
|
||||
}
|
||||
|
||||
// transform the start and end points if necessary
|
||||
if (null != lineTrans)
|
||||
{
|
||||
lineStart = TransformPoint(lineStart, lineTrans);
|
||||
lineEnd = TransformPoint(lineEnd, lineTrans);
|
||||
}
|
||||
|
||||
// form two vectors from the face and a vector stand for the line
|
||||
// Use SubXYZ() method to get the vectors
|
||||
Autodesk.Revit.DB.XYZ vector1 = SubXYZ(first, second); // first vector of face
|
||||
Autodesk.Revit.DB.XYZ vector2 = SubXYZ(first, third); // second vector of face
|
||||
Autodesk.Revit.DB.XYZ vector3 = SubXYZ(lineStart, lineEnd); // line vector
|
||||
|
||||
// get two dot products of the face vectors and line vector
|
||||
double result1 = DotMatrix(vector1, vector3);
|
||||
double result2 = DotMatrix(vector2, vector3);
|
||||
|
||||
// if two dot products are all zero, the line is perpendicular to the face
|
||||
return (IsEqual(result1, 0) && IsEqual(result2, 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// judge whether the two vectors have the same direction
|
||||
/// </summary>
|
||||
/// <param name="firstVec">the first vector</param>
|
||||
/// <param name="secondVec">the second vector</param>
|
||||
/// <returns>true if the two vector is in same direction, otherwise false</returns>
|
||||
public static bool IsSameDirection(Autodesk.Revit.DB.XYZ firstVec, Autodesk.Revit.DB.XYZ secondVec)
|
||||
{
|
||||
// get the unit vector for two vectors
|
||||
Autodesk.Revit.DB.XYZ first = UnitVector(firstVec);
|
||||
Autodesk.Revit.DB.XYZ second = UnitVector(secondVec);
|
||||
|
||||
// if the dot product of two unit vectors is equal to 1, return true
|
||||
double dot = DotMatrix(first, second);
|
||||
return (IsEqual(dot, 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Judge whether the two vectors have the opposite direction
|
||||
/// </summary>
|
||||
/// <param name="firstVec">the first vector</param>
|
||||
/// <param name="secondVec">the second vector</param>
|
||||
/// <returns>true if the two vector is in opposite direction, otherwise false</returns>
|
||||
public static bool IsOppositeDirection(Autodesk.Revit.DB.XYZ firstVec, Autodesk.Revit.DB.XYZ secondVec)
|
||||
{
|
||||
// get the unit vector for two vectors
|
||||
Autodesk.Revit.DB.XYZ first = UnitVector(firstVec);
|
||||
Autodesk.Revit.DB.XYZ second = UnitVector(secondVec);
|
||||
|
||||
// if the dot product of two unit vectors is equal to -1, return true
|
||||
double dot = DotMatrix(first, second);
|
||||
return (IsEqual(dot, -1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// multiplication cross of two Autodesk.Revit.DB.XYZ as Matrix
|
||||
/// </summary>
|
||||
/// <param name="p1">The first XYZ</param>
|
||||
/// <param name="p2">The second XYZ</param>
|
||||
/// <returns>the normal vector of the face which first and secend vector lie on</returns>
|
||||
public static Autodesk.Revit.DB.XYZ CrossMatrix(Autodesk.Revit.DB.XYZ p1, Autodesk.Revit.DB.XYZ p2)
|
||||
{
|
||||
//get the coordinate of the XYZ
|
||||
double u1 = p1.X;
|
||||
double u2 = p1.Y;
|
||||
double u3 = p1.Z;
|
||||
|
||||
double v1 = p2.X;
|
||||
double v2 = p2.Y;
|
||||
double v3 = p2.Z;
|
||||
|
||||
double x = v3 * u2 - v2 * u3;
|
||||
double y = v1 * u3 - v3 * u1;
|
||||
double z = v2 * u1 - v1 * u2;
|
||||
|
||||
return new Autodesk.Revit.DB.XYZ (x, y, z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set the vector into unit length
|
||||
/// </summary>
|
||||
/// <param name="vector">the input vector</param>
|
||||
/// <returns>the vector in unit length</returns>
|
||||
public static Autodesk.Revit.DB.XYZ UnitVector(Autodesk.Revit.DB.XYZ vector)
|
||||
{
|
||||
// calculate the distance from grid origin to the XYZ
|
||||
double length = GetLength(vector);
|
||||
|
||||
// changed the vector into the unit length
|
||||
double x = vector.X / length;
|
||||
double y = vector.Y / length;
|
||||
double z = vector.Z / length;
|
||||
return new Autodesk.Revit.DB.XYZ (x, y, z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate the distance from grid origin to the XYZ(vector length)
|
||||
/// </summary>
|
||||
/// <param name="vector">the input vector</param>
|
||||
/// <returns>the length of the vector</returns>
|
||||
public static double GetLength(Autodesk.Revit.DB.XYZ vector)
|
||||
{
|
||||
double x = vector.X;
|
||||
double y = vector.Y;
|
||||
double z = vector.Z;
|
||||
return Math.Sqrt(x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtraction of two points(or vectors), get a new vector
|
||||
/// </summary>
|
||||
/// <param name="p1">the first point(vector)</param>
|
||||
/// <param name="p2">the second point(vector)</param>
|
||||
/// <returns>return a new vector from point p2 to p1</returns>
|
||||
public static Autodesk.Revit.DB.XYZ SubXYZ(Autodesk.Revit.DB.XYZ p1, Autodesk.Revit.DB.XYZ p2)
|
||||
{
|
||||
double x = p1.X - p2.X;
|
||||
double y = p1.Y - p2.Y;
|
||||
double z = p1.Z - p2.Z;
|
||||
|
||||
return new Autodesk.Revit.DB.XYZ (x, y, z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add of two points(or vectors), get a new point(vector)
|
||||
/// </summary>
|
||||
/// <param name="p1">the first point(vector)</param>
|
||||
/// <param name="p2">the first point(vector)</param>
|
||||
/// <returns>a new vector(point)</returns>
|
||||
public static Autodesk.Revit.DB.XYZ AddXYZ(Autodesk.Revit.DB.XYZ p1, Autodesk.Revit.DB.XYZ p2)
|
||||
{
|
||||
double x = p1.X + p2.X;
|
||||
double y = p1.Y + p2.Y;
|
||||
double z = p1.Z + p2.Z;
|
||||
|
||||
return new Autodesk.Revit.DB.XYZ (x, y, z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiply a verctor with a number
|
||||
/// </summary>
|
||||
/// <param name="vector">a vector</param>
|
||||
/// <param name="rate">the rate number</param>
|
||||
/// <returns></returns>
|
||||
public static Autodesk.Revit.DB.XYZ MultiplyVector(Autodesk.Revit.DB.XYZ vector, double rate)
|
||||
{
|
||||
double x = vector.X * rate;
|
||||
double y = vector.Y * rate;
|
||||
double z = vector.Z * rate;
|
||||
|
||||
return new Autodesk.Revit.DB.XYZ (x, y, z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transform old coordinate system in the new coordinate system
|
||||
/// </summary>
|
||||
/// <param name="point">the Autodesk.Revit.DB.XYZ which need to be transformed</param>
|
||||
/// <param name="transform">the value of the coordinate system to be transformed</param>
|
||||
/// <returns>the new Autodesk.Revit.DB.XYZ which has been transformed</returns>
|
||||
public static Autodesk.Revit.DB.XYZ TransformPoint(Autodesk.Revit.DB.XYZ point, Transform transform)
|
||||
{
|
||||
//get the coordinate value in X, Y, Z axis
|
||||
double x = point.X;
|
||||
double y = point.Y;
|
||||
double z = point.Z;
|
||||
|
||||
//transform basis of the old coordinate system in the new coordinate system
|
||||
Autodesk.Revit.DB.XYZ b0 = transform.get_Basis(0);
|
||||
Autodesk.Revit.DB.XYZ b1 = transform.get_Basis(1);
|
||||
Autodesk.Revit.DB.XYZ b2 = transform.get_Basis(2);
|
||||
Autodesk.Revit.DB.XYZ origin = transform.Origin;
|
||||
|
||||
//transform the origin of the old coordinate system in the new coordinate system
|
||||
double xTemp = x * b0.X + y * b1.X + z * b2.X + origin.X;
|
||||
double yTemp = x * b0.Y + y * b1.Y + z * b2.Y + origin.Y;
|
||||
double zTemp = x * b0.Z + y * b1.Z + z * b2.Z + origin.Z;
|
||||
|
||||
return new Autodesk.Revit.DB.XYZ (xTemp, yTemp, zTemp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move a point a give offset along a given direction
|
||||
/// </summary>
|
||||
/// <param name="point">the point need to move</param>
|
||||
/// <param name="direction">the direction the point move to</param>
|
||||
/// <param name="offset">indicate how long to move</param>
|
||||
/// <returns>the moved point</returns>
|
||||
public static Autodesk.Revit.DB.XYZ OffsetPoint(Autodesk.Revit.DB.XYZ point, Autodesk.Revit.DB.XYZ direction, double offset)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ directUnit = UnitVector(direction);
|
||||
Autodesk.Revit.DB.XYZ offsetVect = MultiplyVector(directUnit, offset);
|
||||
return AddXYZ(point, offsetVect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get the orient of hook accroding to curve direction, rebar normal and hook direction
|
||||
/// </summary>
|
||||
/// <param name="curveVec">the curve direction</param>
|
||||
/// <param name="normal">rebar normal direction</param>
|
||||
/// <param name="hookVec">the hook direction</param>
|
||||
/// <returns>the orient of the hook</returns>
|
||||
public static RebarHookOrientation GetHookOrient(Autodesk.Revit.DB.XYZ curveVec, Autodesk.Revit.DB.XYZ normal, Autodesk.Revit.DB.XYZ hookVec)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ tempVec = normal;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
tempVec = GeomUtil.CrossMatrix(tempVec, curveVec);
|
||||
if (GeomUtil.IsSameDirection(tempVec, hookVec))
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
return RebarHookOrientation.Right;
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
return RebarHookOrientation.Left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Can't find the hook orient according to hook direction.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Judge the vector is in right or left direction
|
||||
/// </summary>
|
||||
/// <param name="normal">The unit vector need to be judged its direction</param>
|
||||
/// <returns>if in right dircetion return true, otherwise return false</returns>
|
||||
public static bool IsInRightDir(Autodesk.Revit.DB.XYZ normal)
|
||||
{
|
||||
double eps = 1.0e-8;
|
||||
if (Math.Abs(normal.X) <= eps)
|
||||
{
|
||||
if (normal.Y > 0) return false;
|
||||
else return true;
|
||||
}
|
||||
if (normal.X > 0) return true;
|
||||
if (normal.X < 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dot product of two Autodesk.Revit.DB.XYZ as Matrix
|
||||
/// </summary>
|
||||
/// <param name="p1">The first XYZ</param>
|
||||
/// <param name="p2">The second XYZ</param>
|
||||
/// <returns>the cosine value of the angle between vector p1 an p2</returns>
|
||||
private static double DotMatrix(Autodesk.Revit.DB.XYZ p1, Autodesk.Revit.DB.XYZ p2)
|
||||
{
|
||||
//get the coordinate of the Autodesk.Revit.DB.XYZ
|
||||
double v1 = p1.X;
|
||||
double v2 = p1.Y;
|
||||
double v3 = p1.Z;
|
||||
|
||||
double u1 = p2.X;
|
||||
double u2 = p2.Y;
|
||||
double u3 = p2.Z;
|
||||
|
||||
return v1 * u1 + v2 * u2 + v3 * u3;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,366 @@
|
||||
//
|
||||
// (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;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
using GeoInstance = Autodesk.Revit.DB.GeometryInstance;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
/// <summary>
|
||||
/// The base class which support beamGeometrySupport and ColumnGeometrySupport etc.
|
||||
/// it store some common geometry information, and give some helper fuctions
|
||||
/// </summary>
|
||||
public class GeometrySupport
|
||||
{
|
||||
/// <summary>
|
||||
/// store the solid of beam or column
|
||||
/// </summary>
|
||||
protected Solid m_solid;
|
||||
|
||||
/// <summary>
|
||||
/// the extend or sweep path of the beam or column
|
||||
/// </summary>
|
||||
protected Line m_drivingLine;
|
||||
|
||||
/// <summary>
|
||||
/// the director vector of beam or column
|
||||
/// </summary>
|
||||
protected Autodesk.Revit.DB.XYZ m_drivingVector;
|
||||
|
||||
/// <summary>
|
||||
/// a list to store the edges
|
||||
/// </summary>
|
||||
protected List<Line> m_edges = new List<Line>();
|
||||
|
||||
/// <summary>
|
||||
/// a list to store the point
|
||||
/// </summary>
|
||||
protected List<Autodesk.Revit.DB.XYZ> m_points = new List<Autodesk.Revit.DB.XYZ>();
|
||||
|
||||
/// <summary>
|
||||
/// the transform value of the solid
|
||||
/// </summary>
|
||||
protected Transform m_transform;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="element">the host object, must be family instance</param>
|
||||
/// <param name="geoOptions">the geometry option</param>
|
||||
public GeometrySupport(FamilyInstance element, Options geoOptions)
|
||||
{
|
||||
// get the geometry element of the selected element
|
||||
Autodesk.Revit.DB.GeometryElement geoElement = element.get_Geometry(new Options());
|
||||
IEnumerator<GeometryObject> Objects = geoElement.GetEnumerator();
|
||||
if (null == geoElement || !Objects.MoveNext())
|
||||
{
|
||||
throw new Exception("Can't get the geometry of selected element.");
|
||||
}
|
||||
|
||||
SweptProfile swProfile = element.GetSweptProfile();
|
||||
if (swProfile == null || !(swProfile.GetDrivingCurve() is Line))
|
||||
{
|
||||
throw new Exception("The selected element driving curve is not a line.");
|
||||
}
|
||||
|
||||
// get the driving path and vector of the beam or column
|
||||
Line line = swProfile.GetDrivingCurve() as Line;
|
||||
if (null != line)
|
||||
{
|
||||
m_drivingLine = line; // driving path
|
||||
m_drivingVector = GeomUtil.SubXYZ(line.GetEndPoint(1), line.GetEndPoint(0));
|
||||
}
|
||||
|
||||
//get the geometry object
|
||||
Objects.Reset();
|
||||
//foreach (GeometryObject geoObject in geoElement.Objects)
|
||||
while (Objects.MoveNext())
|
||||
{
|
||||
GeometryObject geoObject = Objects.Current;
|
||||
|
||||
//get the geometry instance which contain the geometry information
|
||||
GeoInstance instance = geoObject as GeoInstance;
|
||||
if (null != instance)
|
||||
{
|
||||
//foreach (GeometryObject o in instance.SymbolGeometry.Objects)
|
||||
IEnumerator<GeometryObject> Objects1 = instance.SymbolGeometry.GetEnumerator();
|
||||
while (Objects1.MoveNext())
|
||||
{
|
||||
GeometryObject o = Objects1.Current;
|
||||
|
||||
// get the solid of beam of column
|
||||
Solid solid = o as Solid;
|
||||
|
||||
// do some checks.
|
||||
if (null == solid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (0 == solid.Faces.Size || 0 == solid.Edges.Size)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_solid = solid;
|
||||
//get the transform value of instance
|
||||
m_transform = instance.Transform;
|
||||
|
||||
// Get the swept profile curves information
|
||||
if (!GetSweptProfile(solid))
|
||||
{
|
||||
throw new Exception("Can't get the swept profile curves.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// do some checks about profile curves information
|
||||
if (null == m_edges)
|
||||
{
|
||||
throw new Exception("Can't get the geometry edge information.");
|
||||
}
|
||||
if (4 != m_points.Count)
|
||||
{
|
||||
throw new Exception("The sample only work for rectangular beams or columns.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// transform the point to new coordinates
|
||||
/// </summary>
|
||||
/// <param name="point">the point need to transform</param>
|
||||
/// <returns>the changed point</returns>
|
||||
protected Autodesk.Revit.DB.XYZ Transform(Autodesk.Revit.DB.XYZ point)
|
||||
{
|
||||
// only invoke the TransformPoint() method.
|
||||
return GeomUtil.TransformPoint(point, m_transform);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the length of driving line
|
||||
/// </summary>
|
||||
/// <returns>the length of the driving line</returns>
|
||||
protected double GetDrivingLineLength()
|
||||
{
|
||||
return GeomUtil.GetLength(m_drivingVector);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get two vectors, which indicate some edge direction which contain given point,
|
||||
/// set the given point as the start point, the other end point of the edge as end
|
||||
/// </summary>
|
||||
/// <param name="point">a point of the swept profile</param>
|
||||
/// <returns>two vectors indicate edge direction</returns>
|
||||
protected List<Autodesk.Revit.DB.XYZ> GetRelatedVectors(Autodesk.Revit.DB.XYZ point)
|
||||
{
|
||||
// Initialize the return vector list.
|
||||
List<Autodesk.Revit.DB.XYZ> vectors = new List<Autodesk.Revit.DB.XYZ>();
|
||||
|
||||
// Get all the edge which contain this point.
|
||||
// And get the vector from this point to another point
|
||||
foreach (Line line in m_edges)
|
||||
{
|
||||
if (GeomUtil.IsEqual(point, line.GetEndPoint(0)))
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ vector = GeomUtil.SubXYZ(line.GetEndPoint(1), line.GetEndPoint(0));
|
||||
vectors.Add(vector);
|
||||
}
|
||||
if (GeomUtil.IsEqual(point, line.GetEndPoint(1)))
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ vector = GeomUtil.SubXYZ(line.GetEndPoint(0), line.GetEndPoint(1));
|
||||
vectors.Add(vector);
|
||||
}
|
||||
}
|
||||
|
||||
// only two vector(direction) should be found
|
||||
if (2 != vectors.Count)
|
||||
{
|
||||
throw new Exception("a point on swept profile should have only two direction.");
|
||||
}
|
||||
|
||||
return vectors;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Offset the points of the swept profile to make the points inside swept profile
|
||||
/// </summary>
|
||||
/// <param name="offset">indicate how long to offset on two directions</param>
|
||||
/// <returns>the offset points</returns>
|
||||
protected List<Autodesk.Revit.DB.XYZ> OffsetPoints(double offset)
|
||||
{
|
||||
// Initialize the offset point list.
|
||||
List<Autodesk.Revit.DB.XYZ> points = new List<Autodesk.Revit.DB.XYZ>();
|
||||
|
||||
// Get all points of the swept profile, and offset it in two related direction
|
||||
foreach (Autodesk.Revit.DB.XYZ point in m_points)
|
||||
{
|
||||
// Get two related directions
|
||||
List<Autodesk.Revit.DB.XYZ> directions = GetRelatedVectors(point);
|
||||
Autodesk.Revit.DB.XYZ firstDir = directions[0];
|
||||
Autodesk.Revit.DB.XYZ secondDir = directions[1];
|
||||
|
||||
// offset the point in two direction
|
||||
Autodesk.Revit.DB.XYZ movedPoint = GeomUtil.OffsetPoint(point, firstDir, offset);
|
||||
movedPoint = GeomUtil.OffsetPoint(movedPoint, secondDir, offset);
|
||||
|
||||
// add the offset point into the array
|
||||
points.Add(movedPoint);
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Find the inforamtion of the swept profile(face),
|
||||
/// and store the points and edges of the profile(face)
|
||||
/// </summary>
|
||||
/// <param name="solid">the solid reference</param>
|
||||
/// <returns>true if the swept profile can be gotten, otherwise false</returns>
|
||||
private bool GetSweptProfile(Solid solid)
|
||||
{
|
||||
// get the swept face
|
||||
Face sweptFace = GetSweptProfileFace(solid);
|
||||
// do some checks
|
||||
if (null == sweptFace || 1 != sweptFace.EdgeLoops.Size)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// get the points of the swept face
|
||||
foreach (Autodesk.Revit.DB.XYZ point in sweptFace.Triangulate().Vertices)
|
||||
{
|
||||
m_points.Add(Transform(point));
|
||||
}
|
||||
|
||||
// get the edges of the swept face
|
||||
m_edges = ChangeEdgeToLine(sweptFace.EdgeLoops.get_Item(0));
|
||||
|
||||
// do some checks
|
||||
return (null != m_edges);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the swept profile(face) of the host object(family instance)
|
||||
/// </summary>
|
||||
/// <param name="solid">the solid reference</param>
|
||||
/// <returns>the swept profile</returns>
|
||||
private Face GetSweptProfileFace(Solid solid)
|
||||
{
|
||||
// Get a point on the swept profile from all points in solid
|
||||
Autodesk.Revit.DB.XYZ refPoint = new Autodesk.Revit.DB.XYZ(); // the point on swept profile
|
||||
foreach (Edge edge in solid.Edges)
|
||||
{
|
||||
List<XYZ> points = edge.Tessellate() as List<XYZ>; //get end points of the edge
|
||||
if (2 != points.Count) // make sure all edges are lines
|
||||
{
|
||||
throw new Exception("All edge should be line.");
|
||||
}
|
||||
|
||||
// get two points of the edge. All points in solid should be transform first
|
||||
Autodesk.Revit.DB.XYZ first = Transform(points[0]); // start point of edge
|
||||
Autodesk.Revit.DB.XYZ second = Transform(points[1]); // end point of edge
|
||||
|
||||
// some edges should be parallelled with the driving line,
|
||||
// and the start point of that edge should be the wanted point
|
||||
Autodesk.Revit.DB.XYZ edgeVector = GeomUtil.SubXYZ(second, first);
|
||||
if (GeomUtil.IsSameDirection(edgeVector, m_drivingVector))
|
||||
{
|
||||
refPoint = first;
|
||||
break;
|
||||
}
|
||||
if (GeomUtil.IsOppositeDirection(edgeVector, m_drivingVector))
|
||||
{
|
||||
refPoint = second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Find swept profile(face)
|
||||
Face sweptFace = null; // define the swept face
|
||||
foreach (Face face in solid.Faces)
|
||||
{
|
||||
if (null != sweptFace)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// the swept face should be perpendicular with the driving line
|
||||
if (!GeomUtil.IsVertical(face, m_drivingLine, m_transform, null))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// use the gotted point to get the swept face
|
||||
foreach (Autodesk.Revit.DB.XYZ point in face.Triangulate().Vertices)
|
||||
{
|
||||
Autodesk.Revit.DB.XYZ pnt = Transform(point); // all points in solid should be transform
|
||||
if (GeomUtil.IsEqual(refPoint, pnt))
|
||||
{
|
||||
sweptFace = face;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sweptFace;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the swept profile edges from EdgeArray type to line list
|
||||
/// </summary>
|
||||
/// <param name="edges">the swept profile edges</param>
|
||||
/// <returns>the line list which stores the swept profile edges</returns>
|
||||
private List<Line> ChangeEdgeToLine(EdgeArray edges)
|
||||
{
|
||||
// create the line list instance.
|
||||
List<Line> edgeLines = new List<Line>();
|
||||
|
||||
// get each edge from swept profile,
|
||||
// and changed the geometry information in line list
|
||||
foreach (Edge edge in edges)
|
||||
{
|
||||
//get the two points of each edge
|
||||
List<XYZ> points = edge.Tessellate() as List<XYZ>;
|
||||
Autodesk.Revit.DB.XYZ first = Transform(points[0]);
|
||||
Autodesk.Revit.DB.XYZ second = Transform(points[1]);
|
||||
|
||||
// create new line and add them into line list
|
||||
edgeLines.Add(Line.CreateBound(first, second));
|
||||
}
|
||||
|
||||
return edgeLines;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
//
|
||||
// (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 Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.Reinforcement.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// contain utility methods find or set certain parameter
|
||||
/// </summary>
|
||||
public class ParameterUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// find a parameter according to the parameter's name
|
||||
/// </summary>
|
||||
/// <param name="element">the host object of the parameter</param>
|
||||
/// <param name="parameterName">parameter name</param>
|
||||
/// <param name="value">the value of the parameter with integer type</param>
|
||||
/// <returns>if find the parameter return true</returns>
|
||||
public static bool SetParameter(Element element, string parameterName, int value)
|
||||
{
|
||||
ParameterSet parameters = element.Parameters;//a set containing all of the parameters
|
||||
//find a parameter according to the parameter's name
|
||||
Parameter findParameter = FindParameter(parameters, parameterName);
|
||||
|
||||
if (null == findParameter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//judge whether the parameter is readonly before change its value
|
||||
if (!findParameter.IsReadOnly)
|
||||
{
|
||||
//judge whether the type of the value is the same as the parameter's
|
||||
StorageType parameterType = findParameter.StorageType;
|
||||
if (StorageType.Integer != parameterType)
|
||||
{
|
||||
throw new Exception("The types of value and parameter are different!");
|
||||
}
|
||||
findParameter.Set(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// find a parameter according to the parameter's name
|
||||
/// </summary>
|
||||
/// <param name="element">the host object of the parameter</param>
|
||||
/// <param name="parameterName">parameter name</param>
|
||||
/// <param name="value">the value of the parameter with double type</param>
|
||||
/// <returns>if find the parameter return true</returns>
|
||||
public static bool SetParameter(Element element, string parameterName, double value)
|
||||
{
|
||||
ParameterSet parameters = element.Parameters;
|
||||
Parameter findParameter = FindParameter(parameters, parameterName);
|
||||
|
||||
if (null == findParameter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!findParameter.IsReadOnly)
|
||||
{
|
||||
StorageType parameterType = findParameter.StorageType;
|
||||
if (StorageType.Double != parameterType)
|
||||
{
|
||||
throw new Exception("The types of value and parameter are different!");
|
||||
}
|
||||
findParameter.Set(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// find a parameter according to the parameter's name
|
||||
/// </summary>
|
||||
/// <param name="element">the host object of the parameter</param>
|
||||
/// <param name="parameterName">parameter name</param>
|
||||
/// <param name="value">the value of the parameter with string type</param>
|
||||
/// <returns>if find the parameter return true</returns>
|
||||
public static bool SetParameter(Element element, string parameterName, string value)
|
||||
{
|
||||
ParameterSet parameters = element.Parameters;
|
||||
Parameter findParameter = FindParameter(parameters, parameterName);
|
||||
|
||||
if (null == findParameter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!findParameter.IsReadOnly)
|
||||
{
|
||||
StorageType parameterType = findParameter.StorageType;
|
||||
if (StorageType.String != parameterType)
|
||||
{
|
||||
throw new Exception("The types of value and parameter are different!");
|
||||
}
|
||||
findParameter.Set(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// find a parameter according to the parameter's name
|
||||
/// </summary>
|
||||
/// <param name="element">the host object of the parameter</param>
|
||||
/// <param name="parameterName">parameter name</param>
|
||||
/// <param name="value">the value of the parameter with Autodesk.Revit.DB.ElementId type</param>
|
||||
/// <returns>if find the parameter return true</returns>
|
||||
public static bool SetParameter(Element element, string parameterName, ref Autodesk.Revit.DB.ElementId value)
|
||||
{
|
||||
ParameterSet parameters = element.Parameters;
|
||||
Parameter findParameter = FindParameter(parameters, parameterName);
|
||||
|
||||
if (null == findParameter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!findParameter.IsReadOnly)
|
||||
{
|
||||
StorageType parameterType = findParameter.StorageType;
|
||||
if (StorageType.ElementId != parameterType)
|
||||
{
|
||||
throw new Exception("The types of value and parameter are different!");
|
||||
}
|
||||
findParameter.Set(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set certain parameter of given element to int value
|
||||
/// </summary>
|
||||
/// <param name="element">given element</param>
|
||||
/// <param name="paraIndex">BuiltInParameter</param>
|
||||
/// <param name="value">the value of the parameter with integer type</param>
|
||||
/// <returns>if find the parameter return true</returns>
|
||||
public static bool SetParameter(Element element, BuiltInParameter paraIndex, int value)
|
||||
{
|
||||
//find a parameter according to the builtInParameter name
|
||||
Parameter parameter = element.get_Parameter(paraIndex);
|
||||
if (null == parameter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parameter.IsReadOnly)
|
||||
{
|
||||
StorageType parameterType = parameter.StorageType;
|
||||
if (StorageType.Integer != parameterType)
|
||||
{
|
||||
throw new Exception("The types of value and parameter are different!");
|
||||
}
|
||||
parameter.Set(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// find a parameter according to the parameter's name
|
||||
/// </summary>
|
||||
/// <param name="element">the host object of the parameter</param>
|
||||
/// <param name="paraIndex">parameter index</param>
|
||||
/// <param name="value">the value of the parameter with double type</param>
|
||||
/// <returns>if find the parameter return true</returns>
|
||||
public static bool SetParameter(Element element, BuiltInParameter paraIndex, double value)
|
||||
{
|
||||
Parameter parameter = element.get_Parameter(paraIndex);
|
||||
if (null == parameter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parameter.IsReadOnly)
|
||||
{
|
||||
StorageType parameterType = parameter.StorageType;
|
||||
if (StorageType.Double != parameterType)
|
||||
{
|
||||
throw new Exception("The types of value and parameter are different!");
|
||||
}
|
||||
parameter.Set(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// find a parameter according to the parameter's name
|
||||
/// </summary>
|
||||
/// <param name="element">the host object of the parameter</param>
|
||||
/// <param name="paraIndex">parameter index</param>
|
||||
/// <param name="value">the value of the parameter with string type</param>
|
||||
/// <returns>if find the parameter return true</returns>
|
||||
public static bool SetParameter(Element element, BuiltInParameter paraIndex, string value)
|
||||
{
|
||||
Parameter parameter = element.get_Parameter(paraIndex);
|
||||
if (null == parameter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parameter.IsReadOnly)
|
||||
{
|
||||
StorageType parameterType = parameter.StorageType;
|
||||
if (StorageType.String != parameterType)
|
||||
{
|
||||
throw new Exception("The types of value and parameter are different!");
|
||||
}
|
||||
parameter.Set(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// find a parameter according to the parameter's name
|
||||
/// </summary>
|
||||
/// <param name="element">the host object of the parameter</param>
|
||||
/// <param name="paraIndex">parameter index</param>
|
||||
/// <param name="value">the value of the parameter with Autodesk.Revit.DB.ElementId type</param>
|
||||
/// <returns>if find the parameter return true</returns>
|
||||
public static bool SetParameter(Element element,
|
||||
BuiltInParameter paraIndex, ref Autodesk.Revit.DB.ElementId value)
|
||||
{
|
||||
Parameter parameter = element.get_Parameter(paraIndex);
|
||||
if (null == parameter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parameter.IsReadOnly)
|
||||
{
|
||||
StorageType parameterType = parameter.StorageType;
|
||||
if (StorageType.ElementId != parameterType)
|
||||
{
|
||||
throw new Exception("The types of value and parameter are different!");
|
||||
}
|
||||
parameter.Set(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set null id to a parameter
|
||||
/// </summary>
|
||||
/// <param name="parameter">the parameter which wanted to change the value</param>
|
||||
/// <returns>if set parameter's value successful return true</returns>
|
||||
public static bool SetParaNullId(Parameter parameter)
|
||||
{
|
||||
Autodesk.Revit.DB.ElementId id = new ElementId(-1);
|
||||
|
||||
if (!parameter.IsReadOnly)
|
||||
{
|
||||
parameter.Set(id);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// find a parameter according to the parameter's name
|
||||
/// </summary>
|
||||
/// <param name="parameters">parameter set</param>
|
||||
/// <param name="name">parameter name</param>
|
||||
/// <returns>found parameter</returns>
|
||||
public static Parameter FindParameter(ParameterSet parameters, string name)
|
||||
{
|
||||
Parameter findParameter = null;
|
||||
|
||||
foreach (Parameter parameter in parameters)
|
||||
{
|
||||
if (parameter.Definition.Name == name)
|
||||
{
|
||||
findParameter = parameter;
|
||||
}
|
||||
}
|
||||
|
||||
return findParameter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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("Reinforcement")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Reinforcement")]
|
||||
[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("0aa8f153-2f4a-4e3a-949b-eb97dc6b35c2")]
|
||||
|
||||
// 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.
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>Reinforcement.dll</Assembly>
|
||||
<ClientId>cc1d65d3-2fa1-4afb-a82b-b6c8ed2c56a9</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.Reinforcement.CS.Command</FullClassName>
|
||||
<Text>Reinforcement</Text>
|
||||
<Description>Create bar set in a selected concrete element (beam or column) that does not have any reinforcement.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?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>{E1DA0A90-58B2-4032-B443-F8C397CE3B49}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Reinforcement</RootNamespace>
|
||||
<AssemblyName>Reinforcement</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="BeamFramReinMaker.cs" />
|
||||
<Compile Include="BeamFramReinMakerForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BeamFramReinMakerForm.Designer.cs">
|
||||
<DependentUpon>BeamFramReinMakerForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BeamGeometrySupport.cs" />
|
||||
<Compile Include="ColumnFramReinMaker.cs" />
|
||||
<Compile Include="ColumnFramReinMakerForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ColumnFramReinMakerForm.Designer.cs">
|
||||
<DependentUpon>ColumnFramReinMakerForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ColumnGeometrySupport.cs" />
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="FrameReinMakerFactory.cs" />
|
||||
<Compile Include="FramReinMaker.cs" />
|
||||
<Compile Include="GeomData.cs" />
|
||||
<Compile Include="GeometrySupport.cs" />
|
||||
<Compile Include="GeomUtil.cs" />
|
||||
<Compile Include="ParameterUtil.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="BeamFramReinMakerForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>BeamFramReinMakerForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ColumnFramReinMakerForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>ColumnFramReinMakerForm.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>
|
||||
Reference in New Issue
Block a user