mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-19 10:45:56 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,708 @@
|
||||
//
|
||||
// (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 System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.BoundaryConditions.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// BoundaryConditions Type Enumeration
|
||||
/// </summary>
|
||||
public enum BCType
|
||||
{
|
||||
/// <summary>
|
||||
/// Point BC
|
||||
/// </summary>
|
||||
Point = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Line BC
|
||||
/// </summary>
|
||||
Line,
|
||||
|
||||
/// <summary>
|
||||
/// Area BC
|
||||
/// </summary>
|
||||
Area
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions State Enumeration
|
||||
/// </summary>
|
||||
public enum BCState
|
||||
{
|
||||
/// <summary>
|
||||
/// the state of current BC is fixed
|
||||
/// </summary>
|
||||
Fixed = 0,
|
||||
|
||||
/// <summary>
|
||||
/// the state of current BC is Pinned
|
||||
/// </summary>
|
||||
Pinned,
|
||||
|
||||
/// <summary>
|
||||
/// the state of current BC is Roller
|
||||
/// </summary>
|
||||
Roller,
|
||||
|
||||
/// <summary>
|
||||
/// the state of current BC is decided by user
|
||||
/// </summary>
|
||||
User
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions Translation/Rotation Enumeration
|
||||
/// </summary>
|
||||
public enum BCTranslationRotation
|
||||
{
|
||||
/// <summary>
|
||||
/// the BC is fixed, can used when any BCState
|
||||
/// </summary>
|
||||
Fixed = 0,
|
||||
|
||||
/// <summary>
|
||||
/// the BC's Translation/Rotation can released
|
||||
/// </summary>
|
||||
Released,
|
||||
|
||||
/// <summary>
|
||||
/// user can set the BC's Translation/Rotation spring modulus.
|
||||
/// Only can be used when the BCState is User
|
||||
/// </summary>
|
||||
Spring,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// A custom attribute to allow a target to have a pet.
|
||||
/// this attribute is about the BoundaryConditions Type Enumeration
|
||||
/// </summary>
|
||||
public sealed class BCTypeAttribute : Attribute
|
||||
{
|
||||
// Keep a variable internally ...
|
||||
private BCType[] m_bCTypes;
|
||||
|
||||
/// <summary>
|
||||
/// The constructor is called when the attribute is set.
|
||||
/// </summary>
|
||||
/// <param name="bcTypes"></param>
|
||||
public BCTypeAttribute(BCType[] bcTypes)
|
||||
{
|
||||
m_bCTypes = bcTypes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// property get or set internal variable m_bcTypes
|
||||
/// </summary>
|
||||
public BCType[] BCType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bCTypes;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bCTypes = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// override Equals method
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
BCTypeAttribute temp = obj as BCTypeAttribute;
|
||||
if (null == temp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (BCType t1 in temp.BCType)
|
||||
{
|
||||
foreach (BCType t2 in m_bCTypes)
|
||||
{
|
||||
if (t1 == t2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// override GetHashCode method
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// use to create instance as the display object of the PropertyGrid
|
||||
/// </summary>
|
||||
public class BCProperties
|
||||
{
|
||||
// the boundary conditions of which the information will displayed in the UI grid
|
||||
private Autodesk.Revit.DB.Structure.BoundaryConditions m_bC;
|
||||
|
||||
#region "Properties"
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions Type
|
||||
/// this item will be displayed no matter the point BC,line BC or area BC
|
||||
/// </summary>
|
||||
[Category("Structural Analysis"),ReadOnly(true),
|
||||
BCType(new BCType[] { BCType.Point, BCType.Line, BCType.Area })]
|
||||
public BCType BoundaryConditionsType
|
||||
{
|
||||
get
|
||||
{
|
||||
return (BCType)GetParameterValue("Boundary Conditions Type",
|
||||
BuiltInParameterGroup.PG_STRUCTURAL_ANALYSIS);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetParameterValue("Boundary Conditions Type",
|
||||
BuiltInParameterGroup.PG_STRUCTURAL_ANALYSIS, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions State
|
||||
/// </summary>
|
||||
[Category("Structural Analysis"),
|
||||
BCType(new BCType[] { BCType.Point, BCType.Line, BCType.Area })]
|
||||
public BCState State
|
||||
{
|
||||
get
|
||||
{
|
||||
return (BCState)GetParameterValue("State", BuiltInParameterGroup.PG_STRUCTURAL_ANALYSIS);
|
||||
}
|
||||
// Point BC includes Fixed, Pinned, Roller and User four different State;
|
||||
// Line BC includes Fixed, Pinned and User;
|
||||
// while the Area BC includes Pinned and User.
|
||||
set
|
||||
{
|
||||
if (BCType.Area == BoundaryConditionsType)
|
||||
{
|
||||
if (BCState.Fixed != value && BCState.Roller != value)
|
||||
{
|
||||
SetParameterValue("State", BuiltInParameterGroup.PG_STRUCTURAL_ANALYSIS, value);
|
||||
}
|
||||
}
|
||||
else if (BCType.Line == BoundaryConditionsType)
|
||||
{
|
||||
if (BCState.Roller != value)
|
||||
{
|
||||
SetParameterValue("State", BuiltInParameterGroup.PG_STRUCTURAL_ANALYSIS, value); ;
|
||||
}
|
||||
}
|
||||
else if (BCType.Point == BoundaryConditionsType)
|
||||
{
|
||||
SetParameterValue("State", BuiltInParameterGroup.PG_STRUCTURAL_ANALYSIS, value); ;
|
||||
}
|
||||
|
||||
// other parameters do corresponding change when the State is changed.
|
||||
MatchBCValuesRule();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions XTranslation
|
||||
/// </summary>
|
||||
[Description("This value can be edit under User state"),Category("Translation in"),
|
||||
BCType(new BCType[]{BCType.Point, BCType.Line, BCType.Area})]
|
||||
public BCTranslationRotation XTranslation
|
||||
{
|
||||
get
|
||||
{
|
||||
return (BCTranslationRotation)GetParameterValue("X Translation",
|
||||
BuiltInParameterGroup.PG_TRANSLATION_IN);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (BCState.User == State)
|
||||
{
|
||||
SetParameterValue("X Translation", BuiltInParameterGroup.PG_TRANSLATION_IN, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions SpringModulus about XTranslation
|
||||
/// </summary>
|
||||
[Category("Translation in")]
|
||||
public double XTranslationSpringModulus
|
||||
{
|
||||
get
|
||||
{
|
||||
return (double)GetParameterValue("X Spring Modulus",
|
||||
BuiltInParameterGroup.PG_TRANSLATION_IN);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetParameterValue("X Spring Modulus", BuiltInParameterGroup.PG_TRANSLATION_IN, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryCondition YTranslation
|
||||
/// </summary>
|
||||
[Description("This value can be edit under User state"),Category("Translation in"),
|
||||
BCType(new BCType[] { BCType.Point, BCType.Line, BCType.Area })]
|
||||
public BCTranslationRotation YTranslation
|
||||
{
|
||||
get
|
||||
{
|
||||
return (BCTranslationRotation)GetParameterValue("Y Translation",
|
||||
BuiltInParameterGroup.PG_TRANSLATION_IN);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (BCState.User == State)
|
||||
{
|
||||
SetParameterValue("Y Translation", BuiltInParameterGroup.PG_TRANSLATION_IN, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions SpringModulus about YTranslation
|
||||
/// </summary>
|
||||
[Category("Translation in")]
|
||||
public double YTranslationSpringModulus
|
||||
{
|
||||
get
|
||||
{
|
||||
return (double)GetParameterValue("Y Spring Modulus",
|
||||
BuiltInParameterGroup.PG_TRANSLATION_IN);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetParameterValue("Y Spring Modulus", BuiltInParameterGroup.PG_TRANSLATION_IN, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions ZTranslation
|
||||
/// </summary>
|
||||
[Description("This value can be edit under User state"), Category("Translation in"),
|
||||
BCType(new BCType[] { BCType.Point, BCType.Line, BCType.Area })]
|
||||
public BCTranslationRotation ZTranslation
|
||||
{
|
||||
get
|
||||
{
|
||||
return (BCTranslationRotation)GetParameterValue("Z Translation",
|
||||
BuiltInParameterGroup.PG_TRANSLATION_IN);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (BCState.User == State)
|
||||
{
|
||||
SetParameterValue("Z Translation", BuiltInParameterGroup.PG_TRANSLATION_IN, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions SpringModulus about ZTranslation
|
||||
/// </summary>
|
||||
[Category("Translation in")]
|
||||
public double ZTranslationSpringModulus
|
||||
{
|
||||
get
|
||||
{
|
||||
return (double)GetParameterValue("Z Spring Modulus",
|
||||
BuiltInParameterGroup.PG_TRANSLATION_IN);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetParameterValue("Z Spring Modulus", BuiltInParameterGroup.PG_TRANSLATION_IN, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions XRotation
|
||||
/// only displayed when the BC Type is point or line
|
||||
/// </summary>
|
||||
[Description("This value can be edit under User state"), Category("Rotation about"),
|
||||
BCType(new BCType[] { BCType.Point, BCType.Line})]
|
||||
public BCTranslationRotation XRotation
|
||||
{
|
||||
get
|
||||
{
|
||||
return (BCTranslationRotation)GetParameterValue("X Rotation",
|
||||
BuiltInParameterGroup.PG_ROTATION_ABOUT);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (BCState.User == State)
|
||||
{
|
||||
SetParameterValue("X Rotation", BuiltInParameterGroup.PG_ROTATION_ABOUT, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions SpringModulus about XRotation
|
||||
/// </summary>
|
||||
[Category("Rotation about")]
|
||||
public double XRotationSpringModulus
|
||||
{
|
||||
get
|
||||
{
|
||||
return (double)GetParameterValue("X Spring Modulus",
|
||||
BuiltInParameterGroup.PG_ROTATION_ABOUT);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetParameterValue("X Spring Modulus", BuiltInParameterGroup.PG_ROTATION_ABOUT, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions YRotation
|
||||
/// Only be displayed when the BC Type is point
|
||||
/// </summary>
|
||||
[ Description("This value can be edit under User state"),Category("Rotation about"),
|
||||
BCType(new BCType[] { BCType.Point})]
|
||||
public BCTranslationRotation YRotation
|
||||
{
|
||||
get
|
||||
{
|
||||
return (BCTranslationRotation)GetParameterValue("Y Rotation",
|
||||
BuiltInParameterGroup.PG_ROTATION_ABOUT);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (BCState.User == State)
|
||||
{
|
||||
SetParameterValue("Y Rotation", BuiltInParameterGroup.PG_ROTATION_ABOUT, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions SpringModulus about YRotation
|
||||
/// </summary>
|
||||
[Category("Rotation about")]
|
||||
public double YRotationSpringModulus
|
||||
{
|
||||
get
|
||||
{
|
||||
return (double)GetParameterValue("Y Spring Modulus",
|
||||
BuiltInParameterGroup.PG_ROTATION_ABOUT);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetParameterValue("Y Spring Modulus", BuiltInParameterGroup.PG_ROTATION_ABOUT, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions ZRotation
|
||||
/// </summary>
|
||||
[Description("This value can be edit under User state"),
|
||||
Category("Rotation about"),BCType(new BCType[] { BCType.Point })]
|
||||
public BCTranslationRotation ZRotation
|
||||
{
|
||||
get
|
||||
{
|
||||
return (BCTranslationRotation)GetParameterValue("Z Rotation",
|
||||
BuiltInParameterGroup.PG_ROTATION_ABOUT);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (BCState.User == State)
|
||||
{
|
||||
SetParameterValue("Z Rotation", BuiltInParameterGroup.PG_ROTATION_ABOUT, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BoundaryConditions SpringModulus about ZRotation
|
||||
/// </summary>
|
||||
[Category("Rotation about")]
|
||||
public double ZRotationSpringModulus
|
||||
{
|
||||
get
|
||||
{
|
||||
return (double)GetParameterValue("Z Spring Modulus",
|
||||
BuiltInParameterGroup.PG_ROTATION_ABOUT);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetParameterValue("Z Spring Modulus", BuiltInParameterGroup.PG_ROTATION_ABOUT, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region "Methods"
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="bC">
|
||||
/// the boundary conditions of which the information will displayed in the UI grid
|
||||
/// </param>
|
||||
public BCProperties(Autodesk.Revit.DB.Structure.BoundaryConditions bC)
|
||||
{
|
||||
m_bC = bC;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When Spring is selected for Translation/Rotation the user enter a positive value
|
||||
/// greater than Zero as the corresponding Spring Modulus.
|
||||
/// And according to its display unit do the conversion between display value and inside value.
|
||||
/// </summary>
|
||||
/// <param name="gridItemLabel">the name of parameter which value is spring</param>
|
||||
public void SetSpringModulus(string gridItemLabel)
|
||||
{
|
||||
using (SpringModulusForm springModulusForm = new SpringModulusForm())
|
||||
{
|
||||
// judge current conversion rule between the display value and inside value
|
||||
if (BCType.Point == BoundaryConditionsType)
|
||||
{
|
||||
if (gridItemLabel.Contains("Translation"))
|
||||
{
|
||||
springModulusForm.Conversion = UnitConversion.UnitDictionary["PTSpringModulusConver"];
|
||||
}
|
||||
else if (gridItemLabel.Contains("Rotation"))
|
||||
{
|
||||
springModulusForm.Conversion = UnitConversion.UnitDictionary["PRSpringModulusConver"];
|
||||
}
|
||||
}
|
||||
else if (BCType.Line == BoundaryConditionsType)
|
||||
{
|
||||
if (gridItemLabel.Contains("Translation"))
|
||||
{
|
||||
springModulusForm.Conversion = UnitConversion.UnitDictionary["LTSpringModulusConver"];
|
||||
}
|
||||
else if (gridItemLabel.Contains("Rotation"))
|
||||
{
|
||||
springModulusForm.Conversion = UnitConversion.UnitDictionary["LRSpringModulusConver"];
|
||||
}
|
||||
}
|
||||
else if (BCType.Area == BoundaryConditionsType && gridItemLabel.Contains("Translation"))
|
||||
{
|
||||
springModulusForm.Conversion = UnitConversion.UnitDictionary["ATSpringModulusConver"];
|
||||
}
|
||||
|
||||
// get the old value
|
||||
if ("XTranslation" == gridItemLabel)
|
||||
{
|
||||
springModulusForm.OldStringModulus = XTranslationSpringModulus;
|
||||
}
|
||||
else if ("YTranslation" == gridItemLabel)
|
||||
{
|
||||
springModulusForm.OldStringModulus = YTranslationSpringModulus;
|
||||
}
|
||||
else if ("ZTranslation" == gridItemLabel)
|
||||
{
|
||||
springModulusForm.OldStringModulus = ZTranslationSpringModulus;
|
||||
}
|
||||
else if ("XRotation" == gridItemLabel)
|
||||
{
|
||||
springModulusForm.OldStringModulus = XRotationSpringModulus;
|
||||
}
|
||||
else if ("YRotation" == gridItemLabel)
|
||||
{
|
||||
springModulusForm.OldStringModulus = YRotationSpringModulus;
|
||||
}
|
||||
else if ("ZRotation" == gridItemLabel)
|
||||
{
|
||||
springModulusForm.OldStringModulus = ZRotationSpringModulus;
|
||||
}
|
||||
|
||||
// show the spring modulus dialog to ask a positive number
|
||||
DialogResult result = springModulusForm.ShowDialog();
|
||||
|
||||
// set the user input number as the new value
|
||||
if (DialogResult.OK == result)
|
||||
{
|
||||
if ("XTranslation" == gridItemLabel)
|
||||
{
|
||||
XTranslationSpringModulus = springModulusForm.StringModulus;
|
||||
}
|
||||
else if ("YTranslation" == gridItemLabel)
|
||||
{
|
||||
YTranslationSpringModulus = springModulusForm.StringModulus;
|
||||
}
|
||||
else if ("ZTranslation" == gridItemLabel)
|
||||
{
|
||||
ZTranslationSpringModulus = springModulusForm.StringModulus;
|
||||
}
|
||||
else if ("XRotation" == gridItemLabel)
|
||||
{
|
||||
XRotationSpringModulus = springModulusForm.StringModulus;
|
||||
}
|
||||
else if ("YRotation" == gridItemLabel)
|
||||
{
|
||||
YRotationSpringModulus = springModulusForm.StringModulus;
|
||||
}
|
||||
else if ("ZRotation" == gridItemLabel)
|
||||
{
|
||||
ZRotationSpringModulus = springModulusForm.StringModulus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get parameter via matching the appointed name and group.
|
||||
/// and deal with it according to the type of Parameter's StorageType
|
||||
/// </summary>
|
||||
protected Object GetParameterValue(string parameterName, BuiltInParameterGroup parameterGroup)
|
||||
{
|
||||
ParameterSet parameters = m_bC.Parameters;
|
||||
foreach (Parameter parameter in parameters)
|
||||
{
|
||||
// find the parameter of which the name is the same as the param name
|
||||
if ((parameterName != parameter.Definition.Name) ||
|
||||
(parameterGroup != parameter.Definition.ParameterGroup))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// get the parameter value
|
||||
switch (parameter.StorageType)
|
||||
{
|
||||
case StorageType.Double:
|
||||
return parameter.AsDouble();
|
||||
case StorageType.Integer:
|
||||
return parameter.AsInteger();
|
||||
case StorageType.ElementId:
|
||||
return parameter.AsElementId();
|
||||
case StorageType.String:
|
||||
return parameter.AsString();
|
||||
case StorageType.None:
|
||||
return parameter.AsValueString();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// when user changed the parameter value via the UI set this changed parameter value
|
||||
/// </summary>
|
||||
/// <param name="parameterName">the name of the changed parameter</param>
|
||||
/// <param name="parameterGroup">
|
||||
/// because some parameters of boundary conditions have the same name
|
||||
/// </param>
|
||||
/// <param name="value">the new parameter value</param>
|
||||
protected void SetParameterValue(string parameterName,
|
||||
BuiltInParameterGroup parameterGroup,
|
||||
Object value)
|
||||
{
|
||||
ParameterSet parameters = m_bC.Parameters;
|
||||
foreach (Parameter parameter in parameters)
|
||||
{
|
||||
// find the parameter of which the name is the same as the param name
|
||||
if ((parameterName != parameter.Definition.Name) ||
|
||||
(parameterGroup != parameter.Definition.ParameterGroup))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// get the parameter value
|
||||
switch (parameter.StorageType)
|
||||
{
|
||||
case StorageType.Double:
|
||||
parameter.Set((double)value);
|
||||
break;
|
||||
case StorageType.Integer:
|
||||
parameter.Set((int)value);
|
||||
break;
|
||||
case StorageType.ElementId:
|
||||
Autodesk.Revit.DB.ElementId Id = (Autodesk.Revit.DB.ElementId)value;
|
||||
parameter.Set(Id);
|
||||
break;
|
||||
case StorageType.String:
|
||||
parameter.Set(value as string);
|
||||
break;
|
||||
case StorageType.None:
|
||||
parameter.SetValueString(value as string);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the BC parameter values rules according to the Revit main program.
|
||||
/// For example, when the State is Fixed all the Translation/Rotation parameters are Fixed too.
|
||||
/// </summary>
|
||||
private void MatchBCValuesRule()
|
||||
{
|
||||
if (BCState.Fixed == State)
|
||||
{
|
||||
XTranslation = BCTranslationRotation.Fixed;
|
||||
YTranslation = BCTranslationRotation.Fixed;
|
||||
ZTranslation = BCTranslationRotation.Fixed;
|
||||
XRotation = BCTranslationRotation.Fixed;
|
||||
YRotation = BCTranslationRotation.Fixed;
|
||||
ZRotation = BCTranslationRotation.Fixed;
|
||||
}
|
||||
else if (BCState.Pinned == State)
|
||||
{
|
||||
XTranslation = BCTranslationRotation.Fixed;
|
||||
YTranslation = BCTranslationRotation.Fixed;
|
||||
ZTranslation = BCTranslationRotation.Fixed;
|
||||
ZRotation = BCTranslationRotation.Released;
|
||||
YRotation = BCTranslationRotation.Released;
|
||||
ZRotation = BCTranslationRotation.Released;
|
||||
}
|
||||
else if (BCState.Roller == State)
|
||||
{
|
||||
XTranslation = BCTranslationRotation.Released;
|
||||
YTranslation = BCTranslationRotation.Released;
|
||||
ZTranslation = BCTranslationRotation.Fixed;
|
||||
XRotation = BCTranslationRotation.Released;
|
||||
YRotation = BCTranslationRotation.Released;
|
||||
ZRotation = BCTranslationRotation.Released;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>BoundaryConditions.dll</Assembly>
|
||||
<ClientId>71ac558f-0ce7-4e97-8a36-67bbb86a0229</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.BoundaryConditions.CS.Command</FullClassName>
|
||||
<Text>Boundary Conditions</Text>
|
||||
<Description>Display the BoundaryConditions' parameters or create a new BoundaryConditions instance.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?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>{8A4355DF-E929-490F-8DE9-1CA755920C4D}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BoundaryConditions</RootNamespace>
|
||||
<AssemblyName>BoundaryConditions</AssemblyName>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
<CodeAnalysisRules>-Microsoft.Globalization#CA1301;-Microsoft.Globalization#CA1302;-Microsoft.Globalization#CA1303;-Microsoft.Globalization#CA1306;-Microsoft.Globalization#CA1304;-Microsoft.Globalization#CA1305;-Microsoft.Globalization#CA1300;-Microsoft.Interoperability#CA1403;-Microsoft.Interoperability#CA1406;-Microsoft.Interoperability#CA1413;-Microsoft.Interoperability#CA1402;-Microsoft.Interoperability#CA1407;-Microsoft.Interoperability#CA1404;-Microsoft.Interoperability#CA1410;-Microsoft.Interoperability#CA1411;-Microsoft.Interoperability#CA1405;-Microsoft.Interoperability#CA1409;-Microsoft.Interoperability#CA1415;-Microsoft.Interoperability#CA1408;-Microsoft.Interoperability#CA1414;-Microsoft.Interoperability#CA1412;-Microsoft.Interoperability#CA1400;-Microsoft.Interoperability#CA1401;-Microsoft.Mobility#CA1600;-Microsoft.Mobility#CA1601;-Microsoft.Portability#CA1901;-Microsoft.Portability#CA1900;-Microsoft.Reliability#CA2000;-Microsoft.Reliability#CA2002;-Microsoft.Reliability#CA2003;-Microsoft.Reliability#CA2004;-Microsoft.Reliability#CA2006;-Microsoft.Security#CA2116;-Microsoft.Security#CA2117;-Microsoft.Security#CA2105;-Microsoft.Security#CA2115;-Microsoft.Security#CA2104;-Microsoft.Security#CA2122;-Microsoft.Security#CA2114;-Microsoft.Security#CA2123;-Microsoft.Security#CA2111;-Microsoft.Security#CA2108;-Microsoft.Security#CA2107;-Microsoft.Security#CA2103;-Microsoft.Security#CA2100;-Microsoft.Security#CA2118;-Microsoft.Security#CA2109;-Microsoft.Security#CA2119;-Microsoft.Security#CA2106;-Microsoft.Security#CA2112;-Microsoft.Security#CA2110;-Microsoft.Security#CA2120;-Microsoft.Security#CA2101;-Microsoft.Security#CA2121;-Microsoft.Security#CA2126;-Microsoft.Security#CA2124</CodeAnalysisRules>
|
||||
</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>
|
||||
<CodeAnalysisRules>-Microsoft.Globalization#CA1301;-Microsoft.Globalization#CA1302;-Microsoft.Globalization#CA1303;-Microsoft.Globalization#CA1306;-Microsoft.Globalization#CA1304;-Microsoft.Globalization#CA1305;-Microsoft.Globalization#CA1300;-Microsoft.Interoperability#CA1403;-Microsoft.Interoperability#CA1406;-Microsoft.Interoperability#CA1413;-Microsoft.Interoperability#CA1402;-Microsoft.Interoperability#CA1407;-Microsoft.Interoperability#CA1404;-Microsoft.Interoperability#CA1410;-Microsoft.Interoperability#CA1411;-Microsoft.Interoperability#CA1405;-Microsoft.Interoperability#CA1409;-Microsoft.Interoperability#CA1415;-Microsoft.Interoperability#CA1408;-Microsoft.Interoperability#CA1414;-Microsoft.Interoperability#CA1412;-Microsoft.Interoperability#CA1400;-Microsoft.Interoperability#CA1401;-Microsoft.Mobility#CA1600;-Microsoft.Mobility#CA1601;-Microsoft.Portability#CA1901;-Microsoft.Portability#CA1900;-Microsoft.Reliability#CA2000;-Microsoft.Reliability#CA2002;-Microsoft.Reliability#CA2003;-Microsoft.Reliability#CA2004;-Microsoft.Reliability#CA2006;-Microsoft.Security#CA2116;-Microsoft.Security#CA2117;-Microsoft.Security#CA2105;-Microsoft.Security#CA2115;-Microsoft.Security#CA2104;-Microsoft.Security#CA2122;-Microsoft.Security#CA2114;-Microsoft.Security#CA2123;-Microsoft.Security#CA2111;-Microsoft.Security#CA2108;-Microsoft.Security#CA2107;-Microsoft.Security#CA2103;-Microsoft.Security#CA2100;-Microsoft.Security#CA2118;-Microsoft.Security#CA2109;-Microsoft.Security#CA2119;-Microsoft.Security#CA2106;-Microsoft.Security#CA2112;-Microsoft.Security#CA2110;-Microsoft.Security#CA2120;-Microsoft.Security#CA2101;-Microsoft.Security#CA2121;-Microsoft.Security#CA2126;-Microsoft.Security#CA2124</CodeAnalysisRules>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</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="BCProperties.cs" />
|
||||
<Compile Include="BoundaryConditionsData.cs" />
|
||||
<Compile Include="BoundaryConditionsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BoundaryConditionsForm.Designer.cs">
|
||||
<DependentUpon>BoundaryConditionsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="SpringModulusForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SpringModulusForm.Designer.cs">
|
||||
<DependentUpon>SpringModulusForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UnitConversion.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="BoundaryConditionsForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>BoundaryConditionsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="SpringModulusForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>SpringModulusForm.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,280 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
|
||||
namespace Revit.SDK.Samples.BoundaryConditions.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// user select a element. If the selected element has boundary conditions, display
|
||||
/// its parameter values else create one.
|
||||
/// this class prepare the needed data(the selected element type and its BC information)
|
||||
/// and operate the Revit API
|
||||
/// </summary>
|
||||
public class BoundaryConditionsData
|
||||
{
|
||||
#region "Members"
|
||||
|
||||
// the selected Element
|
||||
private Autodesk.Revit.DB.Element m_hostElement;
|
||||
|
||||
// store all the corresponding BCs of the current selected host element
|
||||
// and use the BC Id value as the key
|
||||
private Dictionary<int, Autodesk.Revit.DB.Structure.BoundaryConditions> m_bCsDictionary =
|
||||
new Dictionary<int, Autodesk.Revit.DB.Structure.BoundaryConditions>();
|
||||
|
||||
// the object for which the grid in UI displays.
|
||||
private BCProperties m_bCProperties;
|
||||
|
||||
#endregion
|
||||
|
||||
#region "Properties"
|
||||
|
||||
/// <summary>
|
||||
/// gets or sets the object for which the grid in UI displays.
|
||||
/// </summary>
|
||||
public BCProperties BCProperties
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bCProperties;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bCProperties = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get current host element
|
||||
/// </summary>
|
||||
public Autodesk.Revit.DB.Element HostElement
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_hostElement;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get all the BCs correspond with current host
|
||||
/// </summary>
|
||||
public Dictionary<int, Autodesk.Revit.DB.Structure.BoundaryConditions> BCs
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bCsDictionary;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region "Delegate"
|
||||
|
||||
//A delegate for create boundary condition with different type
|
||||
private delegate Autodesk.Revit.DB.Structure.BoundaryConditions
|
||||
CreateBCHandler(Autodesk.Revit.DB.Element HostElement);
|
||||
|
||||
#endregion
|
||||
|
||||
#region "Methods"
|
||||
|
||||
/// <summary>
|
||||
/// construct function
|
||||
/// </summary>
|
||||
/// <param name="element"> host element</param>
|
||||
public BoundaryConditionsData(Autodesk.Revit.DB.Element element)
|
||||
{
|
||||
// store the selected element and its BCs
|
||||
SetBCHostMap(element);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// According to the selected element create corresponding Boundary Conditions.
|
||||
/// Add it into m_bCsDictionary.
|
||||
/// </summary>
|
||||
public bool CreateBoundaryConditions()
|
||||
{
|
||||
CreateBCHandler createBCH = null;
|
||||
|
||||
// judge the type of the HostElement
|
||||
if (m_hostElement is FamilyInstance)
|
||||
{
|
||||
FamilyInstance familyInstance = m_hostElement as FamilyInstance;
|
||||
StructuralType structuralType = familyInstance.StructuralType;
|
||||
|
||||
if (structuralType == StructuralType.Beam)
|
||||
{
|
||||
// create Line BC for beam
|
||||
createBCH = new CreateBCHandler(CreateLineBC);
|
||||
}
|
||||
else if (structuralType == StructuralType.Brace ||
|
||||
structuralType == StructuralType.Column ||
|
||||
structuralType == StructuralType.Footing)
|
||||
{
|
||||
// create point BC for Column/brace
|
||||
createBCH = new CreateBCHandler(CreatePointBC);
|
||||
}
|
||||
}
|
||||
else if (m_hostElement is Wall)
|
||||
{
|
||||
// create line BC for wall
|
||||
createBCH = new CreateBCHandler(CreateLineBC);
|
||||
}
|
||||
else if (m_hostElement is Floor)
|
||||
{
|
||||
// create area BC for Floor
|
||||
createBCH = new CreateBCHandler(CreateAreaBC);
|
||||
}
|
||||
else if (m_hostElement is WallFoundation)
|
||||
{
|
||||
// create line BC for WallFoundation
|
||||
createBCH = new CreateBCHandler(CreateLineBC);
|
||||
}
|
||||
|
||||
// begin create
|
||||
Autodesk.Revit.DB.Structure.BoundaryConditions NewBC = null;
|
||||
try
|
||||
{
|
||||
NewBC = createBCH(m_hostElement);
|
||||
if (null == NewBC)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// add the created Boundary Conditions into m_bCsDictionary
|
||||
m_bCsDictionary.Add(NewBC.Id.IntegerValue, NewBC);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// store the selected element and its corresponding BCs
|
||||
/// </summary>
|
||||
/// <param name="element"> use selected element in Revit UI(the host element)</param>
|
||||
private void SetBCHostMap(Autodesk.Revit.DB.Element element)
|
||||
{
|
||||
// set the Host element with current selected element
|
||||
m_hostElement = element;
|
||||
// retrieve the Document in which the Element resides.
|
||||
Document doc = element.Document;
|
||||
|
||||
IEnumerable<Autodesk.Revit.DB.Structure.BoundaryConditions> boundaryConditions = from elem in
|
||||
new FilteredElementCollector(doc).OfClass(typeof(Autodesk.Revit.DB.Structure.BoundaryConditions)).ToElements()
|
||||
let bC = elem as Autodesk.Revit.DB.Structure.BoundaryConditions
|
||||
where bC != null && m_hostElement.Id.IntegerValue == bC.HostElement.Id.IntegerValue
|
||||
select bC;
|
||||
foreach (Autodesk.Revit.DB.Structure.BoundaryConditions bC in boundaryConditions)
|
||||
{
|
||||
m_bCsDictionary.Add(bC.Id.IntegerValue, bC);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new Point BoundaryConditions Element.
|
||||
/// All the parameter default as Fixed.
|
||||
/// </summary>
|
||||
/// <param name="hostElement">
|
||||
/// structural element which provide the analytical line end reference
|
||||
/// </param>
|
||||
/// <returns> the created Point BoundaryConditions Element</returns>
|
||||
private Autodesk.Revit.DB.Structure.BoundaryConditions CreatePointBC(Autodesk.Revit.DB.Element hostElement)
|
||||
{
|
||||
if (!(hostElement is FamilyInstance))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
FamilyInstance familyInstance = hostElement as FamilyInstance;
|
||||
AnalyticalModel analyticalModel = familyInstance.GetAnalyticalModel();
|
||||
Reference endReference = null;
|
||||
|
||||
Curve refCurve = analyticalModel.GetCurve();
|
||||
if (null != refCurve)
|
||||
{
|
||||
|
||||
endReference = analyticalModel.GetReference(new AnalyticalModelSelector(refCurve,AnalyticalCurveSelector.EndPoint));
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Autodesk.Revit.Creation.Document createDoc = hostElement.Document.Create;
|
||||
|
||||
// invoke Document.NewPointBoundaryConditions Method
|
||||
Autodesk.Revit.DB.Structure.BoundaryConditions createdBC =
|
||||
createDoc.NewPointBoundaryConditions(endReference, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
return createdBC;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new Line BoundaryConditions Element.
|
||||
/// All the parameter default as Fixed.
|
||||
/// </summary>
|
||||
/// <param name="hostElement">structural element which provide the hostElementId</param>
|
||||
/// <returns>the created Point BoundaryConditions Element</returns>
|
||||
private Autodesk.Revit.DB.Structure.BoundaryConditions CreateLineBC(Autodesk.Revit.DB.Element hostElement)
|
||||
{
|
||||
Autodesk.Revit.Creation.Document createDoc = hostElement.Document.Create;
|
||||
|
||||
// invoke Document.NewLineBoundaryConditions Method
|
||||
Autodesk.Revit.DB.Structure.BoundaryConditions createdBC =
|
||||
createDoc.NewLineBoundaryConditions(hostElement.GetAnalyticalModel(), 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
return createdBC;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new Area BoundaryConditions Element.
|
||||
/// All the parameter default as Fixed.
|
||||
/// </summary>
|
||||
/// <param name="hostElement">structural element which provide the hostElementId</param>
|
||||
/// <returns>the created Point BoundaryConditions Element</returns>
|
||||
private Autodesk.Revit.DB.Structure.BoundaryConditions CreateAreaBC(Autodesk.Revit.DB.Element hostElement)
|
||||
{
|
||||
Autodesk.Revit.Creation.Document createDoc = hostElement.Document.Create;
|
||||
|
||||
// invoke Document.NewAreaBoundaryConditions Method
|
||||
Autodesk.Revit.DB.Structure.BoundaryConditions createdBC =
|
||||
createDoc.NewAreaBoundaryConditions(hostElement.GetAnalyticalModel(), 0, 0, 0, 0, 0, 0);
|
||||
|
||||
return createdBC;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
//
|
||||
// (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.BoundaryConditions.CS
|
||||
{
|
||||
partial class BoundaryConditionsForm
|
||||
{
|
||||
/// <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.bCLabel = new System.Windows.Forms.Label();
|
||||
this.hostLabel = new System.Windows.Forms.Label();
|
||||
this.bCPropertyGrid = new System.Windows.Forms.PropertyGrid();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.bCComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.hostTextBox = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// bCLabel
|
||||
//
|
||||
this.bCLabel.AutoSize = true;
|
||||
this.bCLabel.Location = new System.Drawing.Point(200, 20);
|
||||
this.bCLabel.Name = "bCLabel";
|
||||
this.bCLabel.Size = new System.Drawing.Size(139, 17);
|
||||
this.bCLabel.TabIndex = 0;
|
||||
this.bCLabel.Text = "Boundary Conditions";
|
||||
//
|
||||
// hostLabel
|
||||
//
|
||||
this.hostLabel.AutoSize = true;
|
||||
this.hostLabel.Location = new System.Drawing.Point(21, 20);
|
||||
this.hostLabel.Name = "hostLabel";
|
||||
this.hostLabel.Size = new System.Drawing.Size(37, 17);
|
||||
this.hostLabel.TabIndex = 1;
|
||||
this.hostLabel.Text = "Host";
|
||||
//
|
||||
// bCPropertyGrid
|
||||
//
|
||||
this.bCPropertyGrid.Location = new System.Drawing.Point(23, 60);
|
||||
this.bCPropertyGrid.Name = "bCPropertyGrid";
|
||||
this.bCPropertyGrid.Size = new System.Drawing.Size(434, 290);
|
||||
this.bCPropertyGrid.TabIndex = 2;
|
||||
this.bCPropertyGrid.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.bCPropertyGrid_PropertyValueChanged);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(247, 379);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(102, 30);
|
||||
this.okButton.TabIndex = 3;
|
||||
this.okButton.Text = "&OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(355, 379);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(102, 30);
|
||||
this.cancelButton.TabIndex = 4;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// bCComboBox
|
||||
//
|
||||
this.bCComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.bCComboBox.FormattingEnabled = true;
|
||||
this.bCComboBox.Location = new System.Drawing.Point(345, 13);
|
||||
this.bCComboBox.Name = "bCComboBox";
|
||||
this.bCComboBox.Size = new System.Drawing.Size(112, 24);
|
||||
this.bCComboBox.TabIndex = 1;
|
||||
this.bCComboBox.SelectedIndexChanged += new System.EventHandler(this.bCComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// hostTextBox
|
||||
//
|
||||
this.hostTextBox.Location = new System.Drawing.Point(64, 15);
|
||||
this.hostTextBox.Name = "hostTextBox";
|
||||
this.hostTextBox.ReadOnly = true;
|
||||
this.hostTextBox.Size = new System.Drawing.Size(97, 22);
|
||||
this.hostTextBox.TabIndex = 6;
|
||||
this.hostTextBox.TabStop = false;
|
||||
//
|
||||
// BoundaryConditionsForm
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(480, 438);
|
||||
this.Controls.Add(this.hostTextBox);
|
||||
this.Controls.Add(this.bCComboBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.bCPropertyGrid);
|
||||
this.Controls.Add(this.hostLabel);
|
||||
this.Controls.Add(this.bCLabel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "BoundaryConditionsForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Boundary Conditions";
|
||||
this.Load += new System.EventHandler(this.BoundaryConditionsForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label bCLabel;
|
||||
private System.Windows.Forms.Label hostLabel;
|
||||
private System.Windows.Forms.PropertyGrid bCPropertyGrid;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.ComboBox bCComboBox;
|
||||
private System.Windows.Forms.TextBox hostTextBox;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
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.BoundaryConditions.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// UI which display the information and interact with users
|
||||
/// </summary>
|
||||
public partial class BoundaryConditionsForm : System.Windows.Forms.Form
|
||||
{
|
||||
// an instance of BoundaryConditionsData class which deal with the need data
|
||||
private BoundaryConditionsData m_dataBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="dataBuffer"></param>
|
||||
public BoundaryConditionsForm(BoundaryConditionsData dataBuffer)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
m_dataBuffer = dataBuffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// display the information about the host element and the BC parameter value
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BoundaryConditionsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
// display host element id in the text box
|
||||
hostTextBox.Text = m_dataBuffer.HostElement.Id.IntegerValue.ToString();
|
||||
|
||||
// if the selected element has not a BC, create one and display the default parameter values
|
||||
// else list the BC ids in the combox and display the first BC's parameter values
|
||||
if (0 == m_dataBuffer.BCs.Count)
|
||||
{
|
||||
bCComboBox.Visible = false;
|
||||
bCLabel.Visible = false;
|
||||
bool isCreatedSuccessful = m_dataBuffer.CreateBoundaryConditions();
|
||||
m_dataBuffer.HostElement.Document.Regenerate();
|
||||
|
||||
if (!isCreatedSuccessful)
|
||||
{
|
||||
this.DialogResult = DialogResult.Retry;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bCComboBox.Visible = true;
|
||||
bCLabel.Visible = true;
|
||||
}
|
||||
|
||||
// list the boundary conditions Id values to the combobox
|
||||
System.Collections.ICollection bCIdValues = m_dataBuffer.BCs.Keys;
|
||||
foreach (int bCIdValue in bCIdValues)
|
||||
{
|
||||
bCComboBox.Items.Add(bCIdValue);
|
||||
}
|
||||
|
||||
bCComboBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// display the BC's property value according the selected BC ID in combobox
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void bCComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// create a BCProperties instance according to current selected BC Id
|
||||
m_dataBuffer.BCProperties = new BCProperties(m_dataBuffer.BCs[int.Parse(bCComboBox.Text)]);
|
||||
|
||||
// set the display object
|
||||
bCPropertyGrid.SelectedObject = m_dataBuffer.BCProperties;
|
||||
|
||||
// set the browsable attributes of the property grid
|
||||
Attribute[] attributes = null;
|
||||
if (BCType.Point == m_dataBuffer.BCProperties.BoundaryConditionsType)
|
||||
{
|
||||
attributes = new Attribute[] { new BCTypeAttribute(new BCType[] { BCType.Point }) };
|
||||
}
|
||||
else if (BCType.Line == m_dataBuffer.BCProperties.BoundaryConditionsType)
|
||||
{
|
||||
attributes = new Attribute[] { new BCTypeAttribute(new BCType[] { BCType.Line }) };
|
||||
}
|
||||
else if (BCType.Area == m_dataBuffer.BCProperties.BoundaryConditionsType)
|
||||
{
|
||||
attributes = new Attribute[] { new BCTypeAttribute(new BCType[] { BCType.Area }) };
|
||||
}
|
||||
|
||||
bCPropertyGrid.BrowsableAttributes = new AttributeCollection(attributes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// deal with operations that user set these parameters with other valid value.
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <param name="e"></param>
|
||||
private void bCPropertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
||||
{
|
||||
if (e.ChangedItem.Label.Contains("Translation") || e.ChangedItem.Label.Contains("Rotation"))
|
||||
{
|
||||
// invoke SetSpringModulus method in BCProperties class to
|
||||
// let user enter a positive number as the SpringModulus
|
||||
// when set any Translation/Rotation parameter to Spring
|
||||
BCTranslationRotation value = (BCTranslationRotation)e.ChangedItem.Value;
|
||||
if (BCTranslationRotation.Spring == value)
|
||||
{
|
||||
m_dataBuffer.BCProperties.SetSpringModulus(e.ChangedItem.Label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// confirm the changed and exist the UI
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,158 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Structure;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace Revit.SDK.Samples.BoundaryConditions.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// A ExternalCommand class inherited IExternalCommand interface
|
||||
/// </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,
|
||||
ElementSet elements)
|
||||
{
|
||||
try
|
||||
{
|
||||
//Retrieves the currently active project.
|
||||
UIDocument doc = commandData.Application.ActiveUIDocument;
|
||||
|
||||
// must select a element first
|
||||
ElementSet elementSet = new ElementSet();
|
||||
foreach (ElementId elementId in doc.Selection.GetElementIds())
|
||||
{
|
||||
elementSet.Insert(doc.Document.GetElement(elementId));
|
||||
}
|
||||
if (1 != elementSet.Size)
|
||||
{
|
||||
message = "Please select one structural element which is listed as follows: \r\n" +
|
||||
"Columns/braces/Beams/Walls/Wall Foundations/Slabs/Foundation Slabs";
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
|
||||
|
||||
Transaction tran = new Transaction(doc.Document, "BoundaryConditions");
|
||||
tran.Start();
|
||||
|
||||
// deal with the selected element
|
||||
foreach (Element element in elementSet)
|
||||
{
|
||||
// the selected element must be a structural element
|
||||
if (!IsExpectedElement(element))
|
||||
{
|
||||
message = "Please select one structural element which is listed as follows: \r\n" +
|
||||
"Columns/braces/Beams/Walls/Wall Foundations/ \r\n" +
|
||||
"Slabs/Foundation Slabs";
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
|
||||
// prepare the relative data
|
||||
BoundaryConditionsData dataBuffer = new BoundaryConditionsData(element);
|
||||
|
||||
// show UI
|
||||
using (BoundaryConditionsForm displayForm = new BoundaryConditionsForm(dataBuffer))
|
||||
{
|
||||
DialogResult result = displayForm.ShowDialog();
|
||||
if (DialogResult.OK == result)
|
||||
{
|
||||
tran.Commit();
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
else if (DialogResult.Retry == result)
|
||||
{
|
||||
message = "failed to create BoundaryConditions.";
|
||||
tran.RollBack();
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tran.RollBack();
|
||||
// user cancel the operation
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
message = e.Message;
|
||||
return Autodesk.Revit.UI.Result.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the selected element must be a structural Column/brace/Beam/Wall/Wall Foundation/Slab/Foundation Slab.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool IsExpectedElement(Element element)
|
||||
{
|
||||
|
||||
// judge the element's type. If it is any type of FamilyInstance, Wall, Floor or
|
||||
// WallFoundation, then get judge if it has a AnalyticalModel.
|
||||
if (null == element.GetAnalyticalModel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FamilyInstance familyInstance = element as FamilyInstance;
|
||||
if ((null != familyInstance) && (StructuralType.Footing == familyInstance.StructuralType))
|
||||
{
|
||||
return false; // if selected a isolated foundation not create BC
|
||||
}
|
||||
|
||||
if (element is FamilyInstance || element is Wall || element is Floor || element is WallFoundation)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("BoundaryConditions")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("BoundaryConditions")]
|
||||
[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("ae5105cb-d874-4c01-8d76-86279bf6e4f7")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Binary file not shown.
@@ -0,0 +1,127 @@
|
||||
//
|
||||
// (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.BoundaryConditions.CS
|
||||
{
|
||||
partial class SpringModulusForm
|
||||
{
|
||||
/// <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.springModulusTextBox = new System.Windows.Forms.TextBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.springModulusLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// springModulusTextBox
|
||||
//
|
||||
this.springModulusTextBox.Location = new System.Drawing.Point(14, 47);
|
||||
this.springModulusTextBox.Name = "springModulusTextBox";
|
||||
this.springModulusTextBox.Size = new System.Drawing.Size(263, 22);
|
||||
this.springModulusTextBox.TabIndex = 0;
|
||||
this.springModulusTextBox.Leave += new System.EventHandler(this.springModulusTextBox_Leave);
|
||||
this.springModulusTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.springModulusTextBox_KeyDown);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(108, 95);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(77, 28);
|
||||
this.okButton.TabIndex = 1;
|
||||
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(200, 95);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(77, 28);
|
||||
this.cancelButton.TabIndex = 2;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// springModulusLabel
|
||||
//
|
||||
this.springModulusLabel.AutoSize = true;
|
||||
this.springModulusLabel.Location = new System.Drawing.Point(12, 18);
|
||||
this.springModulusLabel.Name = "springModulusLabel";
|
||||
this.springModulusLabel.Size = new System.Drawing.Size(204, 17);
|
||||
this.springModulusLabel.TabIndex = 3;
|
||||
this.springModulusLabel.Text = "Please enter a positive number";
|
||||
//
|
||||
// SpringModulusForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(298, 138);
|
||||
this.Controls.Add(this.springModulusLabel);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.springModulusTextBox);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "SpringModulusForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Spring Modulus";
|
||||
this.Load += new System.EventHandler(this.SpringModulusForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox springModulusTextBox;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Label springModulusLabel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
//
|
||||
// (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.BoundaryConditions.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// user enter a positive number as the SpringModulus
|
||||
/// </summary>
|
||||
public partial class SpringModulusForm : System.Windows.Forms.Form
|
||||
{
|
||||
// member
|
||||
private double m_springModulus; // new value
|
||||
private double m_oldSpringModulus; // old value
|
||||
private ConversionValue m_conversion; //conversion rule of current SpringModulus
|
||||
|
||||
// property
|
||||
/// <summary>
|
||||
///set conversion rule between diaplay value and inside value of current SpringModulus
|
||||
/// </summary>
|
||||
public ConversionValue Conversion
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_conversion;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_conversion = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get the new value after interact with user
|
||||
/// </summary>
|
||||
public double StringModulus
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_springModulus;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set the old value before interact with user
|
||||
/// </summary>
|
||||
public double OldStringModulus
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_oldSpringModulus;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_oldSpringModulus = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
public SpringModulusForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// display the old value in the text box when show the interaction
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SpringModulusForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
// get the old value which is the inside value
|
||||
m_springModulus = m_oldSpringModulus;
|
||||
|
||||
// conversion the inside value into display value
|
||||
double displaySpringModulus = m_oldSpringModulus / m_conversion.Ratio;
|
||||
|
||||
// deal with the diaplay value with the special percision
|
||||
displaySpringModulus = Math.Round(displaySpringModulus, m_conversion.Precision);
|
||||
|
||||
// display the value and show user the unit of the value
|
||||
springModulusTextBox.Text = displaySpringModulus + m_conversion.UnitName;
|
||||
springModulusTextBox.Focus();
|
||||
springModulusTextBox.SelectAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user affirm the input
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!springModulusTextBox.Focused)
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user cancel the input
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
m_springModulus = m_oldSpringModulus;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user can click Enter key to end of the input
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void springModulusTextBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (13 == e.KeyValue)
|
||||
{
|
||||
okButton.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// check if the input is valid
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void springModulusTextBox_Leave(object sender, EventArgs e)
|
||||
{
|
||||
// store all the text of the text box
|
||||
string allText = springModulusTextBox.Text;
|
||||
// store the text of the text box after removing the unit and white chatracters
|
||||
string springModulusText = allText;
|
||||
|
||||
// parse the text to get the valid springModulus
|
||||
if (allText.Contains(m_conversion.UnitName))
|
||||
{
|
||||
// removes the unit
|
||||
int index = allText.IndexOf(m_conversion.UnitName);
|
||||
springModulusText = allText.Substring(0, index);
|
||||
|
||||
// removes all white chatracters from the beginning and end of this string
|
||||
springModulusText = springModulusText.Trim();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// the spring modulus should be a double number
|
||||
double temp = Double.Parse(springModulusText);
|
||||
|
||||
// deal with the input with the given precision
|
||||
temp = Math.Round(temp, m_conversion.Precision);
|
||||
|
||||
// add corresponding unit
|
||||
springModulusTextBox.Text = temp.ToString() + m_conversion.UnitName;
|
||||
|
||||
// convert the display value into the inside value
|
||||
m_springModulus = temp * m_conversion.Ratio;
|
||||
|
||||
// the value must be a positive number
|
||||
if (0 >= m_springModulus)
|
||||
{
|
||||
springModulusTextBox.Focus();
|
||||
springModulusTextBox.SelectAll();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
springModulusTextBox.Focus();
|
||||
springModulusTextBox.SelectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,155 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Revit.SDK.Samples.BoundaryConditions.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// a structure about the conversion rule between display value and inside value
|
||||
/// </summary>
|
||||
public struct ConversionValue
|
||||
{
|
||||
// members
|
||||
private int m_precision; // the precision of the diaplay value
|
||||
private string m_unitName; // the unit of the display value
|
||||
private double m_ratio; // the radio of inside value to display value
|
||||
|
||||
/// <summary>
|
||||
/// constructor, using to initialize the members
|
||||
/// </summary>
|
||||
/// <param name="precision">the precision of the diaplay value</param>
|
||||
/// <param name="ratio">the unit of the display value</param>
|
||||
/// <param name="unitName">the radio of inside value to display valuea</param>
|
||||
public ConversionValue(int precision, double ratio, string unitName)
|
||||
{
|
||||
|
||||
m_precision = precision;
|
||||
m_ratio = ratio;
|
||||
m_unitName = unitName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get the precision of the diaplay value
|
||||
/// </summary>
|
||||
public int Precision
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_precision;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get the unit of the display value
|
||||
/// </summary>
|
||||
public string UnitName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_unitName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get the radio of inside value to display value
|
||||
/// </summary>
|
||||
public double Ratio
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ratio;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// value conversion dictionary, in this class the data we gave only fit for Imperial unit
|
||||
/// the relationship about dislay paramete values and inside parameter values
|
||||
/// </summary>
|
||||
public static class UnitConversion
|
||||
{
|
||||
// member: dictionary
|
||||
private static Dictionary<string, ConversionValue> m_unitDictionary;
|
||||
|
||||
/// <summary>
|
||||
/// get the value dictionary
|
||||
/// </summary>
|
||||
public static Dictionary<string, ConversionValue> UnitDictionary
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_unitDictionary;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// static constructor to initialize the value conversion dictionary which we will used
|
||||
/// according to the difference unit
|
||||
/// </summary>
|
||||
static UnitConversion()
|
||||
{
|
||||
m_unitDictionary = new Dictionary<string, ConversionValue>();
|
||||
|
||||
#region "fill my units dictionary"
|
||||
char degree = (char)0xb0;
|
||||
char square = (char)0xB2;
|
||||
char cube = (char)0xB3;
|
||||
|
||||
// about point BC's translation spring modulus
|
||||
AddNewUnit(1, 175126.835246476, "kip/in", "PTSpringModulusConver");
|
||||
|
||||
// about point BC's rotation spring modulus
|
||||
AddNewUnit(1, 47880.2589803358, "kip-f/" + degree + "F", "PRSpringModulusConver");
|
||||
|
||||
// about Line BC's translation spring modulus
|
||||
AddNewUnit(4, 14593.9029372064, "kip/ft" + square, "LTSpringModulusConver");
|
||||
|
||||
// about Line BC's rotation spring modulus
|
||||
AddNewUnit(1, 47880.2589803358, "kip-f/" + degree + "F/ft", "LRSpringModulusConver");
|
||||
|
||||
// about Area BC's translation spring modulus
|
||||
AddNewUnit(1, 14593.9029372064, "kip/ft" + cube, "ATSpringModulusConver");
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add a new unit conversion item
|
||||
/// </summary>
|
||||
/// <param name="precision"> the precision of the display value</param>
|
||||
/// <param name="ratio"> the radio of inside value to display value about current unit</param>
|
||||
/// <param name="unitName"> the unit of the display value</param>
|
||||
/// <param name="key"></param>
|
||||
private static void AddNewUnit(int precision, double ratio, string unitName, string key)
|
||||
{
|
||||
// create a ConversionValue instance
|
||||
ConversionValue conversionValue = new ConversionValue(precision, ratio, unitName);
|
||||
|
||||
// add this item to ourself dictionary
|
||||
m_unitDictionary.Add(key, conversionValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user