mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-17 10:02:09 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using GElement = Autodesk.Revit.DB.GeometryElement;
|
||||
using CElement = Autodesk.Revit.DB.Element;
|
||||
using GInstance = Autodesk.Revit.DB.Instance;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
|
||||
namespace Revit.SDK.Samples.NewRebar.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is the entrance of this project, it implements IExternalCommand.
|
||||
/// </summary>
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
|
||||
public class Command : IExternalCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Implement this method as an external command for Revit.
|
||||
/// </summary>
|
||||
/// <param name="commandData">An object that is passed to the external application
|
||||
/// which contains data related to the command,
|
||||
/// such as the application object and active view.</param>
|
||||
/// <param name="message">A message that can be set by the external application
|
||||
/// which will be displayed if a failure or cancellation is returned by
|
||||
/// the external command.</param>
|
||||
/// <param name="elements">A set of elements to which the external application
|
||||
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
/// <returns>Return the status of the external command.
|
||||
/// A result of Succeeded means that the API external method functioned as expected.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation
|
||||
/// at some point. Failure should be returned if the application is unable to proceed with
|
||||
/// the operation.</returns>
|
||||
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
|
||||
Transaction transaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "External Tool");
|
||||
try
|
||||
{
|
||||
transaction.Start();
|
||||
RebarCreator creator = new RebarCreator(commandData);
|
||||
creator.Execute();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
message = e.Message.ToString();
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
finally
|
||||
{
|
||||
transaction.Commit();
|
||||
}
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
//
|
||||
// (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.ComponentModel;
|
||||
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.NewRebar.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Dimension on RebarShapeDefByArc.
|
||||
/// </summary>
|
||||
abstract class ConstraintOnArcShape : ConstraintOnRebarShape
|
||||
{
|
||||
/// <summary>
|
||||
/// Dimension to constrain the arc shape.
|
||||
/// </summary>
|
||||
protected RebarShapeParameter m_rebarShapeParameter;
|
||||
|
||||
public ConstraintOnArcShape(RebarShapeDefByArc def)
|
||||
: base(def)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dimension to constrain the arc shape.
|
||||
/// </summary>
|
||||
[DisplayName("RebarShape parameter"), TypeConverter(typeof(TypeConverterRebarShapeParameter)), ReadOnly(false)]
|
||||
public virtual RebarShapeParameter RebarShapeParameter
|
||||
{
|
||||
get
|
||||
{
|
||||
UpdateParameterTypeConverter();
|
||||
|
||||
return m_rebarShapeParameter;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_rebarShapeParameter = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get RebarShapeDefinitionByArc object.
|
||||
/// </summary>
|
||||
protected RebarShapeDefinitionByArc GetRebarShapeDefinitionByArc
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_shapeDef.RebarshapeDefinition as RebarShapeDefinitionByArc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arc length dimension.
|
||||
/// </summary>
|
||||
class ConstraintArcLength : ConstraintOnArcShape
|
||||
{
|
||||
public ConstraintArcLength(RebarShapeDefByArc def)
|
||||
: base(def)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add dimension to constrain the arc length.
|
||||
/// </summary>
|
||||
public override void Commit()
|
||||
{
|
||||
GetRebarShapeDefinitionByArc.AddConstraintArcLength(
|
||||
RebarShapeParameter.Parameter);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arc chord length dimension.
|
||||
/// </summary>
|
||||
class ConstraintChordLength : ConstraintOnArcShape
|
||||
{
|
||||
public ConstraintChordLength(RebarShapeDefByArc def)
|
||||
: base(def)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add dimension to constrain the arc chord length.
|
||||
/// </summary>
|
||||
public override void Commit()
|
||||
{
|
||||
GetRebarShapeDefinitionByArc.AddConstraintChordLength(
|
||||
RebarShapeParameter.Parameter);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arc circumference dimension.
|
||||
/// </summary>
|
||||
class ConstraintCircumference : ConstraintOnArcShape
|
||||
{
|
||||
/// <summary>
|
||||
/// Arc reference type.
|
||||
/// </summary>
|
||||
private RebarShapeArcReferenceType m_arcReferenceType;
|
||||
|
||||
public ConstraintCircumference(RebarShapeDefByArc def)
|
||||
: base(def)
|
||||
{
|
||||
m_arcReferenceType = RebarShapeArcReferenceType.External;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arc reference type.
|
||||
/// </summary>
|
||||
public RebarShapeArcReferenceType ArcReferenceType
|
||||
{
|
||||
get { return m_arcReferenceType; }
|
||||
set { m_arcReferenceType = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add dimension to constrain the arc circumference.
|
||||
/// </summary>
|
||||
public override void Commit()
|
||||
{
|
||||
GetRebarShapeDefinitionByArc.AddConstraintCircumference(
|
||||
RebarShapeParameter.Parameter, ArcReferenceType);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arc diameter dimension.
|
||||
/// </summary>
|
||||
class ConstraintDiameter : ConstraintOnArcShape
|
||||
{
|
||||
/// <summary>
|
||||
/// Arc reference type.
|
||||
/// </summary>
|
||||
private RebarShapeArcReferenceType m_arcReferenceType;
|
||||
|
||||
public ConstraintDiameter(RebarShapeDefByArc def)
|
||||
: base(def)
|
||||
{
|
||||
m_arcReferenceType = RebarShapeArcReferenceType.External;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arc reference type.
|
||||
/// </summary>
|
||||
public RebarShapeArcReferenceType ArcReferenceType
|
||||
{
|
||||
get { return m_arcReferenceType; }
|
||||
set { m_arcReferenceType = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add dimension to constrain arc diameter.
|
||||
/// </summary>
|
||||
public override void Commit()
|
||||
{
|
||||
GetRebarShapeDefinitionByArc.AddConstraintDiameter(
|
||||
RebarShapeParameter.Parameter, ArcReferenceType);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arc radius dimension.
|
||||
/// </summary>
|
||||
class ConstraintRadius : ConstraintOnArcShape
|
||||
{
|
||||
/// <summary>
|
||||
/// Arc reference type.
|
||||
/// </summary>
|
||||
private RebarShapeArcReferenceType m_arcReferenceType;
|
||||
|
||||
public ConstraintRadius(RebarShapeDefByArc def)
|
||||
: base(def)
|
||||
{
|
||||
m_arcReferenceType = RebarShapeArcReferenceType.External;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arc reference type.
|
||||
/// </summary>
|
||||
public RebarShapeArcReferenceType ArcReferenceType
|
||||
{
|
||||
get { return m_arcReferenceType; }
|
||||
set { m_arcReferenceType = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add dimension to constrain the radius of arc.
|
||||
/// </summary>
|
||||
public override void Commit()
|
||||
{
|
||||
GetRebarShapeDefinitionByArc.AddConstraintRadius(
|
||||
RebarShapeParameter.Parameter, ArcReferenceType);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arc Sagittarius length dimension.
|
||||
/// </summary>
|
||||
class ConstraintSagittaLength : ConstraintOnArcShape
|
||||
{
|
||||
public ConstraintSagittaLength(RebarShapeDefByArc def)
|
||||
: base(def)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add dimension to constrain the Sagittarius length of arc.
|
||||
/// </summary>
|
||||
public override void Commit()
|
||||
{
|
||||
GetRebarShapeDefinitionByArc.AddConstraintSagittaLength(
|
||||
RebarShapeParameter.Parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// (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 System.ComponentModel;
|
||||
|
||||
namespace Revit.SDK.Samples.NewRebar.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Dimension on RebarShape.
|
||||
/// </summary>
|
||||
public abstract class ConstraintOnRebarShape
|
||||
{
|
||||
/// <summary>
|
||||
/// A wrapper of RebarShapeDefinition.
|
||||
/// </summary>
|
||||
protected RebarShapeDef m_shapeDef;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, initialize fields.
|
||||
/// </summary>
|
||||
/// <param name="def">RebarShapeDef object</param>
|
||||
protected ConstraintOnRebarShape(RebarShapeDef def)
|
||||
{
|
||||
m_shapeDef = def;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the parameter list value for property grid.
|
||||
/// </summary>
|
||||
protected void UpdateParameterTypeConverter()
|
||||
{
|
||||
TypeConverterRebarShapeParameter.RebarShapeParameters = m_shapeDef.Parameters;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of the constraint.
|
||||
/// </summary>
|
||||
public String Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetType().Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Commit the dimension.
|
||||
/// </summary>
|
||||
public abstract void Commit();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
namespace Revit.SDK.Samples.NewRebar.CS
|
||||
{
|
||||
partial class AddConstraint
|
||||
{
|
||||
/// <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.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.constraintTypesComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(164, 76);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(72, 23);
|
||||
this.cancelButton.TabIndex = 16;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(74, 76);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(72, 23);
|
||||
this.okButton.TabIndex = 15;
|
||||
this.okButton.Text = "&OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(67, 17);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(81, 13);
|
||||
this.label1.TabIndex = 14;
|
||||
this.label1.Text = "ConstraintType:";
|
||||
//
|
||||
// constraintTypesComboBox
|
||||
//
|
||||
this.constraintTypesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.constraintTypesComboBox.FormattingEnabled = true;
|
||||
this.constraintTypesComboBox.Location = new System.Drawing.Point(65, 41);
|
||||
this.constraintTypesComboBox.Name = "constraintTypesComboBox";
|
||||
this.constraintTypesComboBox.Size = new System.Drawing.Size(188, 21);
|
||||
this.constraintTypesComboBox.TabIndex = 13;
|
||||
//
|
||||
// AddConstraint
|
||||
//
|
||||
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(323, 114);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.constraintTypesComboBox);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "AddConstraint";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Add Constraint";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.ComboBox constraintTypesComboBox;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// (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;
|
||||
|
||||
namespace Revit.SDK.Samples.NewRebar.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This form provides an entrance for user to add constraints to RebarShape.
|
||||
/// </summary>
|
||||
public partial class AddConstraint : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public AddConstraint()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, Initialize fields.
|
||||
/// </summary>
|
||||
/// <param name="constraintTypes"></param>
|
||||
public AddConstraint(List<Type> constraintTypes)
|
||||
: this()
|
||||
{
|
||||
constraintTypesComboBox.DataSource = constraintTypes;
|
||||
constraintTypesComboBox.DisplayMember = "Name";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the type from constraintTypesComboBox selection.
|
||||
/// </summary>
|
||||
public Type ConstraintType
|
||||
{
|
||||
get
|
||||
{
|
||||
return constraintTypesComboBox.SelectedItem as Type;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OK Button, Return DialogResult.OK and close this form.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel Button, Return DialogResult.Cancel and close this form.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,191 @@
|
||||
//
|
||||
// (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.NewRebar.CS
|
||||
{
|
||||
partial class AddParameter
|
||||
{
|
||||
/// <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.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.paramValueTextBox = new System.Windows.Forms.TextBox();
|
||||
this.paramNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.groupBox = new System.Windows.Forms.GroupBox();
|
||||
this.paramFormulaRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.paramDoubleRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.groupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(43, 112);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(34, 13);
|
||||
this.label2.TabIndex = 8;
|
||||
this.label2.Text = "Value";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(43, 79);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(35, 13);
|
||||
this.label1.TabIndex = 7;
|
||||
this.label1.Text = "Name";
|
||||
//
|
||||
// paramValueTextBox
|
||||
//
|
||||
this.paramValueTextBox.Location = new System.Drawing.Point(102, 105);
|
||||
this.paramValueTextBox.Name = "paramValueTextBox";
|
||||
this.paramValueTextBox.Size = new System.Drawing.Size(142, 20);
|
||||
this.paramValueTextBox.TabIndex = 6;
|
||||
//
|
||||
// paramNameTextBox
|
||||
//
|
||||
this.paramNameTextBox.Location = new System.Drawing.Point(102, 79);
|
||||
this.paramNameTextBox.Name = "paramNameTextBox";
|
||||
this.paramNameTextBox.Size = new System.Drawing.Size(142, 20);
|
||||
this.paramNameTextBox.TabIndex = 5;
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(64, 146);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(72, 23);
|
||||
this.okButton.TabIndex = 2;
|
||||
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(159, 146);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(72, 23);
|
||||
this.cancelButton.TabIndex = 10;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// groupBox
|
||||
//
|
||||
this.groupBox.Controls.Add(this.paramFormulaRadioButton);
|
||||
this.groupBox.Controls.Add(this.paramDoubleRadioButton);
|
||||
this.groupBox.Location = new System.Drawing.Point(43, 12);
|
||||
this.groupBox.Name = "groupBox";
|
||||
this.groupBox.Size = new System.Drawing.Size(201, 47);
|
||||
this.groupBox.TabIndex = 11;
|
||||
this.groupBox.TabStop = false;
|
||||
this.groupBox.Text = "Parameter Type";
|
||||
//
|
||||
// paramFormulaRadioButton
|
||||
//
|
||||
this.paramFormulaRadioButton.AutoSize = true;
|
||||
this.paramFormulaRadioButton.Location = new System.Drawing.Point(116, 19);
|
||||
this.paramFormulaRadioButton.Name = "paramFormulaRadioButton";
|
||||
this.paramFormulaRadioButton.Size = new System.Drawing.Size(62, 17);
|
||||
this.paramFormulaRadioButton.TabIndex = 1;
|
||||
this.paramFormulaRadioButton.Text = "Formula";
|
||||
this.paramFormulaRadioButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// paramDoubleRadioButton
|
||||
//
|
||||
this.paramDoubleRadioButton.AutoSize = true;
|
||||
this.paramDoubleRadioButton.Checked = true;
|
||||
this.paramDoubleRadioButton.Location = new System.Drawing.Point(21, 19);
|
||||
this.paramDoubleRadioButton.Name = "paramDoubleRadioButton";
|
||||
this.paramDoubleRadioButton.Size = new System.Drawing.Size(59, 17);
|
||||
this.paramDoubleRadioButton.TabIndex = 0;
|
||||
this.paramDoubleRadioButton.TabStop = true;
|
||||
this.paramDoubleRadioButton.Text = "Double";
|
||||
this.paramDoubleRadioButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// AddParameter
|
||||
//
|
||||
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(285, 181);
|
||||
this.Controls.Add(this.groupBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.paramValueTextBox);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.paramNameTextBox);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "AddParameter";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Add Parameter";
|
||||
this.groupBox.ResumeLayout(false);
|
||||
this.groupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox paramValueTextBox;
|
||||
private System.Windows.Forms.TextBox paramNameTextBox;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.GroupBox groupBox;
|
||||
private System.Windows.Forms.RadioButton paramFormulaRadioButton;
|
||||
private System.Windows.Forms.RadioButton paramDoubleRadioButton;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
//
|
||||
// (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 System.Text.RegularExpressions;
|
||||
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.NewRebar.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This form provides an entrance for user to add parameters to RebarShape.
|
||||
/// </summary>
|
||||
public partial class AddParameter : System.Windows.Forms.Form
|
||||
{
|
||||
List<RebarShapeParameter> m_parameterList;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public AddParameter()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, initialize fields.
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
public AddParameter(List<RebarShapeParameter> list)
|
||||
: this()
|
||||
{
|
||||
m_parameterList = list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is it formula parameter or not?
|
||||
/// </summary>
|
||||
public bool IsFormula
|
||||
{
|
||||
get
|
||||
{
|
||||
return paramFormulaRadioButton.Checked;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameter name from paramNameTextBox.
|
||||
/// </summary>
|
||||
public string ParamName
|
||||
{
|
||||
get
|
||||
{
|
||||
return paramNameTextBox.Text;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameter value from paramValueTextBox.
|
||||
/// </summary>
|
||||
public string ParamValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return paramValueTextBox.Text;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel Button, Return DialogResult.Cancel and close this form.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OK button, check the correction of data, then Return DialogResult.OK
|
||||
/// and close this form.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ParamName) || string.IsNullOrEmpty(ParamValue))
|
||||
{
|
||||
TaskDialog.Show("Revit", "Parameter Name and Value should not be null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsFormula)
|
||||
{
|
||||
try
|
||||
{
|
||||
Double.Parse(ParamValue);
|
||||
}
|
||||
catch
|
||||
{
|
||||
TaskDialog.Show("Revit", "Input value - " + ParamValue + " - should be double.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure Parameter name should be started with letter
|
||||
// And just contains letters, numbers and underlines
|
||||
Regex regex = new Regex("^[a-zA-Z]\\w*$");
|
||||
if (!regex.IsMatch(ParamName))
|
||||
{
|
||||
TaskDialog.Show("Revit", "Parameter name should be started with letter \r\n And just contains letters, numbers and underlines.");
|
||||
paramNameTextBox.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the name is unique.
|
||||
foreach (RebarShapeParameter param in m_parameterList)
|
||||
{
|
||||
if (param.Name.Equals(ParamName))
|
||||
{
|
||||
TaskDialog.Show("Revit", "The name is already exist, please input again.");
|
||||
paramNameTextBox.Focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+259
@@ -0,0 +1,259 @@
|
||||
//
|
||||
// (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.NewRebar.CS
|
||||
{
|
||||
partial class NewRebarForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.rebarShapesGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.shapesComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.createShapeButton = new System.Windows.Forms.Button();
|
||||
this.rebarBarTypeGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.barTypesComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.arcTypecomboBox = new System.Windows.Forms.ComboBox();
|
||||
this.segmentCountTextBox = new System.Windows.Forms.TextBox();
|
||||
this.bySegmentsradioButton = new System.Windows.Forms.RadioButton();
|
||||
this.byArcradioButton = new System.Windows.Forms.RadioButton();
|
||||
this.rebarShapesGroupBox.SuspendLayout();
|
||||
this.rebarBarTypeGroupBox.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(141, 233);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(89, 26);
|
||||
this.okButton.TabIndex = 4;
|
||||
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(252, 233);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(89, 26);
|
||||
this.cancelButton.TabIndex = 5;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// rebarShapesGroupBox
|
||||
//
|
||||
this.rebarShapesGroupBox.Controls.Add(this.shapesComboBox);
|
||||
this.rebarShapesGroupBox.Location = new System.Drawing.Point(26, 12);
|
||||
this.rebarShapesGroupBox.Name = "rebarShapesGroupBox";
|
||||
this.rebarShapesGroupBox.Size = new System.Drawing.Size(204, 77);
|
||||
this.rebarShapesGroupBox.TabIndex = 7;
|
||||
this.rebarShapesGroupBox.TabStop = false;
|
||||
this.rebarShapesGroupBox.Text = "RebarShape";
|
||||
//
|
||||
// shapesComboBox
|
||||
//
|
||||
this.shapesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.shapesComboBox.FormattingEnabled = true;
|
||||
this.shapesComboBox.Location = new System.Drawing.Point(31, 31);
|
||||
this.shapesComboBox.Name = "shapesComboBox";
|
||||
this.shapesComboBox.Size = new System.Drawing.Size(149, 21);
|
||||
this.shapesComboBox.TabIndex = 8;
|
||||
//
|
||||
// createShapeButton
|
||||
//
|
||||
this.createShapeButton.Location = new System.Drawing.Point(20, 151);
|
||||
this.createShapeButton.Name = "createShapeButton";
|
||||
this.createShapeButton.Size = new System.Drawing.Size(162, 29);
|
||||
this.createShapeButton.TabIndex = 9;
|
||||
this.createShapeButton.Text = "Create Rebar &Shape ...";
|
||||
this.createShapeButton.UseVisualStyleBackColor = true;
|
||||
this.createShapeButton.Click += new System.EventHandler(this.createShapeButton_Click);
|
||||
//
|
||||
// rebarBarTypeGroupBox
|
||||
//
|
||||
this.rebarBarTypeGroupBox.Controls.Add(this.barTypesComboBox);
|
||||
this.rebarBarTypeGroupBox.Location = new System.Drawing.Point(26, 116);
|
||||
this.rebarBarTypeGroupBox.Name = "rebarBarTypeGroupBox";
|
||||
this.rebarBarTypeGroupBox.Size = new System.Drawing.Size(204, 82);
|
||||
this.rebarBarTypeGroupBox.TabIndex = 8;
|
||||
this.rebarBarTypeGroupBox.TabStop = false;
|
||||
this.rebarBarTypeGroupBox.Text = "RebarBarType";
|
||||
//
|
||||
// barTypesComboBox
|
||||
//
|
||||
this.barTypesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.barTypesComboBox.FormattingEnabled = true;
|
||||
this.barTypesComboBox.Location = new System.Drawing.Point(30, 35);
|
||||
this.barTypesComboBox.Name = "barTypesComboBox";
|
||||
this.barTypesComboBox.Size = new System.Drawing.Size(150, 21);
|
||||
this.barTypesComboBox.TabIndex = 1;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.nameLabel);
|
||||
this.groupBox2.Controls.Add(this.nameTextBox);
|
||||
this.groupBox2.Controls.Add(this.arcTypecomboBox);
|
||||
this.groupBox2.Controls.Add(this.segmentCountTextBox);
|
||||
this.groupBox2.Controls.Add(this.bySegmentsradioButton);
|
||||
this.groupBox2.Controls.Add(this.byArcradioButton);
|
||||
this.groupBox2.Controls.Add(this.createShapeButton);
|
||||
this.groupBox2.Location = new System.Drawing.Point(249, 12);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(213, 186);
|
||||
this.groupBox2.TabIndex = 11;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Create Rebar Shape";
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(20, 36);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 21;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Location = new System.Drawing.Point(79, 31);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(103, 20);
|
||||
this.nameTextBox.TabIndex = 20;
|
||||
//
|
||||
// arcTypecomboBox
|
||||
//
|
||||
this.arcTypecomboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.arcTypecomboBox.FormattingEnabled = true;
|
||||
this.arcTypecomboBox.Location = new System.Drawing.Point(79, 68);
|
||||
this.arcTypecomboBox.Name = "arcTypecomboBox";
|
||||
this.arcTypecomboBox.Size = new System.Drawing.Size(103, 21);
|
||||
this.arcTypecomboBox.TabIndex = 19;
|
||||
//
|
||||
// segmentCountTextBox
|
||||
//
|
||||
this.segmentCountTextBox.Enabled = false;
|
||||
this.segmentCountTextBox.Location = new System.Drawing.Point(108, 103);
|
||||
this.segmentCountTextBox.Name = "segmentCountTextBox";
|
||||
this.segmentCountTextBox.Size = new System.Drawing.Size(74, 20);
|
||||
this.segmentCountTextBox.TabIndex = 18;
|
||||
//
|
||||
// bySegmentsradioButton
|
||||
//
|
||||
this.bySegmentsradioButton.AutoSize = true;
|
||||
this.bySegmentsradioButton.Location = new System.Drawing.Point(20, 104);
|
||||
this.bySegmentsradioButton.Name = "bySegmentsradioButton";
|
||||
this.bySegmentsradioButton.Size = new System.Drawing.Size(87, 17);
|
||||
this.bySegmentsradioButton.TabIndex = 17;
|
||||
this.bySegmentsradioButton.Text = "By Segments";
|
||||
this.bySegmentsradioButton.UseVisualStyleBackColor = true;
|
||||
this.bySegmentsradioButton.CheckedChanged += new System.EventHandler(this.bySegmentsradioButton_CheckedChanged);
|
||||
//
|
||||
// byArcradioButton
|
||||
//
|
||||
this.byArcradioButton.AutoSize = true;
|
||||
this.byArcradioButton.Checked = true;
|
||||
this.byArcradioButton.Location = new System.Drawing.Point(20, 72);
|
||||
this.byArcradioButton.Name = "byArcradioButton";
|
||||
this.byArcradioButton.Size = new System.Drawing.Size(56, 17);
|
||||
this.byArcradioButton.TabIndex = 16;
|
||||
this.byArcradioButton.TabStop = true;
|
||||
this.byArcradioButton.Text = "By Arc";
|
||||
this.byArcradioButton.UseVisualStyleBackColor = true;
|
||||
this.byArcradioButton.CheckedChanged += new System.EventHandler(this.byArcradioButton_CheckedChanged);
|
||||
//
|
||||
// NewRebarForm
|
||||
//
|
||||
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(484, 281);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.rebarBarTypeGroupBox);
|
||||
this.Controls.Add(this.rebarShapesGroupBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "NewRebarForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Create Rebar";
|
||||
this.Load += new System.EventHandler(this.NewRebarForm_Load);
|
||||
this.rebarShapesGroupBox.ResumeLayout(false);
|
||||
this.rebarBarTypeGroupBox.ResumeLayout(false);
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.GroupBox rebarShapesGroupBox;
|
||||
private System.Windows.Forms.Button createShapeButton;
|
||||
private System.Windows.Forms.ComboBox shapesComboBox;
|
||||
private System.Windows.Forms.GroupBox rebarBarTypeGroupBox;
|
||||
private System.Windows.Forms.ComboBox barTypesComboBox;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.ComboBox arcTypecomboBox;
|
||||
private System.Windows.Forms.TextBox segmentCountTextBox;
|
||||
private System.Windows.Forms.RadioButton bySegmentsradioButton;
|
||||
private System.Windows.Forms.RadioButton byArcradioButton;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
//
|
||||
// (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 System.Reflection;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.NewRebar.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the main form for user to operate the Rebar creation.
|
||||
/// </summary>
|
||||
public partial class NewRebarForm : System.Windows.Forms.Form
|
||||
{
|
||||
///// <summary>
|
||||
///// Revit Application object.
|
||||
///// </summary>
|
||||
//Autodesk.Revit.ApplicationServices.Application m_rvtApp;
|
||||
|
||||
/// <summary>
|
||||
/// Revit Document object.
|
||||
/// </summary>
|
||||
Document m_rvtDoc;
|
||||
|
||||
/// <summary>
|
||||
/// All RebarBarTypes of Revit current document.
|
||||
/// </summary>
|
||||
List<RebarBarType> m_rebarBarTypes = new List<RebarBarType>();
|
||||
|
||||
/// <summary>
|
||||
/// All RebarShape of Revit current document.
|
||||
/// </summary>
|
||||
List<RebarShape> m_rebarShapes = new List<RebarShape>();
|
||||
|
||||
/// <summary>
|
||||
/// Control binding source, provides data source for RebarBarType list box.
|
||||
/// </summary>
|
||||
BindingSource m_barTypesBinding = new BindingSource();
|
||||
|
||||
/// <summary>
|
||||
/// Control binding source, provides data source for RebarShapes list box.
|
||||
/// </summary>
|
||||
BindingSource m_shapesBinding = new BindingSource();
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public NewRebarForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, initialize fields of RebarBarTypes and RebarShapes.
|
||||
/// </summary>
|
||||
/// <param name="rvtApp"></param>
|
||||
public NewRebarForm(Autodesk.Revit.DB.Document rvtDoc)
|
||||
: this()
|
||||
{
|
||||
m_rvtDoc = rvtDoc;
|
||||
|
||||
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(m_rvtDoc);
|
||||
filteredElementCollector.OfClass(typeof(RebarBarType));
|
||||
m_rebarBarTypes = filteredElementCollector.Cast<RebarBarType>().ToList<RebarBarType>();
|
||||
|
||||
filteredElementCollector = new FilteredElementCollector(m_rvtDoc);
|
||||
filteredElementCollector.OfClass(typeof(RebarShape));
|
||||
m_rebarShapes = filteredElementCollector.Cast<RebarShape>().ToList<RebarShape>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return RebarBarType from selection of barTypesComboBox.
|
||||
/// </summary>
|
||||
public RebarBarType RebarBarType
|
||||
{
|
||||
get
|
||||
{
|
||||
return barTypesComboBox.SelectedItem as RebarBarType;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return RebarShape from selection of shapesComboBox.
|
||||
/// </summary>
|
||||
public RebarShape RebarShape
|
||||
{
|
||||
get
|
||||
{
|
||||
return shapesComboBox.SelectedItem as RebarShape;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// OK Button, return DialogResult.OK and close this form.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel Button, return DialogResult.Cancel and close this form.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Present a dialog to customize a RebarShape.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void createShapeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Make sure the name is not null or empty.
|
||||
if (string.IsNullOrEmpty(nameTextBox.Text.Trim()))
|
||||
{
|
||||
TaskDialog.Show("Revit", "Please give a name to create a rebar shape.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the input name is started with letter and
|
||||
// just contains letters, numbers and underlines.
|
||||
Regex regex = new Regex("^[a-zA-Z]\\w+$");
|
||||
if (!regex.IsMatch(nameTextBox.Text.Trim()))
|
||||
{
|
||||
TaskDialog.Show("Revit", "Please input the name starting with letter and just containing letters, numbers and underlines. String is " + nameTextBox.Text.ToString());
|
||||
nameTextBox.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a RebarShapeDefinition.
|
||||
RebarShapeDef shapeDef = null;
|
||||
|
||||
if (byArcradioButton.Checked)
|
||||
{
|
||||
// Create arc shape.
|
||||
RebarShapeDefinitionByArc arcShapeDefinition = null;
|
||||
RebarShapeDefinitionByArcType arcType = (RebarShapeDefinitionByArcType)Enum.Parse(typeof(RebarShapeDefinitionByArcType), arcTypecomboBox.Text);
|
||||
if (arcType != RebarShapeDefinitionByArcType.Spiral)
|
||||
{
|
||||
arcShapeDefinition = new RebarShapeDefinitionByArc(m_rvtDoc, arcType);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set default value for Spiral-Shape definition.
|
||||
arcShapeDefinition = new RebarShapeDefinitionByArc(m_rvtDoc, 10.0, 3.0, 0, 0);
|
||||
}
|
||||
shapeDef = new RebarShapeDefByArc(arcShapeDefinition);
|
||||
}
|
||||
else if (bySegmentsradioButton.Checked)
|
||||
{
|
||||
// Create straight segments shape.
|
||||
int segmentCount = 0;
|
||||
if (int.TryParse(segmentCountTextBox.Text, out segmentCount) && segmentCount > 0)
|
||||
{
|
||||
shapeDef = new RebarShapeDefBySegment(new RebarShapeDefinitionBySegments(m_rvtDoc, segmentCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskDialog.Show("Revit", "Please input a valid positive integer as segments count.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int startHookAngle = 0;
|
||||
int endHookAngle = 0;
|
||||
RebarHookOrientation startHookOrientation = RebarHookOrientation.Left;
|
||||
RebarHookOrientation endHookOrientation = RebarHookOrientation.Left;
|
||||
|
||||
bool doCreate = false;
|
||||
|
||||
using (NewRebarShapeForm form = new NewRebarShapeForm(m_rvtDoc, shapeDef))
|
||||
{
|
||||
// Present a form to customize the shape.
|
||||
if (DialogResult.OK == form.ShowDialog())
|
||||
{
|
||||
doCreate = true;
|
||||
if (form.NeedSetHooks)
|
||||
{
|
||||
// Set hooks for rebar shape.
|
||||
startHookAngle = form.StartHookAngle;
|
||||
endHookAngle = form.EndHookAngle;
|
||||
startHookOrientation = form.StartHookOrientation;
|
||||
endHookOrientation = form.EndHookOrientation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (doCreate)
|
||||
{
|
||||
// Create the RebarShape.
|
||||
RebarShape createdRebarShape = RebarShape.Create(m_rvtDoc, shapeDef.RebarshapeDefinition, null,
|
||||
RebarStyle.Standard, StirrupTieAttachmentType.InteriorFace,
|
||||
startHookAngle, startHookOrientation,
|
||||
endHookAngle, endHookOrientation,
|
||||
0);
|
||||
createdRebarShape.Name = nameTextBox.Text.Trim();
|
||||
|
||||
// Add the created shape to the candidate list.
|
||||
m_rebarShapes.Add(createdRebarShape);
|
||||
m_shapesBinding.ResetBindings(false);
|
||||
shapesComboBox.SelectedItem = createdRebarShape;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the status of some controls.
|
||||
/// </summary>
|
||||
private void UpdateUIStatus()
|
||||
{
|
||||
segmentCountTextBox.Enabled = bySegmentsradioButton.Checked;
|
||||
arcTypecomboBox.Enabled = byArcradioButton.Checked;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// byArcradioButton check status change event.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void byArcradioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateUIStatus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// bySegmentsradioButton check status change event.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void bySegmentsradioButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateUIStatus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load event, Initialize controls data source.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void NewRebarForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
m_barTypesBinding.DataSource = m_rebarBarTypes;
|
||||
m_shapesBinding.DataSource = m_rebarShapes;
|
||||
|
||||
arcTypecomboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
arcTypecomboBox.DataSource = Enum.GetNames(typeof(RebarShapeDefinitionByArcType));
|
||||
|
||||
shapesComboBox.Sorted = true;
|
||||
barTypesComboBox.Sorted = true;
|
||||
shapesComboBox.DataSource = m_shapesBinding;
|
||||
shapesComboBox.DisplayMember = "Name";
|
||||
barTypesComboBox.DataSource = m_barTypesBinding;
|
||||
barTypesComboBox.DisplayMember = "Name";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,339 @@
|
||||
//
|
||||
// (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.NewRebar.CS
|
||||
{
|
||||
partial class NewRebarShapeForm
|
||||
{
|
||||
/// <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.addParameterButton = new System.Windows.Forms.Button();
|
||||
this.addConstraintButton = new System.Windows.Forms.Button();
|
||||
this.parameterListBox = new System.Windows.Forms.ListBox();
|
||||
this.propertyGrid = new System.Windows.Forms.PropertyGrid();
|
||||
this.constraintListBox = new System.Windows.Forms.ListBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.parameterGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.hookGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.endHookOrientationcomboBox = new System.Windows.Forms.ComboBox();
|
||||
this.startHookOrientationComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.endHookAngleComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.startHookAngleComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.useHooksCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.parameterGroupBox.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.hookGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// addParameterButton
|
||||
//
|
||||
this.addParameterButton.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.addParameterButton.Location = new System.Drawing.Point(3, 195);
|
||||
this.addParameterButton.Name = "addParameterButton";
|
||||
this.addParameterButton.Size = new System.Drawing.Size(137, 31);
|
||||
this.addParameterButton.TabIndex = 2;
|
||||
this.addParameterButton.Text = "Add &Parameter";
|
||||
this.addParameterButton.UseVisualStyleBackColor = true;
|
||||
this.addParameterButton.Click += new System.EventHandler(this.addParameterButton_Click);
|
||||
//
|
||||
// addConstraintButton
|
||||
//
|
||||
this.addConstraintButton.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.addConstraintButton.Location = new System.Drawing.Point(3, 195);
|
||||
this.addConstraintButton.Name = "addConstraintButton";
|
||||
this.addConstraintButton.Size = new System.Drawing.Size(200, 31);
|
||||
this.addConstraintButton.TabIndex = 3;
|
||||
this.addConstraintButton.Text = "Add Con&straint";
|
||||
this.addConstraintButton.UseVisualStyleBackColor = true;
|
||||
this.addConstraintButton.Click += new System.EventHandler(this.addConstraintButton_Click);
|
||||
//
|
||||
// parameterListBox
|
||||
//
|
||||
this.parameterListBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.parameterListBox.FormattingEnabled = true;
|
||||
this.parameterListBox.HorizontalScrollbar = true;
|
||||
this.parameterListBox.Location = new System.Drawing.Point(3, 16);
|
||||
this.parameterListBox.Name = "parameterListBox";
|
||||
this.parameterListBox.Size = new System.Drawing.Size(137, 173);
|
||||
this.parameterListBox.TabIndex = 4;
|
||||
this.parameterListBox.SelectedIndexChanged += new System.EventHandler(this.parameterListBox_SelectedIndexChanged);
|
||||
//
|
||||
// propertyGrid
|
||||
//
|
||||
this.propertyGrid.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.propertyGrid.Location = new System.Drawing.Point(3, 16);
|
||||
this.propertyGrid.Name = "propertyGrid";
|
||||
this.propertyGrid.Size = new System.Drawing.Size(222, 365);
|
||||
this.propertyGrid.TabIndex = 5;
|
||||
//
|
||||
// constraintListBox
|
||||
//
|
||||
this.constraintListBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.constraintListBox.FormattingEnabled = true;
|
||||
this.constraintListBox.Location = new System.Drawing.Point(3, 16);
|
||||
this.constraintListBox.Name = "constraintListBox";
|
||||
this.constraintListBox.Size = new System.Drawing.Size(200, 173);
|
||||
this.constraintListBox.TabIndex = 6;
|
||||
this.constraintListBox.SelectedIndexChanged += new System.EventHandler(this.constraintListBox_SelectedIndexChanged);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(237, 425);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 29);
|
||||
this.okButton.TabIndex = 7;
|
||||
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(342, 425);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 29);
|
||||
this.cancelButton.TabIndex = 8;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// parameterGroupBox
|
||||
//
|
||||
this.parameterGroupBox.Controls.Add(this.parameterListBox);
|
||||
this.parameterGroupBox.Controls.Add(this.addParameterButton);
|
||||
this.parameterGroupBox.Location = new System.Drawing.Point(12, 26);
|
||||
this.parameterGroupBox.Name = "parameterGroupBox";
|
||||
this.parameterGroupBox.Size = new System.Drawing.Size(143, 229);
|
||||
this.parameterGroupBox.TabIndex = 9;
|
||||
this.parameterGroupBox.TabStop = false;
|
||||
this.parameterGroupBox.Text = "Parameters";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.constraintListBox);
|
||||
this.groupBox2.Controls.Add(this.addConstraintButton);
|
||||
this.groupBox2.Location = new System.Drawing.Point(181, 26);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(206, 229);
|
||||
this.groupBox2.TabIndex = 10;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Constraints";
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.propertyGrid);
|
||||
this.groupBox3.Location = new System.Drawing.Point(413, 26);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(228, 384);
|
||||
this.groupBox3.TabIndex = 11;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "Properties";
|
||||
//
|
||||
// hookGroupBox
|
||||
//
|
||||
this.hookGroupBox.Controls.Add(this.label4);
|
||||
this.hookGroupBox.Controls.Add(this.label3);
|
||||
this.hookGroupBox.Controls.Add(this.label2);
|
||||
this.hookGroupBox.Controls.Add(this.label1);
|
||||
this.hookGroupBox.Controls.Add(this.endHookOrientationcomboBox);
|
||||
this.hookGroupBox.Controls.Add(this.startHookOrientationComboBox);
|
||||
this.hookGroupBox.Controls.Add(this.endHookAngleComboBox);
|
||||
this.hookGroupBox.Controls.Add(this.startHookAngleComboBox);
|
||||
this.hookGroupBox.Controls.Add(this.useHooksCheckBox);
|
||||
this.hookGroupBox.Location = new System.Drawing.Point(15, 257);
|
||||
this.hookGroupBox.Name = "hookGroupBox";
|
||||
this.hookGroupBox.Size = new System.Drawing.Size(368, 153);
|
||||
this.hookGroupBox.TabIndex = 12;
|
||||
this.hookGroupBox.TabStop = false;
|
||||
this.hookGroupBox.Text = "Rebar Hook";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(222, 100);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(109, 13);
|
||||
this.label4.TabIndex = 8;
|
||||
this.label4.Text = "End Hook Orientation";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(23, 100);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(85, 13);
|
||||
this.label3.TabIndex = 7;
|
||||
this.label3.Text = "End Hook Angle";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(222, 42);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(112, 13);
|
||||
this.label2.TabIndex = 6;
|
||||
this.label2.Text = "Start Hook Orientation";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(23, 42);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(88, 13);
|
||||
this.label1.TabIndex = 5;
|
||||
this.label1.Text = "Start Hook Angle";
|
||||
//
|
||||
// endHookOrientationcomboBox
|
||||
//
|
||||
this.endHookOrientationcomboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.endHookOrientationcomboBox.Enabled = false;
|
||||
this.endHookOrientationcomboBox.FormattingEnabled = true;
|
||||
this.endHookOrientationcomboBox.Location = new System.Drawing.Point(222, 120);
|
||||
this.endHookOrientationcomboBox.Name = "endHookOrientationcomboBox";
|
||||
this.endHookOrientationcomboBox.Size = new System.Drawing.Size(121, 21);
|
||||
this.endHookOrientationcomboBox.TabIndex = 4;
|
||||
//
|
||||
// startHookOrientationComboBox
|
||||
//
|
||||
this.startHookOrientationComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.startHookOrientationComboBox.Enabled = false;
|
||||
this.startHookOrientationComboBox.FormattingEnabled = true;
|
||||
this.startHookOrientationComboBox.Location = new System.Drawing.Point(222, 62);
|
||||
this.startHookOrientationComboBox.Name = "startHookOrientationComboBox";
|
||||
this.startHookOrientationComboBox.Size = new System.Drawing.Size(121, 21);
|
||||
this.startHookOrientationComboBox.TabIndex = 3;
|
||||
//
|
||||
// endHookAngleComboBox
|
||||
//
|
||||
this.endHookAngleComboBox.Enabled = false;
|
||||
this.endHookAngleComboBox.FormattingEnabled = true;
|
||||
this.endHookAngleComboBox.Location = new System.Drawing.Point(23, 120);
|
||||
this.endHookAngleComboBox.Name = "endHookAngleComboBox";
|
||||
this.endHookAngleComboBox.Size = new System.Drawing.Size(121, 21);
|
||||
this.endHookAngleComboBox.TabIndex = 2;
|
||||
//
|
||||
// startHookAngleComboBox
|
||||
//
|
||||
this.startHookAngleComboBox.Enabled = false;
|
||||
this.startHookAngleComboBox.FormattingEnabled = true;
|
||||
this.startHookAngleComboBox.Location = new System.Drawing.Point(23, 62);
|
||||
this.startHookAngleComboBox.Name = "startHookAngleComboBox";
|
||||
this.startHookAngleComboBox.Size = new System.Drawing.Size(121, 21);
|
||||
this.startHookAngleComboBox.TabIndex = 1;
|
||||
//
|
||||
// useHooksCheckBox
|
||||
//
|
||||
this.useHooksCheckBox.AutoSize = true;
|
||||
this.useHooksCheckBox.Location = new System.Drawing.Point(23, 20);
|
||||
this.useHooksCheckBox.Name = "useHooksCheckBox";
|
||||
this.useHooksCheckBox.Size = new System.Drawing.Size(103, 17);
|
||||
this.useHooksCheckBox.TabIndex = 0;
|
||||
this.useHooksCheckBox.Text = "Set Rebar Hook";
|
||||
this.useHooksCheckBox.UseVisualStyleBackColor = true;
|
||||
this.useHooksCheckBox.CheckedChanged += new System.EventHandler(this.useHooksCheckBox_CheckedChanged);
|
||||
//
|
||||
// NewRebarShapeForm
|
||||
//
|
||||
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(661, 465);
|
||||
this.Controls.Add(this.hookGroupBox);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.parameterGroupBox);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "NewRebarShapeForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Create RebarShape";
|
||||
this.Load += new System.EventHandler(this.NewRebarShapeForm_Load);
|
||||
this.parameterGroupBox.ResumeLayout(false);
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.hookGroupBox.ResumeLayout(false);
|
||||
this.hookGroupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button addParameterButton;
|
||||
private System.Windows.Forms.Button addConstraintButton;
|
||||
private System.Windows.Forms.ListBox parameterListBox;
|
||||
private System.Windows.Forms.PropertyGrid propertyGrid;
|
||||
private System.Windows.Forms.ListBox constraintListBox;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.GroupBox parameterGroupBox;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
private System.Windows.Forms.GroupBox hookGroupBox;
|
||||
private System.Windows.Forms.ComboBox endHookOrientationcomboBox;
|
||||
private System.Windows.Forms.ComboBox startHookOrientationComboBox;
|
||||
private System.Windows.Forms.ComboBox endHookAngleComboBox;
|
||||
private System.Windows.Forms.ComboBox startHookAngleComboBox;
|
||||
private System.Windows.Forms.CheckBox useHooksCheckBox;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
//
|
||||
// (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 System.Reflection;
|
||||
using System.IO;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.NewRebar.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This form is provided for user to define a new RebarShape.
|
||||
/// </summary>
|
||||
public partial class NewRebarShapeForm : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// RebarShapeDef object.
|
||||
/// </summary>
|
||||
private RebarShapeDef m_rebarShapeDef;
|
||||
|
||||
/// <summary>
|
||||
/// Autodesk Revit Application object.
|
||||
/// </summary>
|
||||
private Autodesk.Revit.ApplicationServices.Application m_rvtApp;
|
||||
|
||||
/// <summary>
|
||||
/// Autodesk Revit Document Object.
|
||||
/// </summary>
|
||||
private Autodesk.Revit.DB.Document m_rvtDoc;
|
||||
|
||||
/// <summary>
|
||||
/// Binding source for parameters ListBox.
|
||||
/// </summary>
|
||||
private BindingSource m_parametersListBoxBinding = new BindingSource();
|
||||
|
||||
/// <summary>
|
||||
/// Binding source for constraints ListBox.
|
||||
/// </summary>
|
||||
private BindingSource m_constraintsListBoxBinding = new BindingSource();
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public NewRebarShapeForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, Initialize the fields.
|
||||
/// </summary>
|
||||
/// <param name="rvtApp">Revit Application object</param>
|
||||
/// <param name="shapeDef">RebarShapeDef object</param>
|
||||
public NewRebarShapeForm(Autodesk.Revit.DB.Document rvtDoc, RebarShapeDef shapeDef)
|
||||
: this()
|
||||
{
|
||||
m_rebarShapeDef = shapeDef;
|
||||
m_rvtDoc = rvtDoc;
|
||||
m_rvtApp = rvtDoc.Application;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If this return true, the hook of RebarShape will be set, otherwise not.
|
||||
/// </summary>
|
||||
public bool NeedSetHooks
|
||||
{
|
||||
get
|
||||
{
|
||||
return useHooksCheckBox.Checked;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return start hook angle.
|
||||
/// </summary>
|
||||
public int StartHookAngle
|
||||
{
|
||||
get
|
||||
{
|
||||
return int.Parse(startHookAngleComboBox.Text);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return end hook angle.
|
||||
/// </summary>
|
||||
public int EndHookAngle
|
||||
{
|
||||
get
|
||||
{
|
||||
return int.Parse(endHookAngleComboBox.Text);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return start hook orientation.
|
||||
/// </summary>
|
||||
public RebarHookOrientation StartHookOrientation
|
||||
{
|
||||
get
|
||||
{
|
||||
return (RebarHookOrientation)Enum.Parse(
|
||||
typeof(RebarHookOrientation), startHookOrientationComboBox.Text);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return end hook orientation.
|
||||
/// </summary>
|
||||
public RebarHookOrientation EndHookOrientation
|
||||
{
|
||||
get
|
||||
{
|
||||
return (RebarHookOrientation)Enum.Parse(
|
||||
typeof(RebarHookOrientation), endHookOrientationcomboBox.Text);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a definition group if there exists one, otherwise, a new one will be created.
|
||||
/// </summary>
|
||||
/// <returns>Definition group</returns>
|
||||
private DefinitionGroup GetOrCreateDefinitionGroup()
|
||||
{
|
||||
DefinitionFile file = null;
|
||||
|
||||
int count = 0;
|
||||
// A count is to avoid infinite loop
|
||||
while (null == file && count < 100)
|
||||
{
|
||||
file = m_rvtApp.OpenSharedParameterFile();
|
||||
if (file == null)
|
||||
{
|
||||
// If Shared parameter file does not exist, then create a new one.
|
||||
string shapeFile =
|
||||
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
|
||||
+ "\\ParameterFile.txt";
|
||||
|
||||
// Fill Schema data of Revit shared parameter file.
|
||||
// If no this schema data, OpenSharedParameterFile may alway return null.
|
||||
System.Text.StringBuilder contents = new System.Text.StringBuilder();
|
||||
contents.AppendLine("# This is a Revit shared parameter file.");
|
||||
contents.AppendLine("# Do not edit manually.");
|
||||
contents.AppendLine("*META VERSION MINVERSION");
|
||||
contents.AppendLine("META 2 1");
|
||||
contents.AppendLine("*GROUP ID NAME");
|
||||
contents.AppendLine("*PARAM GUID NAME DATATYPE DATACATEGORY GROUP VISIBLE");
|
||||
|
||||
// Write Schema data of Revit shared parameter file.
|
||||
File.WriteAllText(shapeFile, contents.ToString());
|
||||
|
||||
// Set Revit shared parameter file
|
||||
m_rvtApp.SharedParametersFilename = shapeFile;
|
||||
}
|
||||
|
||||
// To avoid infinite loop.
|
||||
++count;
|
||||
}
|
||||
|
||||
// Get or create a definition group "Rebar Shape Parameters".
|
||||
DefinitionGroup group = file.Groups.get_Item("Rebar Shape Parameters");
|
||||
if (group == null)
|
||||
group = file.Groups.Create("Rebar Shape Parameters");
|
||||
return group;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Present a dialog to add a parameter to RebarShapeDef.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void addParameterButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (AddParameter addParam = new AddParameter(m_rebarShapeDef.Parameters))
|
||||
{
|
||||
if( DialogResult.OK == addParam.ShowDialog())
|
||||
{
|
||||
Type paramType = addParam.IsFormula ?
|
||||
typeof(RebarShapeParameterFormula) :
|
||||
typeof(RebarShapeParameterDouble);
|
||||
|
||||
object paramName = addParam.ParamName;
|
||||
object paramValue = addParam.ParamValue;
|
||||
if (!addParam.IsFormula)
|
||||
paramValue = double.Parse(addParam.ParamValue);
|
||||
|
||||
// Add the parameter to RebarShapeDef.
|
||||
RebarShapeParameter param = m_rebarShapeDef.AddParameter(paramType, paramName, paramValue);
|
||||
propertyGrid.SelectedObject = param;
|
||||
m_parametersListBoxBinding.ResetBindings(false);
|
||||
parameterListBox.SelectedItem = param;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Present a dialog to add a constraint to RebarShapeDef.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void addConstraintButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (AddConstraint addConstraint = new AddConstraint(m_rebarShapeDef.AllowedConstraintTypes()))
|
||||
{
|
||||
if(DialogResult.OK == addConstraint.ShowDialog())
|
||||
{
|
||||
Type constraintType = addConstraint.ConstraintType;
|
||||
|
||||
// Add the constraint to RebarShapeDef.
|
||||
ConstraintOnRebarShape constraint = m_rebarShapeDef.AddConstraint(constraintType);
|
||||
propertyGrid.SelectedObject = constraint;
|
||||
m_constraintsListBoxBinding.ResetBindings(false);
|
||||
constraintListBox.SelectedItem = constraint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OK Button, commit the RebarShapeDef, if there are not any exception,
|
||||
/// The RebarShape will be added to Revit Document successfully.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_rebarShapeDef.Commit(m_rvtDoc, GetOrCreateDefinitionGroup());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskDialog.Show("Revit", "Rebar shape creation failed:" + ex.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel Button, Cancel the creation of RebarShape.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load event, Initialize the controls data.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void NewRebarShapeForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Initialize parameters' and constraints' listBox data source.
|
||||
m_parametersListBoxBinding.DataSource = m_rebarShapeDef.Parameters;
|
||||
m_constraintsListBoxBinding.DataSource = m_rebarShapeDef.Constraints;
|
||||
parameterListBox.DataSource = m_parametersListBoxBinding;
|
||||
constraintListBox.DataSource = m_constraintsListBoxBinding;
|
||||
parameterListBox.DisplayMember = "Name";
|
||||
constraintListBox.DisplayMember = "Name";
|
||||
m_parametersListBoxBinding.ResetBindings(true);
|
||||
m_constraintsListBoxBinding.ResetBindings(true);
|
||||
|
||||
// Initialize start and end hook angles comboBox data source.
|
||||
int[] startAngles = new int[4] { 0, 90, 135, 180 };
|
||||
int[] endAngles = new int[4] { 0, 90, 135, 180 };
|
||||
startHookAngleComboBox.DataSource = startAngles;
|
||||
endHookAngleComboBox.DataSource = endAngles;
|
||||
|
||||
// Initialize start and end hook orientation comboBox data source.
|
||||
string[] startOritationNames = Enum.GetNames(typeof(RebarHookOrientation));
|
||||
string[] endOritationNames = Enum.GetNames(typeof(RebarHookOrientation));
|
||||
startHookOrientationComboBox.DataSource = startOritationNames;
|
||||
endHookOrientationcomboBox.DataSource = endOritationNames;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the selection in the constraint listBox is changed, the property grid's
|
||||
/// content should be changed too.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void constraintListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
propertyGrid.SelectedObject = constraintListBox.SelectedItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the selection in the parameter listBox is changed, the property grid's
|
||||
/// content should be changed too.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void parameterListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
propertyGrid.SelectedObject = parameterListBox.SelectedItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the check status of useHooksCheckBox is changed, other comboBox's
|
||||
/// enabled status should be changed too.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void useHooksCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
bool isEnalbled = useHooksCheckBox.Checked;
|
||||
startHookAngleComboBox.Enabled = isEnalbled;
|
||||
startHookOrientationComboBox.Enabled = isEnalbled;
|
||||
endHookAngleComboBox.Enabled = isEnalbled;
|
||||
endHookOrientationcomboBox.Enabled = isEnalbled;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,302 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.NewRebar.CS
|
||||
{
|
||||
using GeoElement = Autodesk.Revit.DB.GeometryElement;
|
||||
using GeoSolid = Autodesk.Revit.DB.Solid;
|
||||
using Element = Autodesk.Revit.DB.Element;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The class which gives 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;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// 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 vector 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">Tndicate 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>
|
||||
/// 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,392 @@
|
||||
//
|
||||
// (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.NewRebar.CS
|
||||
{
|
||||
// using GeoInstance as Autodesk.Revit.DB.Instance
|
||||
using GeoInstance = Autodesk.Revit.DB.GeometryInstance;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
/// <summary>
|
||||
/// Compute geometry information and store geometry information.
|
||||
/// </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>
|
||||
private List<Autodesk.Revit.DB.XYZ> m_points = new List<Autodesk.Revit.DB.XYZ>();
|
||||
|
||||
/// <summary>
|
||||
/// Return profile points
|
||||
/// </summary>
|
||||
public List<Autodesk.Revit.DB.XYZ> ProfilePoints
|
||||
{
|
||||
get { return m_points; }
|
||||
set { m_points = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the transform value of the solid
|
||||
/// </summary>
|
||||
protected Transform m_transform;
|
||||
|
||||
/// <summary>
|
||||
/// Driving length field
|
||||
/// </summary>
|
||||
private double m_drivingLength;
|
||||
|
||||
/// <summary>
|
||||
/// Return driving length
|
||||
/// </summary>
|
||||
public double DrivingLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_drivingLength;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="element">The host object, must be family instance</param>
|
||||
public GeometrySupport(FamilyInstance element)
|
||||
{
|
||||
// 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 || 0 == geoElement.Objects.Size)
|
||||
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));
|
||||
m_drivingLength = m_drivingVector.GetLength();
|
||||
}
|
||||
|
||||
//get the geometry object
|
||||
//foreach (GeometryObject geoObject in geoElement.Objects)
|
||||
Objects.Reset();
|
||||
while (Objects.MoveNext())
|
||||
{
|
||||
GeometryObject geoObject = Objects.Current;
|
||||
|
||||
//get the geometry instance which contains 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 works for rectangle beam or column.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <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 edges 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 vectors(directions) should be found
|
||||
if (2 != vectors.Count)
|
||||
{
|
||||
throw new Exception("A point on swept profile should have only two directions.");
|
||||
}
|
||||
|
||||
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>
|
||||
public 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 directions
|
||||
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 directions
|
||||
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 information 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("Each edge should be a line.");
|
||||
}
|
||||
|
||||
// get two points of the edge. All points in solid should be transformed 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 paralleled 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 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 transformed
|
||||
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 change 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,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>NewRebar.dll</Assembly>
|
||||
<ClientId>2d5baccb-f93e-4cf1-8068-f66de309f3b3</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.NewRebar.CS.Command</FullClassName>
|
||||
<Text>NewRebar</Text>
|
||||
<Description>Create a rebar on the selected concrete rectangular column or beam.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>adsk</VendorId>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,141 @@
|
||||
<?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>{3F5F3438-EA42-4340-9DEA-1D82A80BDE94}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Revit.SDK.Samples.NewRebar.CS</RootNamespace>
|
||||
<AssemblyName>NewRebar</AssemblyName>
|
||||
<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="Forms\AddConstraintForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\AddConstraintForm.Designer.cs">
|
||||
<DependentUpon>AddConstraintForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\AddParameterForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\AddParameterForm.Designer.cs">
|
||||
<DependentUpon>AddParameterForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Geom\GeometrySupport.cs" />
|
||||
<Compile Include="Geom\GeomUtil.cs" />
|
||||
<Compile Include="RebarCreator.cs" />
|
||||
<Compile Include="RebarShapeDef\RebarShapeDefByArc.cs" />
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="Constraints\ConstraintOnArcShape.cs" />
|
||||
<Compile Include="Constraints\ConstraintOnSegmentShape.cs" />
|
||||
<Compile Include="Forms\NewRebarForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\NewRebarForm.Designer.cs">
|
||||
<DependentUpon>NewRebarForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\NewRebarShapeForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\NewRebarShapeForm.Designer.cs">
|
||||
<DependentUpon>NewRebarShapeForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Constraints\ConstraintOnRebarShape.cs" />
|
||||
<Compile Include="RebarShapeDef\RebarShapeDef.cs" />
|
||||
<Compile Include="RebarShapeDef\RebarShapeDefBySegment.cs" />
|
||||
<Compile Include="Parameters\RebarShapeParameter.cs" />
|
||||
<Compile Include="Parameters\RebarShapeParameterDouble.cs" />
|
||||
<Compile Include="Parameters\RebarShapeParameterFormula.cs" />
|
||||
<Compile Include="TypeConverter\TypeConverterRebarShapeParameter.cs" />
|
||||
<Compile Include="TypeConverter\TypeConverterSegmentId.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Forms\AddConstraintForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>AddConstraintForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\AddParameterForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>AddParameterForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\NewRebarForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>NewRebarForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\NewRebarShapeForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>NewRebarShapeForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
|
||||
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,109 @@
|
||||
//
|
||||
// (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 System.ComponentModel;
|
||||
|
||||
namespace Revit.SDK.Samples.NewRebar.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class wraps an Parameter object which will be added
|
||||
/// to RebarShape definition. This is a abstract class and it will be inherited
|
||||
/// by two classes: RebarShapeParameterDouble and RebarShapeParameterFormula.
|
||||
/// </summary>
|
||||
public abstract class RebarShapeParameter
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameter id. It is the result of commit.
|
||||
/// </summary>
|
||||
protected ElementId m_parameterId;
|
||||
|
||||
/// <summary>
|
||||
/// RebarShape definition proxy object.
|
||||
/// </summary>
|
||||
protected RebarShapeDef m_rebarShapeDef;
|
||||
|
||||
/// <summary>
|
||||
/// Parameter name string.
|
||||
/// </summary>
|
||||
protected String m_name;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="shapeDef">RebarShapeDefinition proxy</param>
|
||||
/// <param name="name">Parameter name</param>
|
||||
protected RebarShapeParameter(RebarShapeDef shapeDef, string name)
|
||||
{
|
||||
m_rebarShapeDef = shapeDef;
|
||||
m_name = name;
|
||||
m_parameterId = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameter, it is the result of commit.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public ElementId Parameter
|
||||
{
|
||||
get { return m_parameterId; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameter name string.
|
||||
/// </summary>
|
||||
public String Name
|
||||
{
|
||||
get { return m_name; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a external definition if there exists one, otherwise create a new one.
|
||||
/// </summary>
|
||||
/// <param name="group">Definition group</param>
|
||||
/// <returns>External definition</returns>
|
||||
protected ExternalDefinition GetOrCreateDef(DefinitionGroup group)
|
||||
{
|
||||
ExternalDefinition Bdef =
|
||||
group.Definitions.get_Item(m_name) as ExternalDefinition;
|
||||
|
||||
if (Bdef == null)
|
||||
{
|
||||
ExternalDefinitionCreationOptions ExternalDefinitionCreationOptions = new ExternalDefinitionCreationOptions(m_name, SpecTypeId.ReinforcementLength);
|
||||
Bdef = group.
|
||||
Definitions.Create(ExternalDefinitionCreationOptions) as ExternalDefinition;
|
||||
}
|
||||
|
||||
return Bdef;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Yield the Parameter.
|
||||
/// </summary>
|
||||
/// <param name="defGroup">Definition group</param>
|
||||
public abstract void Commit(Autodesk.Revit.DB.Document doc, DefinitionGroup defGroup);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// (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.NewRebar.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class wraps a double parameter which will be the dimension of
|
||||
/// RebarShape definition.
|
||||
/// </summary>
|
||||
class RebarShapeParameterDouble : RebarShapeParameter
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameter double value.
|
||||
/// </summary>
|
||||
private Double m_value;
|
||||
|
||||
/// <summary>
|
||||
/// Parameter double value.
|
||||
/// </summary>
|
||||
public Double Value
|
||||
{
|
||||
get { return m_value; }
|
||||
set { m_value = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="shapeDef">RebarShapeDefinition proxy</param>
|
||||
/// <param name="name">Parameter name</param>
|
||||
/// <param name="value">Parameter double value</param>
|
||||
public RebarShapeParameterDouble(RebarShapeDef shapeDef, String name, Double value)
|
||||
: base(shapeDef, name)
|
||||
{
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a double parameter to RebarShapeDefinition.
|
||||
/// </summary>
|
||||
/// <param name="defGroup">Definition group</param>
|
||||
public override void Commit(Autodesk.Revit.DB.Document doc, DefinitionGroup defGroup)
|
||||
{
|
||||
ExternalDefinition def = GetOrCreateDef(defGroup);
|
||||
m_parameterId = Autodesk.Revit.DB.Structure.RebarShapeParameters.GetOrCreateElementIdForExternalDefinition(doc, def);
|
||||
m_rebarShapeDef.RebarshapeDefinition.AddParameter(m_parameterId, m_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// (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.NewRebar.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class wraps a formula parameter which will be the dimension of
|
||||
/// RebarShape definition.
|
||||
/// </summary>
|
||||
class RebarShapeParameterFormula : RebarShapeParameter
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameter formula sting.
|
||||
/// </summary>
|
||||
private string m_formula;
|
||||
|
||||
/// <summary>
|
||||
/// Parameter formula sting.
|
||||
/// </summary>
|
||||
public string Formula
|
||||
{
|
||||
get { return m_formula; }
|
||||
set { m_formula = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="shapeDef">RebarShapeDefinition proxy</param>
|
||||
/// <param name="name">Parameter name</param>
|
||||
/// <param name="formula">Parameter formula sting</param>
|
||||
public RebarShapeParameterFormula(RebarShapeDef shapeDef, string name, string formula)
|
||||
:base(shapeDef,name)
|
||||
{
|
||||
m_formula = formula;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a formula parameter to RebarShapeDefinition.
|
||||
/// </summary>
|
||||
/// <param name="defGroup">Definition group</param>
|
||||
public override void Commit(Autodesk.Revit.DB.Document doc, DefinitionGroup defGroup)
|
||||
{
|
||||
ExternalDefinition def = GetOrCreateDef(defGroup);
|
||||
m_parameterId = Autodesk.Revit.DB.Structure.RebarShapeParameters.GetOrCreateElementIdForExternalDefinition(doc, def);
|
||||
m_rebarShapeDef.RebarshapeDefinition.AddFormulaParameter(m_parameterId, m_formula);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// (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("Revit.SDK.Samples.NewRebar.CS")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Revit.SDK.Samples.NewRebar.CS")]
|
||||
[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("de5ec217-2e77-4366-a1e0-16d76cda614a")]
|
||||
|
||||
// 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")]
|
||||
@@ -0,0 +1,99 @@
|
||||
{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\froman\fprq2\fcharset0 Times New Roman;}}
|
||||
{\colortbl ;\red0\green0\blue255;}
|
||||
\viewkind4\uc1\pard\ltrpar\nowidctlpar\b\f0\fs20 Application:\b0 NewRebar\line\b Revit Platform:\b0 Structure\line\b Revit Version:\b0 2011.0\line\b First Released For:\b0 2009.0\line\b Programming Language:\b0 C#\line\b Skill Level:\b0 High\line\b Category:\b0 Structure\line\b Type:\b0 ExternalCommand\line\line\b Subject:\b0 Create Rebar and ReabrShapes.\line\b Summary:\b0 \line This sample will demonstrate how to create rebar via NewRebar (RebarShape rebarShape, RebarBarType rebarType, Element host, XYZ origin, XYZ xVec, XYZ yVec) and how to customize RebarShape (include straight segment and arc shape).\par
|
||||
\par
|
||||
\b Classes:\b0 \par
|
||||
\pard\ltrpar\nowidctlpar\fi360 Autodesk.Revit.UI.IExternalCommand \par
|
||||
Autodesk.Revit.Creation.Document\f1\par
|
||||
\f0 Autodesk.Revit.DB\f1 .\f0 FamilyInstance\f1\par
|
||||
\f0 Autodesk.Revit.DB.Structure.Rebar\f1\par
|
||||
\f0 Autodesk.Revit.DB.Structure.RebarShape\f1\par
|
||||
\f0 Autodesk.Revit.DB.Structure\f1 .\f0 RebarShapeDefinition\f1\par
|
||||
\f0 Autodesk.Revit.DB.Structure.RebarShapeDefinitionByArc\f1\par
|
||||
\f0 Autodesk.Revit.DB.Structure.RebarShapeDefinitionBySegments\par
|
||||
Autodesk.Revit.DB.Structure.StructuralType\par
|
||||
Autodesk.Revit.DB\f1 .\f0 Parameter\f1\par
|
||||
\f0 Autodesk.Revit.DB\f1 .\f0 DefinitionGroup\f1\par
|
||||
\f0 Autodesk.Revit.DB\f1 .\f0 ExternalDefinition\par
|
||||
Autodesk.Revit.DB.Solid\f1\par
|
||||
\pard\ltrpar\nowidctlpar\li720\f0\par
|
||||
\pard\ltrpar\nowidctlpar\b Project Files:\b0 \par
|
||||
Command.cs\par
|
||||
This is the entrance of this sample. It implements IExternalCommand Execute method.\f1\par
|
||||
\pard\ltrpar\nowidctlpar\li360\par
|
||||
\pard\ltrpar\nowidctlpar\f0 RebarCreator.cs\f1\par
|
||||
\f0 Class RebarCreator is defined in this file and it wraps the creation of Rebar. Its "Execute" method shows the main dialog for user and after that a Rebar will be created if user click OK button on the main dialog.\f1\par
|
||||
\par
|
||||
\f0 RebarShapeDef.cs\f1\par
|
||||
\f0 Class RebarShapeDef is defined in this file and it wraps RebarShapeDefinition object. It will be inherited by two classes: RebarShapeDefByArc and RebarShapeDefBySegment\f1 .\par
|
||||
\par
|
||||
\f0 RebarShapeDefByArc.cs\f1\par
|
||||
\f0 Class RebarShapeDefByArc is defined in this file and it wraps RebarShapeDefinitionByArc object\f1 .\par
|
||||
\par
|
||||
\f0 RebarShapeDefBySegment.cs\f1\par
|
||||
\f0 Class RebarShapeDefBySegment is defined in this file and it wraps RebarShapeDefinitionBySegments object\f1 .\par
|
||||
\f0\par
|
||||
RebarShapeParameter.cs\par
|
||||
Class RebarShapeParameter is defined in this file and it wraps an Autodesk.Revit.Parameter object which will be added to RebarShape definition. This is an abstract class and it will be inherited by two classes: RebarShapeParameterDouble and RebarShapeParameterFormula.\par
|
||||
\par
|
||||
RebarShapeParameterDouble.cs\par
|
||||
Class RebarShapeParameterDouble is defined in this file and it wraps a double parameter which will be added to RebarShape definition.\par
|
||||
\par
|
||||
RebarShapeParameterFormula.cs\par
|
||||
Class RebarShapeParameterFormula is defined in this file and it wraps a formula parameter which will be added to RebarShape definition.\par
|
||||
\par
|
||||
ConstraintOnRebarShape.cs\par
|
||||
Class ConstraintOnRebarShape is defined in this file and it wraps a constraint on Rebar Shape. It will be inherited by two classes: ConstraintOnSegmentShape and ConstraintOnArcShape.\par
|
||||
\par
|
||||
ConstraintOnSegmentShape.cs\par
|
||||
This file defines a series of classes which inherits from ConstraintOnSegmentShape. Each one can add a constraint to RebarShapeDefinitionBySegments.\par
|
||||
\par
|
||||
ConstraintOnArcShape.cs\par
|
||||
This file defines a series of classes which inherits from ConstraintOnArcShape. Each one can add a constraint to RebarShapeDefinitionByArc.\par
|
||||
\par
|
||||
GeometrySupport.cs\par
|
||||
Class GeometrySupport is defined in this file and it can be used to compute and store geometry information.\f1\par
|
||||
\par
|
||||
\f0 GeomUtil.cs\par
|
||||
Class GeomUtil is defined in this file and it provides the basic geometry operations\f1 .\par
|
||||
\par
|
||||
\f0 NewRebarForm.cs\f1\par
|
||||
\f0 This form is the main entrance for user to operate the Rebar creation.\f1\par
|
||||
\par
|
||||
\f0 NewRebarShapeForm.cs\f1\par
|
||||
\f0 This form is provided for user to define a new RebarShape.\f1\par
|
||||
\par
|
||||
\f0 AddParameterForm.cs\f1\par
|
||||
\f0 This form provides an entrance for user to add parameters to RebarShape.\f1\par
|
||||
\par
|
||||
\f0 AddConstraintForm.cs\par
|
||||
This form provides an entrance for user to add constraints to RebarShape.\f1\par
|
||||
\f0\par
|
||||
\b Description:\b0 \par
|
||||
This sample will demonstrate how to create rebar via NewRebar (RebarShape rebarShape, RebarBarType rebarType, Element host, XYZ origin, XYZ xVec, XYZ yVec) and how to customize RebarShape (include straight segment and arc shape). This sample will cover methods ScaleToBox and SetLayoutRuleWithoutExaminingHost of Rebar and almost all methods and properties of RebarShape. \par
|
||||
\par
|
||||
\b Instructions:\cf1\b0 \cf0\f1\par
|
||||
\pard\ltrpar\nowidctlpar\fi-360\li360\tx360\f0 1.\tab How to create a rebar?\par
|
||||
\pard\ltrpar\nowidctlpar\fi-420\li840\tx840 1)\tab Open or new a Revit project and make sure some concrete Beams or Columns without any rebar and with a rectangular shape are placed. A sample project file NewRebar.rvt is available in the sample\rquote s folder.\par
|
||||
2)\tab Select a concrete Beam or Column without any rebar and with a rectangular shape.\par
|
||||
\pard\ltrpar\nowidctlpar\fi-420\li840 3)\tab Invoke this command and the main dialog will be shown.\par
|
||||
4)\tab In the main dialog, select a RebarShape and a RebarBarType from the ComboBox, then click OK button, a rebar will be created on the selected Beam or Column.\f1\par
|
||||
\pard\ltrpar\nowidctlpar\fi-360\li360\tx360\f0 2.\tab How to customize a rebar shape by segments?\f1\par
|
||||
\pard\ltrpar\nowidctlpar\fi-420\li840\tx840\f0 1)\tab In the main dialog, give a rebar shape name and click radio Button by segments and input the segments number in the Text Box, then click \ldblquote Create Rebar Shape\rdblquote button, a form named \ldblquote Create RebarShape\rdblquote will be shown.\f1\par
|
||||
\pard\ltrpar\nowidctlpar\fi-420\li840\f0 2)\tab In the \ldblquote Create RebarShape\rdblquote form, parameters and constraints can be added to customize the rebar shape. Click button \ldblquote Add parameter\rdblquote will present a dialog to add parameter and click button \ldblquote Add Constraint\rdblquote will present a dialog to add constraint. After that, the parameter or the constraint will be displayed in the property grid, the parameter value and the constraints value can be changed from the property grid.\par
|
||||
\pard\ltrpar\nowidctlpar\fi-420\li840\tx840 3)\tab As for how to add parameters and constraints, here are some advice: \f1\par
|
||||
\pard\ltrpar\nowidctlpar\fi-420\li1620\tx1620\f0 a)\tab Each edge must have a length constraint and a direction constraint.\par
|
||||
\pard\ltrpar\nowidctlpar\fi-420\li1620 b)\tab Each vertex must have a bend constraint.\par
|
||||
c)\tab Listening constraints are not necessary.\par
|
||||
\pard\ltrpar\nowidctlpar\li720\f1\par
|
||||
\pard\ltrpar\nowidctlpar\fi-420\li840\tx840\f0 4)\tab After parameters and constraints are added, click OK button to submit the customize rebar shape.\par
|
||||
\pard\ltrpar\nowidctlpar \par
|
||||
\pard\ltrpar\nowidctlpar\fi-360\li360\tx360 3.\tab How to customize a rebar shape by arc?\f1\par
|
||||
\pard\ltrpar\nowidctlpar\fi-420\li840\tx840\f0 1)\tab In the main dialog, give a rebar shape name and click radio Button by arc and select the arc type from the ComboBox, then click \ldblquote Create rebar shape\rdblquote button, a form named \ldblquote Create RebarShape\rdblquote will be shown.\par
|
||||
\pard\ltrpar\nowidctlpar\fi-420\li840 2)\tab In the \ldblquote Create RebarShape\rdblquote form, parameters and constraints can be added to customize the rebar shape. Click button \ldblquote Add Parameter\rdblquote will present a dialog to add parameter and click button \ldblquote Add Constraint\rdblquote will present a dialog to add constraint. After that, the parameter or the constraint will be displayed in the property grid, the parameter value and the constraints value can be changed from the property grid.\par
|
||||
\pard\ltrpar\nowidctlpar\fi-420\li840\tx840 3)\tab After parameters and constraints are added, click OK button to submit the customize rebar shape.\f1\par
|
||||
\pard\ltrpar\nowidctlpar\par
|
||||
\b\f0 Customize Rebar Shapes Step by step:\par
|
||||
\b0 Under folder \ldblquote Customize RebarShapes Step by step\rdblquote , there are four help doc to help user customize Rebar Shapes step by step. \f1\par
|
||||
}
|
||||
| ||||