added Revit 2020 SDK files
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 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.Windows;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace SectionPropertiesExplorer
|
||||
{
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Automatic)]
|
||||
public class Command : Autodesk.Revit.UI.IExternalCommand
|
||||
{
|
||||
#region IExternalCommand implementation
|
||||
//--------------------------------------------------------------
|
||||
|
||||
public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
this.commandData = commandData;
|
||||
List<Autodesk.Revit.DB.Element> revitElements = new List<Autodesk.Revit.DB.Element>();
|
||||
|
||||
foreach (Autodesk.Revit.DB.Element el in commandData.Application.ActiveUIDocument.Selection.Elements)
|
||||
{
|
||||
Autodesk.Revit.DB.BuiltInCategory cat = (Autodesk.Revit.DB.BuiltInCategory)el.Category.Id.IntegerValue;
|
||||
|
||||
switch (cat)
|
||||
{
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_StructuralColumns:
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_StructuralFraming:
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_Floors:
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_StructuralFoundation:
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_Walls:
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical:
|
||||
revitElements.Add(el);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (revitElements.Count < 1)
|
||||
{
|
||||
MessageBox.Show("No structural columns, structural framings, slabs or no walls are selected.");
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
|
||||
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
|
||||
uiDoc.Selection.Elements.Clear();
|
||||
|
||||
MainWindow mainWindow = new MainWindow(revitElements, On_ElementSelected);
|
||||
mainWindow.ShowDialog();
|
||||
|
||||
foreach (Autodesk.Revit.DB.Element el in revitElements)
|
||||
{
|
||||
uiDoc.Selection.Elements.Add(el);
|
||||
}
|
||||
uiDoc.RefreshActiveView();
|
||||
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
#region event handlers
|
||||
//--------------------------------------------------------------
|
||||
|
||||
private void On_ElementSelected(object sender, MainWindow.ElementSelectedEventArgs e)
|
||||
{
|
||||
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
|
||||
uiDoc.Selection.Elements.Clear();
|
||||
uiDoc.Selection.Elements.Add(e.SelectedElement);
|
||||
uiDoc.RefreshActiveView();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
#region private members
|
||||
//--------------------------------------------------------------
|
||||
|
||||
private Autodesk.Revit.UI.ExternalCommandData commandData;
|
||||
|
||||
//--------------------------------------------------------------
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 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.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
using XYZ = Autodesk.Revit.DB.XYZ;
|
||||
|
||||
namespace SectionPropertiesExplorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Geometry utility
|
||||
/// </summary>
|
||||
internal class Geometry
|
||||
{
|
||||
public static bool IsEqual(double val1, double val2, double eps)
|
||||
{
|
||||
return (System.Math.Abs(val1 - val2) < eps);
|
||||
}
|
||||
|
||||
public static bool PointsAreAlmostEqual(double[] pt1, double[] pt2)
|
||||
{
|
||||
double EpsilonLength = 5.0e-03;
|
||||
return IsEqual(pt1[0], pt2[0], EpsilonLength) && IsEqual(pt1[1], pt2[1], EpsilonLength) && IsEqual(pt1[2], pt2[2], EpsilonLength);
|
||||
}
|
||||
|
||||
public static double Distance2D(double[] p1, double[] p2)
|
||||
{
|
||||
double x = p1[0] - p2[0];
|
||||
double y = p1[1] - p2[1];
|
||||
return System.Math.Sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
public static double[] Subtract(double[] pEnd, double[] pStart)
|
||||
{
|
||||
double EpsilonLength = 5.0e-03;
|
||||
|
||||
double x = pEnd[0] - pStart[0];
|
||||
double y = pEnd[1] - pStart[1];
|
||||
double z = pEnd[2] - pStart[2];
|
||||
|
||||
if (System.Math.Abs(x) < EpsilonLength) x = 0;
|
||||
if (System.Math.Abs(y) < EpsilonLength) y = 0;
|
||||
if (System.Math.Abs(z) < EpsilonLength) z = 0;
|
||||
|
||||
return new double[3] { x, y, z };
|
||||
}
|
||||
|
||||
public static double[] GetParamLine(double[] pt1, double[] pt2)
|
||||
{
|
||||
double EpsilonLength = 5.0e-03;
|
||||
|
||||
double a = 0;
|
||||
double b = 0;
|
||||
|
||||
double xa = pt2[0] - pt1[0];
|
||||
double ya = pt2[1] - pt1[1];
|
||||
|
||||
if (System.Math.Abs(xa) > EpsilonLength)
|
||||
{
|
||||
a = ya / xa;
|
||||
b = pt1[1] - a * pt1[0];
|
||||
}
|
||||
return new double[2] { a, b };
|
||||
}
|
||||
|
||||
public static bool IsPointOnLine(double[] pt1Line, double[] pt2Line, double[] pt)
|
||||
{
|
||||
double EpsilonLength = 5.0e-03;
|
||||
|
||||
double ParamT = -1;
|
||||
double[] Vect = Subtract(pt2Line, pt1Line);
|
||||
|
||||
if (System.Math.Abs(Vect[0]) > EpsilonLength)
|
||||
{ ParamT = (pt[0] - pt1Line[0]) / Vect[0]; }
|
||||
else if (System.Math.Abs(Vect[1]) > EpsilonLength)
|
||||
{ ParamT = (pt[1] - pt1Line[1]) / Vect[1]; }
|
||||
else if (System.Math.Abs(Vect[2]) > EpsilonLength)
|
||||
{ ParamT = (pt[2] - pt1Line[2]) / Vect[2]; }
|
||||
|
||||
if ((ParamT > 0 || System.Math.Abs(ParamT) < EpsilonLength) &&
|
||||
(ParamT < 1 || System.Math.Abs(ParamT - 1) < EpsilonLength))
|
||||
{
|
||||
if (ParamT < 0) ParamT = 0;
|
||||
if (ParamT > 1) ParamT = 1;
|
||||
|
||||
Vect[0] = pt1Line[0] + ParamT * Vect[0];
|
||||
Vect[1] = pt1Line[1] + ParamT * Vect[1];
|
||||
Vect[2] = pt1Line[2] + ParamT * Vect[2];
|
||||
|
||||
return PointsAreAlmostEqual(Vect, pt);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsIntersectionFirstLine2D(double[] pt11, double[] pt12, double[] pt21, double[] pt22, out double[] pt)
|
||||
{
|
||||
double EpsilonLength = 5.0e-03;
|
||||
|
||||
double x = 0, y = 0;
|
||||
double[] Vers1 = Subtract(pt12, pt11);
|
||||
double[] Vers2 = Subtract(pt22, pt21);
|
||||
|
||||
pt = new double[3];
|
||||
|
||||
if (System.Math.Abs(System.Math.Abs(DotProduct(Vers1, Vers2)) - 1) < EpsilonLength)
|
||||
{ return false; }
|
||||
|
||||
double[] W1 = GetParamLine(pt11, pt12);
|
||||
double[] W2 = GetParamLine(pt21, pt22);
|
||||
|
||||
if ((W1[0] != 0 || W1[1] != 0) && (W2[0] != 0 || W2[1] != 0))
|
||||
{
|
||||
x = (W2[1] - W1[1]) / (W1[0] - W2[0]);
|
||||
y = W1[0] * x + W1[1];
|
||||
}
|
||||
else if (W1[0] == 0 && W1[1] == 0 && (W2[0] == 0 && W2[1] == 0))
|
||||
{
|
||||
if (System.Math.Abs(System.Math.Abs(Vers1[0]) - 1) < EpsilonLength)
|
||||
{ x = pt21[0]; y = pt11[1]; }
|
||||
else
|
||||
{ x = pt11[0]; y = pt21[1]; }
|
||||
}
|
||||
else if (W1[0] == 0 && W1[1] == 0)
|
||||
{
|
||||
if (System.Math.Abs(System.Math.Abs(Vers1[0]) - 1) < EpsilonLength)
|
||||
{ y = pt11[1]; if (W2[0] != 0) x = (y - W2[1]) / W2[0]; }
|
||||
else
|
||||
{ x = pt11[0]; y = W2[0] * x + W2[1]; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (System.Math.Abs(System.Math.Abs(Vers2[0]) - 1) < EpsilonLength)
|
||||
{ y = pt21[1]; if (W1[0] != 0) x = (y - W1[1]) / W1[0]; }
|
||||
else
|
||||
{ x = pt21[0]; y = W1[0] * x + W1[1]; }
|
||||
}
|
||||
|
||||
pt[0] = x;
|
||||
pt[1] = y;
|
||||
pt[2] = pt11[2];
|
||||
|
||||
if (!IsPointOnLine(pt11, pt12, pt))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static double DotProduct(double[] vector1, double[] vector2)
|
||||
{
|
||||
return vector1[0] * vector2[0] + vector1[1] * vector2[1] + vector1[2] * vector2[2];
|
||||
}
|
||||
|
||||
public static double AngleBetweenX(double[] p1, double[] p2)
|
||||
{
|
||||
double EpsilonLength = 5.0e-03;
|
||||
|
||||
double Lx = p2[0] - p1[0];
|
||||
double Ly = p2[1] - p1[1];
|
||||
double Lxy = System.Math.Sqrt(Lx * Lx + Ly * Ly);
|
||||
double Ang = 0;
|
||||
|
||||
if (Lxy == 0) return Ang;
|
||||
|
||||
if (Lx != 0)
|
||||
{
|
||||
Ang = Lx / Lxy;
|
||||
double len = System.Math.Sqrt(-Ang * Ang + 1);
|
||||
if (System.Math.Abs(len) > EpsilonLength)
|
||||
{ Ang = System.Math.Atan(-Ang / len) + 2 * System.Math.Atan(1); }
|
||||
else
|
||||
{ Ang = (Lx < -EpsilonLength) ? -System.Math.PI : 0; }
|
||||
|
||||
if (Ly < -EpsilonLength) Ang = -Ang;
|
||||
}
|
||||
else if (Ly != 0)
|
||||
{
|
||||
Ang = Ly / Lxy;
|
||||
double len = System.Math.Sqrt(-Ang * Ang + 1);
|
||||
|
||||
if (System.Math.Abs(len) > EpsilonLength)
|
||||
{ Ang = System.Math.Atan(-Ang / len); }
|
||||
else
|
||||
{ Ang = System.Math.PI / 2 * Ly / System.Math.Abs(Ly); }
|
||||
|
||||
if (Lx < -EpsilonLength) Ang = -Ang;
|
||||
}
|
||||
|
||||
return Ang;
|
||||
}
|
||||
}
|
||||
|
||||
internal class BoundaryBox
|
||||
{
|
||||
#region constructor
|
||||
//--------------------------------------------------------------
|
||||
|
||||
public BoundaryBox()
|
||||
{
|
||||
Children = new List<BoundaryBox>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
#region properties
|
||||
|
||||
public XYZ Min
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public XYZ Max
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public List<BoundaryBox> Children
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region methods
|
||||
//--------------------------------------------------------------
|
||||
|
||||
public void AddPoint(XYZ pt)
|
||||
{
|
||||
if (Min == null)
|
||||
{
|
||||
Min = new XYZ(pt.X, pt.Y, pt.Z);
|
||||
Max = new XYZ(pt.X, pt.Y, pt.Z);
|
||||
return;
|
||||
}
|
||||
|
||||
Min = new XYZ(System.Math.Min(Min.X, pt.X), System.Math.Min(Min.Y, pt.Y), System.Math.Min(Min.Z, pt.Z));
|
||||
|
||||
Max = new XYZ(System.Math.Max(Max.X, pt.X), System.Math.Max(Max.Y, pt.Y), System.Math.Max(Max.Z, pt.Z));
|
||||
}
|
||||
|
||||
public void AddBoundingBox(BoundaryBox bb)
|
||||
{
|
||||
AddPoint(bb.Min);
|
||||
AddPoint(bb.Max);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Min = null;
|
||||
Max = null;
|
||||
}
|
||||
|
||||
public XYZ GetCenter()
|
||||
{
|
||||
if (Min == null || Max == null)
|
||||
return new XYZ();
|
||||
|
||||
return new XYZ((Min.X + Max.X) / 2, (Min.Y + Max.Y) / 2, (Min.Z + Max.Z) / 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether bounding box intersects with current one
|
||||
/// </summary>
|
||||
/// <param name="bb">bounding box</param>
|
||||
/// <param name="Epsilon">epsilon</param>
|
||||
/// <returns>true if given bounding box intersects the current one, else false.</returns>
|
||||
public bool Intersects(BoundaryBox bb, double Epsilon)
|
||||
{
|
||||
if (Min == null || Max == null)
|
||||
return false;
|
||||
|
||||
if (Min.X - Epsilon > bb.Max.X || Min.Y - Epsilon > bb.Max.Y || Min.Z - Epsilon > bb.Max.Z)
|
||||
return false;
|
||||
|
||||
if (bb.Min.X - Epsilon > Max.X || bb.Min.Y - Epsilon > Max.Y || bb.Min.Z - Epsilon > Max.Z)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether bounding box contains the other bounding box
|
||||
/// </summary>
|
||||
/// <param name="bb">bounding box</param>
|
||||
/// <param name="Epsilon">epsilon</param>
|
||||
/// <returns>true if given bounding box intersects the current one, else false.</returns>
|
||||
public bool Contains(BoundaryBox bb, double epsilon)
|
||||
{
|
||||
if (Min == null || Max == null)
|
||||
return false;
|
||||
|
||||
if (Max.X + epsilon < bb.Max.X || Max.Y + epsilon < bb.Max.Y || Max.Z + epsilon < bb.Max.Z)
|
||||
return false;
|
||||
|
||||
if (bb.Min.X + epsilon < Min.X || bb.Min.Y + epsilon < Min.Y || bb.Min.Z + epsilon < Min.Z)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is extension for Revit's XYZ class.
|
||||
/// </summary>
|
||||
internal static class XYZ_Extension
|
||||
{
|
||||
public static XYZ Clone(this XYZ pt)
|
||||
{
|
||||
return new XYZ(pt.X, pt.Y, pt.Z);
|
||||
}
|
||||
|
||||
public static double[] getDblArray(this XYZ pt)
|
||||
{
|
||||
return new double[] { pt.X, pt.Y, pt.Z };
|
||||
}
|
||||
|
||||
public static double[] getDblArray(this IList<XYZ> list)
|
||||
{
|
||||
double[] ar = new double[list.Count * 3];
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
XYZ item = list[i];
|
||||
|
||||
ar[i * 3] = item.X;
|
||||
ar[i * 3 + 1] = item.Y;
|
||||
ar[i * 3 + 2] = item.Z;
|
||||
}
|
||||
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<Window x:Class="SectionPropertiesExplorer.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:myCtrls="clr-namespace:SectionPropertiesExplorer"
|
||||
Title="CodeChecking.Engineering library runtime test"
|
||||
mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="540" d:DesignWidth="720" SizeToContent="WidthAndHeight">
|
||||
<StackPanel>
|
||||
<DockPanel Margin="0 5 0 0" LastChildFill="True">
|
||||
<Label Content="Element:" Height="26" Width="102" Margin="4 0 0 0" DockPanel.Dock="Left"/>
|
||||
<Button Name="previous" Height="22" Width="22" Margin="2 0 5 0" DockPanel.Dock="Left" Click="previous_Click">
|
||||
<Image Name="previous_" Source="/SectionPropertiesExplorer;component/Resources/Images/previous_disabled.png" />
|
||||
</Button>
|
||||
<Button Name="next" Height="22" Width="22" Margin="5 0 5 0" DockPanel.Dock="Right" Click="next_Click">
|
||||
<Image Name="next_" Source="/SectionPropertiesExplorer;component/Resources/Images/next_disabled.png" />
|
||||
</Button>
|
||||
<ComboBox Name="elements" Height="22" SelectedIndex="0"
|
||||
ItemsSource="{Binding Path=ElementEntries}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="Name"
|
||||
SelectedValue="{Binding Path=ElementEntry}" SelectionChanged="elements_SelectionChanged">
|
||||
</ComboBox>
|
||||
</DockPanel>
|
||||
<DockPanel Margin="0 2 0 0" LastChildFill="False">
|
||||
<Label Name="elementSizeLabel" Content="elementSize:" Height="26" Margin="4 0 5 0" DockPanel.Dock="Left"/>
|
||||
<Label Name="elementSizeValue" Content="100 ft" Height="26" Width="200" DockPanel.Dock="Left"/>
|
||||
<StackPanel Orientation="Horizontal" Width="340" Margin="0 2 0 2" DockPanel.Dock="Right">
|
||||
<Label Content="Units system:" Height="26" Width="100" />
|
||||
<RadioButton Name="radioRevit" Content="Revit" Width="80" Margin="0 5 0 0" IsChecked="True" Checked="radioRevit_Checked" />
|
||||
<RadioButton Name="radioImperial" Content="Imperial" Width="80" Margin="0 5 0 0" IsChecked="False" Checked="radioImperial_Checked" />
|
||||
<RadioButton Name="radioMetric" Content="Metric" Width="80" Margin="0 5 0 0" IsChecked="False" Checked="radioMetric_Checked" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
<TabControl Height="432" Name="tabControl" Margin="0 5 0 0" SelectionChanged="tabControl_SelectionChanged">
|
||||
<TabItem Header="Profile" Name="tabProfile">
|
||||
<StackPanel Height="400" Orientation="Horizontal">
|
||||
<myCtrls:SectionParametersControl x:Name="sectionParameters" />
|
||||
<myCtrls:SectionDescriptionControl x:Name="sectionDescription" />
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="Slab" Name="tabSlab">
|
||||
<myCtrls:SlabDescriptionControl x:Name="slabDescription" Height="400"/>
|
||||
</TabItem>
|
||||
<TabItem Header="Wall" Name="tabWall">
|
||||
<myCtrls:WallDescriptionControl x:Name="wallDescription" Height="400"/>
|
||||
</TabItem>
|
||||
<TabItem Header="Material" Name="tabMaterial">
|
||||
<myCtrls:MaterialParametersControl x:Name="materialParameters" />
|
||||
</TabItem>
|
||||
<TabItem Header="T-Section" Name="tabTSection">
|
||||
<myCtrls:SlabDescriptionControl x:Name="tSectionDescription" Height="400"/>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,471 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 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.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.ComponentModel;
|
||||
|
||||
using Autodesk.Revit.DB.CodeChecking.Engineering;
|
||||
using Autodesk.Revit.DB.CodeChecking.Engineering.Tools;
|
||||
|
||||
namespace SectionPropertiesExplorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
List<Autodesk.Revit.DB.Element> revitElements = null;
|
||||
ElementAnalyser revitElementAnalyser = null;
|
||||
|
||||
#region constructors
|
||||
//--------------------------------------------------------------
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
revitUnitsUI = true;
|
||||
unitSystem = Autodesk.Revit.DB.DisplayUnit.IMPERIAL;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public MainWindow(List<Autodesk.Revit.DB.Element> revitElements, EventHandler<ElementSelectedEventArgs> ElementSelectedEventHandler = null)
|
||||
: this()
|
||||
{
|
||||
this.revitElements = revitElements;
|
||||
if (revitElements.Count > 0)
|
||||
{
|
||||
ConnectionViewModel cvm = new ConnectionViewModel(revitElements);
|
||||
DataContext = cvm;
|
||||
}
|
||||
|
||||
this.ElementSelectedEventHandler = ElementSelectedEventHandler;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
#region events
|
||||
//--------------------------------------------------------------
|
||||
|
||||
public class ElementSelectedEventArgs : EventArgs
|
||||
{
|
||||
public ElementSelectedEventArgs(Autodesk.Revit.DB.Element selectedElement)
|
||||
{
|
||||
this.SelectedElement = selectedElement;
|
||||
}
|
||||
|
||||
public Autodesk.Revit.DB.Element SelectedElement { get; private set; }
|
||||
}
|
||||
|
||||
public event EventHandler<ElementSelectedEventArgs> ElementSelectedEventHandler;
|
||||
|
||||
//--------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
#region public methods
|
||||
//--------------------------------------------------------------
|
||||
|
||||
public void DataBinding(Autodesk.Revit.DB.Element revitElement)
|
||||
{
|
||||
UnitsAssignment.RevitUnits = revitElement.Document.GetUnits();
|
||||
|
||||
if (null == revitElementAnalyser)
|
||||
{
|
||||
revitElementAnalyser = revitUnitsUI ? new ElementAnalyser() : new ElementAnalyser(unitSystem);
|
||||
revitElementAnalyser.TSectionAnalysis = true;
|
||||
}
|
||||
|
||||
ElementInfo elementInfo = revitElementAnalyser.Analyse(revitElement);
|
||||
|
||||
switch (elementInfo.Type)
|
||||
{
|
||||
case ElementType.Beam:
|
||||
case ElementType.Column:
|
||||
elementSizeLabel.Content = "Length:";
|
||||
if (revitUnitsUI)
|
||||
{
|
||||
elementSizeValue.Content = UnitsAssignment.FormatToRevitUI("GeomLength", elementInfo.GeomLength(), ElementInfoUnits.Assignments, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
elementSizeValue.Content = elementInfo.GeomLength().ToString();
|
||||
elementSizeValue.Content += " " + UnitsAssignment.GetUnitSymbol("GeomLength", ElementInfoUnits.Assignments, unitSystem);
|
||||
}
|
||||
|
||||
SectionShapeType shapeType = SectionShapeType.Unusual;
|
||||
if (elementInfo.SectionsParams != null)
|
||||
{
|
||||
shapeType = elementInfo.SectionsParams.ShapeType;
|
||||
}
|
||||
|
||||
bool tSectionCollapsedWhenSelected = false;
|
||||
tabSlab.Visibility = System.Windows.Visibility.Collapsed;
|
||||
tabWall.Visibility = System.Windows.Visibility.Collapsed;
|
||||
if (elementInfo.Slabs != null && elementInfo.Slabs.TSection != null)
|
||||
{
|
||||
tabTSection.Visibility = System.Windows.Visibility.Visible;
|
||||
tSectionDescription.DoBinding(elementInfo.Slabs, revitUnitsUI ? null : (Autodesk.Revit.DB.DisplayUnit?)unitSystem, elementInfo.GeomLength());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tabTSection.IsSelected)
|
||||
{
|
||||
tSectionCollapsedWhenSelected = true;
|
||||
}
|
||||
|
||||
tabTSection.Visibility = System.Windows.Visibility.Collapsed;
|
||||
}
|
||||
tabProfile.Visibility = System.Windows.Visibility.Visible;
|
||||
|
||||
if (tabSlab.IsSelected || true == tSectionCollapsedWhenSelected || tabWall.IsSelected)
|
||||
{
|
||||
IInputElement previousFocusedElement = FocusManager.GetFocusedElement(this);
|
||||
tabProfile.Focus();
|
||||
if (previousFocusedElement != null)
|
||||
previousFocusedElement.Focus();
|
||||
}
|
||||
|
||||
sectionDescription.DoBinding(shapeType,
|
||||
elementInfo.Sections,
|
||||
elementInfo.Material != null ? elementInfo.Material.Category == MaterialCategory.Metal : false);
|
||||
sectionParameters.DoBinding(revitElement.Name, elementInfo.SectionsParams, revitUnitsUI ? null : (Autodesk.Revit.DB.DisplayUnit?)unitSystem);
|
||||
break;
|
||||
case ElementType.Slab:
|
||||
elementSizeLabel.Content = "Thickness:";
|
||||
if (revitUnitsUI)
|
||||
{
|
||||
if (elementInfo.Slabs.AsElement != null)
|
||||
{
|
||||
elementSizeValue.Content = UnitsAssignment.FormatToRevitUI("SlabThickness", elementInfo.Slabs.AsElement.Thickness(), ElementInfoUnits.Assignments, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (elementInfo.Slabs.AsElement != null)
|
||||
{
|
||||
elementSizeValue.Content = elementInfo.Slabs.AsElement.Thickness().ToString();
|
||||
elementSizeValue.Content += " " + UnitsAssignment.GetUnitSymbol("SlabThickness", ElementInfoUnits.Assignments, unitSystem);
|
||||
}
|
||||
}
|
||||
|
||||
tabProfile.Visibility = System.Windows.Visibility.Collapsed;
|
||||
tabTSection.Visibility = System.Windows.Visibility.Collapsed;
|
||||
tabWall.Visibility = System.Windows.Visibility.Collapsed;
|
||||
tabSlab.Visibility = System.Windows.Visibility.Visible;
|
||||
|
||||
if (tabProfile.IsSelected || tabTSection.IsSelected || tabWall.IsSelected)
|
||||
{
|
||||
IInputElement previousFocusedElement = FocusManager.GetFocusedElement(this);
|
||||
tabSlab.Focus();
|
||||
if (previousFocusedElement != null)
|
||||
previousFocusedElement.Focus();
|
||||
}
|
||||
|
||||
slabDescription.DoBinding(elementInfo.Slabs, revitUnitsUI ? null : (Autodesk.Revit.DB.DisplayUnit?)unitSystem);
|
||||
break;
|
||||
case ElementType.Wall:
|
||||
elementSizeLabel.Content = "Thickness:";
|
||||
if (revitUnitsUI)
|
||||
{
|
||||
elementSizeValue.Content = UnitsAssignment.FormatToRevitUI("WallThickness", elementInfo.Walls.AsElement.Thickness(), ElementInfoUnits.Assignments, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
elementSizeValue.Content = elementInfo.Walls.AsElement.Thickness().ToString();
|
||||
elementSizeValue.Content += " " + UnitsAssignment.GetUnitSymbol("SlabThickness", ElementInfoUnits.Assignments, unitSystem);
|
||||
}
|
||||
|
||||
tabProfile.Visibility = System.Windows.Visibility.Collapsed;
|
||||
tabTSection.Visibility = System.Windows.Visibility.Collapsed;
|
||||
tabSlab.Visibility = System.Windows.Visibility.Collapsed;
|
||||
tabWall.Visibility = System.Windows.Visibility.Visible;
|
||||
|
||||
if (tabProfile.IsSelected || tabSlab.IsSelected || tabTSection.IsSelected)
|
||||
{
|
||||
IInputElement previousFocusedElement = FocusManager.GetFocusedElement(this);
|
||||
tabWall.Focus();
|
||||
if (previousFocusedElement != null)
|
||||
previousFocusedElement.Focus();
|
||||
}
|
||||
|
||||
wallDescription.DoBinding(elementInfo.Walls.AsElement, revitUnitsUI ? null : (Autodesk.Revit.DB.DisplayUnit?)unitSystem);
|
||||
break;
|
||||
case ElementType.Unknown:
|
||||
default:
|
||||
elementSizeLabel.Content = "";
|
||||
elementSizeValue.Content = "";
|
||||
|
||||
tabProfile.Visibility = System.Windows.Visibility.Collapsed;
|
||||
tabSlab.Visibility = System.Windows.Visibility.Collapsed;
|
||||
tabTSection.Visibility = System.Windows.Visibility.Collapsed;
|
||||
tabWall.Visibility = System.Windows.Visibility.Collapsed;
|
||||
|
||||
if (tabProfile.IsSelected || tabSlab.IsSelected || tabTSection.IsSelected || tabWall.IsSelected)
|
||||
{
|
||||
IInputElement previousFocusedElement = FocusManager.GetFocusedElement(this);
|
||||
tabMaterial.Focus();
|
||||
if (previousFocusedElement != null)
|
||||
previousFocusedElement.Focus();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
MaterialLayerDescription layerDescription = null;
|
||||
Layer structuralLayer = null;
|
||||
|
||||
if (elementInfo.Type == ElementType.Slab)
|
||||
{
|
||||
if (elementInfo.Slabs.AsElement != null)
|
||||
{
|
||||
structuralLayer = elementInfo.Slabs.AsElement.StructuralLayer();
|
||||
}
|
||||
}
|
||||
if (elementInfo.Type == ElementType.Wall)
|
||||
{
|
||||
structuralLayer = elementInfo.Walls.AsElement.StructuralLayer();
|
||||
}
|
||||
|
||||
if (structuralLayer != null)
|
||||
{
|
||||
layerDescription = new MaterialLayerDescription(structuralLayer.Thickness, structuralLayer.Offset);
|
||||
}
|
||||
|
||||
materialParameters.DoBinding(elementInfo.Material, layerDescription, revitUnitsUI ? null : (Autodesk.Revit.DB.DisplayUnit?)unitSystem);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
#region private members and methods
|
||||
//--------------------------------------------------------------
|
||||
|
||||
private void EnableElementsNavigateButtons()
|
||||
{
|
||||
if(elements.Items.CurrentPosition == 0)
|
||||
{
|
||||
previous.IsEnabled = false;
|
||||
next.IsEnabled = elements.Items.Count > 1 ? true : false;
|
||||
}
|
||||
else
|
||||
if (elements.Items.CurrentPosition == elements.Items.Count - 1)
|
||||
{
|
||||
previous.IsEnabled = true;
|
||||
next.IsEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
previous.IsEnabled = true;
|
||||
next.IsEnabled = true;
|
||||
}
|
||||
|
||||
SetImageToNavigateButton(previous_, previous.IsEnabled);
|
||||
SetImageToNavigateButton(next_, next.IsEnabled);
|
||||
}
|
||||
|
||||
private void SetImageToNavigateButton(Image image, bool enabled)
|
||||
{
|
||||
BitmapImage source = new BitmapImage();
|
||||
source.BeginInit();
|
||||
string uriString = "/SectionPropertiesExplorer;component/Resources/Images/";
|
||||
uriString += image.Name + (enabled ? "enabled" : "disabled") + ".png";
|
||||
source.UriSource = new Uri(uriString, UriKind.Relative);
|
||||
source.EndInit();
|
||||
image.Source = source;
|
||||
}
|
||||
|
||||
bool revitUnitsUI;
|
||||
private Autodesk.Revit.DB.DisplayUnit unitSystem;
|
||||
|
||||
//--------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
private void previous_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(elements.Items.CurrentPosition > 0)
|
||||
{
|
||||
elements.Items.MoveCurrentToPrevious();
|
||||
}
|
||||
}
|
||||
|
||||
private void next_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(elements.Items.CurrentPosition < elements.Items.Count -1)
|
||||
{
|
||||
elements.Items.MoveCurrentToNext();
|
||||
}
|
||||
}
|
||||
|
||||
private void elements_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
EnableElementsNavigateButtons();
|
||||
if (elements.Items.CurrentPosition >= 0 && elements.Items.CurrentPosition < revitElements.Count)
|
||||
{
|
||||
DataBinding(revitElements[elements.Items.CurrentPosition]);
|
||||
if (ElementSelectedEventHandler != null)
|
||||
ElementSelectedEventHandler(elements, new ElementSelectedEventArgs(revitElements[elements.Items.CurrentPosition]));
|
||||
}
|
||||
}
|
||||
|
||||
private void radioRevit_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
revitElementAnalyser = null;
|
||||
revitUnitsUI = true;
|
||||
unitSystem = Autodesk.Revit.DB.DisplayUnit.IMPERIAL;
|
||||
if (revitElements != null && revitElements.Count > 0)
|
||||
{
|
||||
DataBinding(revitElements[elements.Items.CurrentPosition]);
|
||||
}
|
||||
}
|
||||
|
||||
private void radioImperial_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
revitElementAnalyser = null;
|
||||
revitUnitsUI = false;
|
||||
unitSystem = Autodesk.Revit.DB.DisplayUnit.IMPERIAL;
|
||||
if (revitElements != null && revitElements.Count > 0)
|
||||
{
|
||||
DataBinding(revitElements[elements.Items.CurrentPosition]);
|
||||
}
|
||||
}
|
||||
|
||||
private void radioMetric_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
revitElementAnalyser = null;
|
||||
revitUnitsUI = false;
|
||||
unitSystem = Autodesk.Revit.DB.DisplayUnit.METRIC;
|
||||
if (revitElements != null && revitElements.Count > 0)
|
||||
{
|
||||
DataBinding(revitElements[elements.Items.CurrentPosition]);
|
||||
}
|
||||
}
|
||||
|
||||
private void tabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class ElementEntry
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ElementEntry(Autodesk.Revit.DB.Element revitElement)
|
||||
{
|
||||
string elementDescription;
|
||||
Autodesk.Revit.DB.BuiltInCategory cat = (Autodesk.Revit.DB.BuiltInCategory)revitElement.Category.Id.IntegerValue;
|
||||
switch (cat)
|
||||
{
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_StructuralColumns:
|
||||
elementDescription = "Column: ";
|
||||
break;
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_StructuralFraming:
|
||||
elementDescription = "Beam: ";
|
||||
break;
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_Floors:
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_StructuralFoundation:
|
||||
elementDescription = "Slab: ";
|
||||
break;
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_Walls:
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical:
|
||||
elementDescription = "Wall: ";
|
||||
break;
|
||||
default:
|
||||
elementDescription = "UnKnown: ";
|
||||
break;
|
||||
}
|
||||
|
||||
elementDescription += "( " + revitElement.Id.ToString() + " )";
|
||||
|
||||
if (revitElement.Name.Length > 0)
|
||||
{
|
||||
elementDescription += " ";
|
||||
elementDescription += revitElement.Name;
|
||||
}
|
||||
this.name = elementDescription;
|
||||
}
|
||||
|
||||
private string name;
|
||||
}
|
||||
|
||||
class ConnectionViewModel : INotifyPropertyChanged
|
||||
{
|
||||
public ConnectionViewModel(List<Autodesk.Revit.DB.Element> revitElements)
|
||||
{
|
||||
IList<ElementEntry> list = new List<ElementEntry>();
|
||||
foreach (Autodesk.Revit.DB.Element e in revitElements)
|
||||
{
|
||||
list.Add(new ElementEntry(e));
|
||||
}
|
||||
ElementEntries = new CollectionView(list);
|
||||
if(list.Count > 0)
|
||||
elementEntry = list[0].Name;
|
||||
}
|
||||
|
||||
public CollectionView ElementEntries { get; private set; }
|
||||
|
||||
public string ElementEntry
|
||||
{
|
||||
get
|
||||
{
|
||||
return elementEntry;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (elementEntry == value)
|
||||
return;
|
||||
elementEntry = value;
|
||||
OnPropertyChanged("ElementEntry");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private string elementEntry;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<UserControl x:Class="SectionPropertiesExplorer.MaterialParametersControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="400" d:DesignWidth="690">
|
||||
<DockPanel LastChildFill="True">
|
||||
<DockPanel DockPanel.Dock="Top">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Name="MaterialNameLabel" Content="Name :" HorizontalAlignment="Left" Height="25" DockPanel.Dock="Top"/>
|
||||
<Label Name="MaterialName" Content="No name" HorizontalAlignment="Center" Height="25" DockPanel.Dock="Top"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Name="MaterialDescriptionLabel" Content="Description :" HorizontalAlignment="Center" Height="25" DockPanel.Dock="Top"/>
|
||||
<Label Name="MaterialDescription" Content="No description" HorizontalAlignment="Center" Height="25" DockPanel.Dock="Top"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Name="LayerDescription" HorizontalAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Name="LayerThicknessLabel" Content="Structural layer thickness :" HorizontalAlignment="Center" Height="25" DockPanel.Dock="Top"/>
|
||||
<Label Name="LayerThickness" Content="No value" HorizontalAlignment="Center" Height="25" DockPanel.Dock="Top"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Name="LayerOffsetLabel" Content="Structural layer offset :" HorizontalAlignment="Center" Height="25" DockPanel.Dock="Top"/>
|
||||
<Label Name="LayerOffset" Content="No value" HorizontalAlignment="Center" Height="25" DockPanel.Dock="Top"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
<ListView Name="materialParameters" Width="auto" Margin="0 10 0 0" DockPanel.Dock="Bottom">
|
||||
<ListView.View>
|
||||
<GridView AllowsColumnReorder="False">
|
||||
<GridView.Columns>
|
||||
<GridViewColumn Header="Property name of characteristic" Width="400" DisplayMemberBinding="{Binding Name}" />
|
||||
<GridViewColumn Header="Value" Width="158" DisplayMemberBinding="{Binding Value}" />
|
||||
<GridViewColumn Header="Unit" Width="120" DisplayMemberBinding="{Binding Unit}" />
|
||||
</GridView.Columns>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,246 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 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.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using XYZ = Autodesk.Revit.DB.XYZ;
|
||||
using Autodesk.Revit.DB.CodeChecking.Engineering;
|
||||
|
||||
namespace SectionPropertiesExplorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MaterialParameters.xaml
|
||||
/// </summary>
|
||||
public partial class MaterialParametersControl : UserControl
|
||||
{
|
||||
public MaterialParametersControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void DoBinding(MaterialInfo materialParams,
|
||||
MaterialLayerDescription layerDescription,
|
||||
Autodesk.Revit.DB.DisplayUnit? unitSystem)
|
||||
{
|
||||
if (layerDescription != null)
|
||||
{
|
||||
string unitThicknessName = "LayerThickness";
|
||||
string unitOffsetName = "LayerOffset";
|
||||
|
||||
string unitThickness;
|
||||
string unitOffset;
|
||||
if (null == unitSystem)
|
||||
{
|
||||
unitThickness = UnitsAssignment.GetUnitSymbol(unitThicknessName, ElementInfoUnits.Assignments);
|
||||
unitOffset = UnitsAssignment.GetUnitSymbol(unitOffsetName, ElementInfoUnits.Assignments);
|
||||
}
|
||||
else
|
||||
{
|
||||
unitThickness = UnitsAssignment.GetUnitSymbol(unitThicknessName, ElementInfoUnits.Assignments, (Autodesk.Revit.DB.DisplayUnit)unitSystem);
|
||||
unitOffset = UnitsAssignment.GetUnitSymbol(unitOffsetName, ElementInfoUnits.Assignments, (Autodesk.Revit.DB.DisplayUnit)unitSystem);
|
||||
}
|
||||
|
||||
string stringThicknessValue = layerDescription.LayerThickness.ToString();
|
||||
string stringOffsetValue = layerDescription.LayerOffset.ToString();
|
||||
|
||||
if (null == unitSystem)
|
||||
{
|
||||
stringThicknessValue = UnitsAssignment.FormatToRevitUI(unitThicknessName, layerDescription.LayerThickness, ElementInfoUnits.Assignments);
|
||||
stringOffsetValue = UnitsAssignment.FormatToRevitUI(unitOffsetName, layerDescription.LayerOffset, ElementInfoUnits.Assignments);
|
||||
}
|
||||
|
||||
LayerThickness.Content = stringThicknessValue + " " + unitThickness;
|
||||
LayerOffset.Content = stringOffsetValue + " " + unitOffset;
|
||||
|
||||
LayerDescription.Visibility = System.Windows.Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
LayerDescription.Visibility = System.Windows.Visibility.Collapsed;
|
||||
}
|
||||
|
||||
List<MaterialParameterDescription> matParDescrList = new List<MaterialParameterDescription>();
|
||||
|
||||
if (materialParams.Category != MaterialCategory.Undefined)
|
||||
{
|
||||
MaterialName.Content = materialParams.Properties.Name;
|
||||
MaterialDescription.Content = materialParams.Properties.Description;
|
||||
|
||||
MaterialCharacteristics materialCharacteristics = materialParams.Characteristics;
|
||||
foreach (object o in materialCharacteristics)
|
||||
{
|
||||
List<MaterialParameterDescription> matParDescr = ParameterBinding(o, materialCharacteristics, MaterialCharacteristicsUnits.Assignments, unitSystem);
|
||||
if (null == matParDescr)
|
||||
continue;
|
||||
matParDescrList.AddRange(matParDescr);
|
||||
}
|
||||
}
|
||||
|
||||
switch (materialParams.Category)
|
||||
{
|
||||
case MaterialCategory.Concrete:
|
||||
MaterialConcreteCharacteristics concrete = (MaterialConcreteCharacteristics)materialParams.Characteristics.Specific;
|
||||
foreach (object o in concrete)
|
||||
{
|
||||
List<MaterialParameterDescription> matParDescr = ParameterBinding(o, concrete, MaterialConcreteCharacteristicsUnits.Assignments, unitSystem);
|
||||
if (matParDescr != null)
|
||||
matParDescrList.AddRange(matParDescr);
|
||||
}
|
||||
break;
|
||||
case MaterialCategory.Metal:
|
||||
MaterialMetalCharacteristics metal = (MaterialMetalCharacteristics)materialParams.Characteristics.Specific;
|
||||
foreach (object o in metal)
|
||||
{
|
||||
List<MaterialParameterDescription> matParDescr = ParameterBinding(o, metal, MaterialMetalCharacteristicsUnits.Assignments, unitSystem);
|
||||
if (matParDescr != null)
|
||||
matParDescrList.AddRange(matParDescr);
|
||||
}
|
||||
|
||||
break;
|
||||
case MaterialCategory.Timber:
|
||||
MaterialTimberCharacteristics timber = (MaterialTimberCharacteristics)materialParams.Characteristics.Specific;
|
||||
foreach (object o in timber)
|
||||
{
|
||||
List<MaterialParameterDescription> matParDescr = ParameterBinding(o, timber, MaterialTimberCharacteristicsUnits.Assignments, unitSystem);
|
||||
if (matParDescr != null)
|
||||
matParDescrList.AddRange(matParDescr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
materialParameters.ItemsSource = matParDescrList;
|
||||
}
|
||||
|
||||
private List<MaterialParameterDescription> ParameterBinding(object property,
|
||||
object propertOwnerObject,
|
||||
UnitsAssignment[] unitsAssignment,
|
||||
Autodesk.Revit.DB.DisplayUnit? unitSystem)
|
||||
{
|
||||
System.Reflection.PropertyInfo pi = property as System.Reflection.PropertyInfo;
|
||||
string name = pi.Name;
|
||||
object oValue = pi.GetValue(propertOwnerObject, null);
|
||||
|
||||
if (!(oValue is double) && !(oValue is XYZ))
|
||||
return null;
|
||||
|
||||
List<MaterialParameterDescription> listMatParDescr = new List<MaterialParameterDescription>();
|
||||
|
||||
int max_i = 3;
|
||||
string dirTxt = "";
|
||||
for (int i = 0; i < max_i; i++)
|
||||
{
|
||||
double value = 0.0;
|
||||
|
||||
if (oValue is double)
|
||||
{
|
||||
value = (double)oValue;
|
||||
max_i = 1;
|
||||
}
|
||||
else
|
||||
if (oValue is XYZ)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
dirTxt = " X";
|
||||
value = (double)(((XYZ)oValue).X);
|
||||
break;
|
||||
case 1:
|
||||
dirTxt = " Y";
|
||||
value = (double)(((XYZ)oValue).Y);
|
||||
break;
|
||||
case 2:
|
||||
dirTxt = " Z";
|
||||
value = (double)(((XYZ)oValue).Z);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Math.Abs(value) < double.Epsilon)
|
||||
continue;
|
||||
|
||||
string unit;
|
||||
if (null == unitSystem)
|
||||
{
|
||||
unit = UnitsAssignment.GetUnitSymbol(name, unitsAssignment);
|
||||
}
|
||||
else
|
||||
{
|
||||
unit = UnitsAssignment.GetUnitSymbol(name, unitsAssignment, (Autodesk.Revit.DB.DisplayUnit)unitSystem);
|
||||
}
|
||||
|
||||
string stringValue = value.ToString();
|
||||
|
||||
if (null == unitSystem)
|
||||
{
|
||||
stringValue = UnitsAssignment.FormatToRevitUI(name, value, unitsAssignment);
|
||||
}
|
||||
|
||||
listMatParDescr.Add(new MaterialParameterDescription(name + dirTxt, stringValue, unit));
|
||||
}
|
||||
|
||||
if(listMatParDescr.Count < 1)
|
||||
return null;
|
||||
|
||||
return listMatParDescr;
|
||||
}
|
||||
}
|
||||
|
||||
public class MaterialLayerDescription
|
||||
{
|
||||
public MaterialLayerDescription(double layerThickness, double layerOffset)
|
||||
{
|
||||
LayerOffset = layerOffset;
|
||||
LayerThickness = layerThickness;
|
||||
}
|
||||
|
||||
public double LayerThickness { get; private set; }
|
||||
public double LayerOffset { get; private set; }
|
||||
}
|
||||
|
||||
class MaterialParameterDescription
|
||||
{
|
||||
public MaterialParameterDescription(string name, string value, string unit)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
Unit = unit;
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
public string Value { get; private set; }
|
||||
public string Unit { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
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("SectionPropertiesExplorer")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Autodesk")]
|
||||
[assembly: AssemblyProduct("SectionPropertiesExplorer")]
|
||||
[assembly: AssemblyCopyright("Autodesk 2013")]
|
||||
[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("8ee1cc48-da69-4017-bfa9-17a4d9df9c2d")]
|
||||
|
||||
// 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 Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2015.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("2015.0.0.2464")]
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 600 B |
|
After Width: | Height: | Size: 203 B |
|
After Width: | Height: | Size: 200 B |
|
After Width: | Height: | Size: 208 B |
|
After Width: | Height: | Size: 204 B |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 549 B |
|
After Width: | Height: | Size: 709 B |
@@ -0,0 +1,28 @@
|
||||
<UserControl x:Class="SectionPropertiesExplorer.SectionDescriptionControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="400" Loaded="UserControl_Loaded">
|
||||
<DockPanel LastChildFill="True">
|
||||
<DockPanel DockPanel.Dock="Top">
|
||||
<DockPanel DockPanel.Dock="Top" HorizontalAlignment="Center">
|
||||
<Label Content="Section type:" Height="26" HorizontalAlignment="Left" />
|
||||
<Label Name="sectionTypeName" Content="Unknown" Height="26" HorizontalAlignment="Left" Margin="10 0 0 0"/>
|
||||
</DockPanel>
|
||||
<Image Name="sectionDefinition" Stretch="None" Width="200" Height="200" Margin="3 0 0 0" DockPanel.Dock="Bottom" Source="/CodeChecking.Engineering.SelfTest;component/Resources/Images/sectionUnusual.png"></Image>
|
||||
</DockPanel>
|
||||
<Label Content="Real shapes of element:" Height="26" HorizontalAlignment="Center" Margin="0 5 0 0" DockPanel.Dock="Top"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<DockPanel>
|
||||
<Label Content="At the begin:" Height="26" HorizontalAlignment="Center" DockPanel.Dock="Top"/>
|
||||
<Canvas Name="sectionAtTheBegViewer" Width="130" MinHeight="110" Margin="5 0 3 5" DockPanel.Dock="Bottom"></Canvas>
|
||||
</DockPanel>
|
||||
<DockPanel>
|
||||
<Label Content="At the end:" Height="26" HorizontalAlignment="Center" DockPanel.Dock="Top"/>
|
||||
<Canvas Name="sectionAtTheEndViewer" Width="130" MinHeight="110" Margin="3 0 5 5" DockPanel.Dock="Bottom"></Canvas>
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,274 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 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.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
using Autodesk.Revit.DB.CodeChecking.Engineering;
|
||||
|
||||
using XYZ = Autodesk.Revit.DB.XYZ;
|
||||
|
||||
namespace SectionPropertiesExplorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SectionDescription.xaml
|
||||
/// </summary>
|
||||
public partial class SectionDescriptionControl : UserControl
|
||||
{
|
||||
public SectionDescriptionControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void DoBinding(SectionShapeType shapeType, ElementSectionsInfo sectionsInfo, bool isSteel = false)
|
||||
{
|
||||
sectionTypeName.Content = Tools.SectionShapeTypeName(shapeType);
|
||||
|
||||
BitmapImage source = new BitmapImage();
|
||||
source.BeginInit();
|
||||
string uriString = "/SectionPropertiesExplorer;component/Resources/Images/section";
|
||||
string typeName = Tools.SectionShapeTypeName(shapeType);
|
||||
string steelTxt = "";
|
||||
if (shapeType == SectionShapeType.Z && isSteel)
|
||||
{
|
||||
steelTxt = "steel";
|
||||
}
|
||||
uriString += typeName + steelTxt + ".png";
|
||||
source.UriSource = new Uri(uriString, UriKind.Relative);
|
||||
source.EndInit();
|
||||
sectionDefinition.Source = source;
|
||||
|
||||
AddShapesToRender(sectionsInfo);
|
||||
}
|
||||
|
||||
private double ScaleBetweenSections(SectionsInfo secAtTheBeg, SectionsInfo secAtTheEnd)
|
||||
{
|
||||
XYZ xyz_min_Beg = secAtTheBeg.GetMinimumBoundary();
|
||||
XYZ xyz_max_Beg = secAtTheBeg.GetMaximumBoundary();
|
||||
XYZ xyz_min_End = secAtTheEnd.GetMinimumBoundary();
|
||||
XYZ xyz_max_End = secAtTheEnd.GetMaximumBoundary();
|
||||
|
||||
double widthBeg = Math.Abs(xyz_max_Beg.X - xyz_min_Beg.X);
|
||||
double widthEnd = Math.Abs(xyz_max_End.X - xyz_min_End.X);
|
||||
|
||||
double heightBeg = Math.Abs(xyz_max_Beg.Y - xyz_min_Beg.Y);
|
||||
double heightEnd = Math.Abs(xyz_max_End.Y - xyz_min_End.Y);
|
||||
|
||||
double widthScale = widthEnd / widthBeg;
|
||||
double heightScale = heightEnd / heightBeg;
|
||||
|
||||
if (widthScale > 1.0)
|
||||
{
|
||||
if (heightScale > 1.0)
|
||||
{
|
||||
return Math.Max(widthScale, heightScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Math.Max(widthScale, 1.0 / heightScale) > widthScale)
|
||||
{
|
||||
return heightScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
return widthScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (heightScale < 1.0)
|
||||
{
|
||||
return Math.Min(widthScale, heightScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Math.Min(widthScale, 1.0 / heightScale) < widthScale)
|
||||
{
|
||||
return heightScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
return widthScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddShapesToRender(ElementSectionsInfo info)
|
||||
{
|
||||
double scale = ScaleBetweenSections(info.AtTheBeg, info.AtTheEnd);
|
||||
AddShapesToRender(info.AtTheBeg, sectionAtTheBegViewer, scale > 1.0 ? 1.0/scale : 1.0);
|
||||
AddShapesToRender(info.AtTheEnd, sectionAtTheEndViewer, scale > 1.0 ? 1.0 : scale);
|
||||
}
|
||||
|
||||
private void AddShapesToRender(SectionsInfo sectionsInfo, Canvas sectionViewer, double scale)
|
||||
{
|
||||
sectionViewer.Children.Clear();
|
||||
|
||||
double actualWidth = sectionViewer.Width;
|
||||
double actualHeight = sectionViewer.MinHeight;
|
||||
|
||||
if (sectionViewer.ActualWidth > 0)
|
||||
{
|
||||
actualWidth = sectionViewer.ActualWidth;
|
||||
}
|
||||
|
||||
if (sectionViewer.ActualHeight > 0)
|
||||
{
|
||||
actualHeight = sectionViewer.ActualHeight;
|
||||
}
|
||||
|
||||
double horizontalMargin = actualWidth / 6;
|
||||
double verticalMargin = actualHeight / 6;
|
||||
|
||||
double width = actualWidth - 2 * horizontalMargin;
|
||||
double height = actualHeight - 2 * verticalMargin;
|
||||
|
||||
horizontalMargin += (width - width * scale) / 2.0;
|
||||
verticalMargin += (height - height * scale) / 2.0;
|
||||
|
||||
double horizontalShift = horizontalMargin;
|
||||
double verticalShift = verticalMargin;
|
||||
|
||||
XYZ xyz_min = sectionsInfo.GetMinimumBoundary();
|
||||
XYZ xyz_max = sectionsInfo.GetMaximumBoundary();
|
||||
|
||||
width = Math.Abs(xyz_max.X - xyz_min.X);
|
||||
height = Math.Abs(xyz_max.Y - xyz_min.Y);
|
||||
|
||||
double stretchCoeff = 0;
|
||||
if (height > width)
|
||||
{
|
||||
stretchCoeff = (actualHeight - 2 * verticalMargin) / height;
|
||||
horizontalShift += (height - width) * stretchCoeff / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
stretchCoeff = (actualWidth - 2 * horizontalMargin) / width;
|
||||
verticalShift += (width - height) * stretchCoeff / 2;
|
||||
}
|
||||
|
||||
if (xyz_min.X < 0)
|
||||
horizontalShift -= stretchCoeff * xyz_min.X;
|
||||
if (xyz_min.Y < 0)
|
||||
verticalShift -= stretchCoeff * xyz_min.Y;
|
||||
|
||||
List<System.Windows.Shapes.Shape> contours = new List<System.Windows.Shapes.Shape>();
|
||||
List<System.Windows.Shapes.Shape> holes = new List<System.Windows.Shapes.Shape>();
|
||||
|
||||
XYZ maxB = sectionsInfo.GetMaximumBoundary();
|
||||
XYZ minB = sectionsInfo.GetMinimumBoundary();
|
||||
|
||||
foreach (Autodesk.Revit.DB.CodeChecking.Engineering.Section section in sectionsInfo.Sections)
|
||||
{
|
||||
Polygon polygon = new Polygon();
|
||||
PointCollection points = new PointCollection();
|
||||
foreach (XYZ xyz in section.Contour.Points)
|
||||
{
|
||||
points.Add(new Point(xyz.X * stretchCoeff, (minB.Y + (maxB.Y - xyz.Y)) * stretchCoeff));
|
||||
}
|
||||
polygon.Points = points;
|
||||
polygon.Fill = Brushes.LightSteelBlue;
|
||||
polygon.Stretch = Stretch.None;
|
||||
polygon.Stroke = Brushes.Black;
|
||||
polygon.StrokeThickness = 1;
|
||||
|
||||
contours.Add(polygon);
|
||||
|
||||
foreach (Autodesk.Revit.DB.CodeChecking.Engineering.Shape shape in section.Holes)
|
||||
{
|
||||
polygon = new Polygon();
|
||||
points = new PointCollection();
|
||||
foreach (XYZ xyz in shape.Points)
|
||||
{
|
||||
points.Add(new Point(xyz.X * stretchCoeff, (minB.Y + (maxB.Y - xyz.Y)) * stretchCoeff));
|
||||
}
|
||||
polygon.Points = points;
|
||||
polygon.Fill = Brushes.White;
|
||||
polygon.Stretch = Stretch.None;
|
||||
polygon.Stroke = Brushes.Black;
|
||||
polygon.StrokeThickness = 1;
|
||||
|
||||
holes.Add(polygon);
|
||||
}
|
||||
}
|
||||
|
||||
if (contours.Count() < 1)
|
||||
{
|
||||
horizontalShift = (actualWidth - defaultShapeToRender.Width) / 2;
|
||||
verticalShift = (actualHeight - defaultShapeToRender.Height) / 2;
|
||||
Canvas.SetLeft(defaultShapeToRender, horizontalShift);
|
||||
Canvas.SetTop(defaultShapeToRender, verticalShift);
|
||||
sectionViewer.Children.Add(defaultShapeToRender);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (System.Windows.Shapes.Shape contour in contours)
|
||||
{
|
||||
Canvas.SetLeft(contour, horizontalShift);
|
||||
Canvas.SetTop(contour, verticalShift);
|
||||
sectionViewer.Children.Add(contour);
|
||||
}
|
||||
|
||||
foreach (System.Windows.Shapes.Shape hole in holes)
|
||||
{
|
||||
Canvas.SetLeft(hole, horizontalShift);
|
||||
Canvas.SetTop(hole, verticalShift);
|
||||
sectionViewer.Children.Add(hole);
|
||||
}
|
||||
}
|
||||
|
||||
private void DefaultShapeToRender()
|
||||
{
|
||||
defaultShapeToRender = new Rectangle()
|
||||
{
|
||||
Fill = Brushes.LightSteelBlue,
|
||||
Height = 100,
|
||||
Width = 100,
|
||||
RadiusX = 5,
|
||||
RadiusY = 5,
|
||||
HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
|
||||
VerticalAlignment = System.Windows.VerticalAlignment.Center
|
||||
};
|
||||
}
|
||||
|
||||
System.Windows.Shapes.Shape defaultShapeToRender = null;
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (null == defaultShapeToRender)
|
||||
DefaultShapeToRender();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<UserControl x:Class="SectionPropertiesExplorer.SectionParametersControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="400">
|
||||
<DockPanel LastChildFill="True">
|
||||
<DockPanel HorizontalAlignment="Center" DockPanel.Dock="Top">
|
||||
<Label Content="Section name:" Height="26" HorizontalAlignment="Right" />
|
||||
<Label Name="sectionName" Content="Unknown" Height="26" HorizontalAlignment="Left" Margin="10 0 0 0"/>
|
||||
</DockPanel>
|
||||
<ListView Name="sectionParameters" MinHeight="374" Width="auto" DockPanel.Dock="Top">
|
||||
<ListView.View>
|
||||
<GridView AllowsColumnReorder="False">
|
||||
<GridView.Columns>
|
||||
<GridViewColumn Header="Name" Width="60" DisplayMemberBinding="{Binding Name}" />
|
||||
<GridViewColumn Header="At the begin" Width="145" DisplayMemberBinding="{Binding ValueAtTheBeg}" />
|
||||
<GridViewColumn Header="At the end" Width="145" DisplayMemberBinding="{Binding ValueAtTheEnd}" />
|
||||
<GridViewColumn Header="Unit" Width="55" DisplayMemberBinding="{Binding Unit}" />
|
||||
</GridView.Columns>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
<TabControl Name="tabControl" DockPanel.Dock="Top">
|
||||
<TabItem Header="General" Name="tabCompoundSection">
|
||||
<ListView Name="compoundSectionParameters" Width="auto">
|
||||
<ListView.View>
|
||||
<GridView AllowsColumnReorder="False">
|
||||
<GridView.Columns>
|
||||
<GridViewColumn Header="Name" Width="60" DisplayMemberBinding="{Binding Name}" />
|
||||
<GridViewColumn Header="At the begin" Width="145" DisplayMemberBinding="{Binding ValueAtTheBeg}" />
|
||||
<GridViewColumn Header="At the end" Width="145" DisplayMemberBinding="{Binding ValueAtTheEnd}" />
|
||||
<GridViewColumn Header="Unit" Width="55" DisplayMemberBinding="{Binding Unit}" />
|
||||
</GridView.Columns>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</TabItem>
|
||||
<TabItem Header="Section1" Name="tabSection1">
|
||||
<ListView Name="section1Parameters" Width="auto">
|
||||
<ListView.View>
|
||||
<GridView AllowsColumnReorder="False">
|
||||
<GridView.Columns>
|
||||
<GridViewColumn Header="Name" Width="60" DisplayMemberBinding="{Binding Name}" />
|
||||
<GridViewColumn Header="At the begin" Width="145" DisplayMemberBinding="{Binding ValueAtTheBeg}" />
|
||||
<GridViewColumn Header="At the end" Width="145" DisplayMemberBinding="{Binding ValueAtTheEnd}" />
|
||||
<GridViewColumn Header="Unit" Width="55" DisplayMemberBinding="{Binding Unit}" />
|
||||
</GridView.Columns>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</TabItem>
|
||||
<TabItem Header="Section2" Name="tabSection2">
|
||||
<ListView Name="section2Parameters" Width="auto">
|
||||
<ListView.View>
|
||||
<GridView AllowsColumnReorder="False">
|
||||
<GridView.Columns>
|
||||
<GridViewColumn Header="Name" Width="60" DisplayMemberBinding="{Binding Name}" />
|
||||
<GridViewColumn Header="At the begin" Width="145" DisplayMemberBinding="{Binding ValueAtTheBeg}" />
|
||||
<GridViewColumn Header="At the end" Width="145" DisplayMemberBinding="{Binding ValueAtTheEnd}" />
|
||||
<GridViewColumn Header="Unit" Width="55" DisplayMemberBinding="{Binding Unit}" />
|
||||
</GridView.Columns>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,297 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 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.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
using Autodesk.Revit.DB.CodeChecking.Engineering;
|
||||
|
||||
namespace SectionPropertiesExplorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SectionParameters.xaml
|
||||
/// </summary>
|
||||
public partial class SectionParametersControl : UserControl
|
||||
{
|
||||
public SectionParametersControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void DoBinding(string sectionName, ElementSectionsParamsInfo sectionsParams, Autodesk.Revit.DB.DisplayUnit? unitSystem)
|
||||
{
|
||||
this.sectionName.Content = sectionName;
|
||||
|
||||
if (null == sectionsParams)
|
||||
{
|
||||
sectionParameters.ItemsSource = null;
|
||||
return;
|
||||
}
|
||||
|
||||
IEnumerable itemsSource = CreateItemSource(0, sectionsParams.AtTheBeg.Dimensions,
|
||||
sectionsParams.Tapered ? sectionsParams.AtTheEnd.Dimensions : null,
|
||||
sectionsParams.AtTheBeg.Characteristics,
|
||||
sectionsParams.Tapered ? sectionsParams.AtTheEnd.Characteristics : null,
|
||||
unitSystem);
|
||||
|
||||
if (sectionsParams.ShapeType != SectionShapeType.DoubleSection && sectionsParams.ShapeType != SectionShapeType.CompoundSection)
|
||||
{
|
||||
tabControl.Visibility = System.Windows.Visibility.Collapsed;
|
||||
|
||||
compoundSectionParameters.Visibility = System.Windows.Visibility.Collapsed;
|
||||
compoundSectionParameters.ItemsSource = null;
|
||||
|
||||
sectionParameters.Visibility = System.Windows.Visibility.Visible;
|
||||
sectionParameters.ItemsSource = itemsSource;
|
||||
}
|
||||
else
|
||||
{
|
||||
tabControl.Visibility = System.Windows.Visibility.Visible;
|
||||
|
||||
compoundSectionParameters.Visibility = System.Windows.Visibility.Visible;
|
||||
compoundSectionParameters.ItemsSource = itemsSource;
|
||||
|
||||
sectionParameters.Visibility = System.Windows.Visibility.Collapsed;
|
||||
sectionParameters.ItemsSource = null;
|
||||
}
|
||||
|
||||
bool isCompoundSection = SectionShapeType.CompoundSection == sectionsParams.ShapeType;
|
||||
|
||||
int maxIndex = (isCompoundSection ? 1 : 0);
|
||||
|
||||
if (sectionsParams.ShapeType == SectionShapeType.DoubleSection || isCompoundSection)
|
||||
{
|
||||
if (sectionsParams.AtTheBeg.ComponentsDimensions.Count > maxIndex &&
|
||||
sectionsParams.AtTheBeg.ComponentsCharacteristics.Count > maxIndex &&
|
||||
(sectionsParams.Tapered ? sectionsParams.AtTheEnd.ComponentsDimensions.Count > maxIndex : true) &&
|
||||
(sectionsParams.Tapered ? sectionsParams.AtTheEnd.ComponentsCharacteristics.Count > maxIndex : true))
|
||||
{
|
||||
if (sectionsParams.ComponentsShapeType.Count > maxIndex)
|
||||
{
|
||||
tabSection1.Header = Tools.SectionShapeTypeName(sectionsParams.ComponentsShapeType[maxIndex]) + " component";
|
||||
}
|
||||
else
|
||||
{
|
||||
tabSection2.Header = "Unknown type";
|
||||
}
|
||||
|
||||
section1Parameters.ItemsSource = CreateItemSource(isCompoundSection ? 1 : 0,
|
||||
sectionsParams.AtTheBeg.ComponentsDimensions[maxIndex],
|
||||
sectionsParams.Tapered ? sectionsParams.AtTheEnd.ComponentsDimensions[maxIndex] : null,
|
||||
sectionsParams.AtTheBeg.ComponentsCharacteristics[maxIndex],
|
||||
sectionsParams.Tapered ? sectionsParams.AtTheEnd.ComponentsCharacteristics[maxIndex] : null,
|
||||
unitSystem);
|
||||
tabSection1.Visibility = System.Windows.Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
tabSection1.Visibility = System.Windows.Visibility.Collapsed;
|
||||
section1Parameters.ItemsSource = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tabSection1.Visibility = System.Windows.Visibility.Collapsed;
|
||||
section1Parameters.ItemsSource = null;
|
||||
}
|
||||
|
||||
if (sectionsParams.ShapeType == SectionShapeType.CompoundSection)
|
||||
{
|
||||
if (sectionsParams.AtTheBeg.ComponentsDimensions.Count > 0 &&
|
||||
sectionsParams.AtTheBeg.ComponentsCharacteristics.Count > 0 &&
|
||||
sectionsParams.Tapered ? sectionsParams.AtTheEnd.ComponentsDimensions.Count > 0 : true &&
|
||||
sectionsParams.Tapered ? sectionsParams.AtTheEnd.ComponentsCharacteristics.Count > 0 : true)
|
||||
{
|
||||
if (sectionsParams.ComponentsShapeType.Count > 0)
|
||||
{
|
||||
tabSection2.Header = Tools.SectionShapeTypeName(sectionsParams.ComponentsShapeType[0]) + " component";
|
||||
}
|
||||
else
|
||||
{
|
||||
tabSection2.Header = "Unknown type";
|
||||
}
|
||||
|
||||
section2Parameters.ItemsSource = CreateItemSource(2, sectionsParams.AtTheBeg.ComponentsDimensions[0],
|
||||
sectionsParams.Tapered ? sectionsParams.AtTheEnd.ComponentsDimensions[0] : null,
|
||||
sectionsParams.AtTheBeg.ComponentsCharacteristics[0],
|
||||
sectionsParams.Tapered ? sectionsParams.AtTheEnd.ComponentsCharacteristics[0] : null,
|
||||
unitSystem);
|
||||
tabSection2.Visibility = System.Windows.Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
tabSection2.Visibility = System.Windows.Visibility.Collapsed;
|
||||
section2Parameters.ItemsSource = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tabSection2.Visibility = System.Windows.Visibility.Collapsed;
|
||||
section2Parameters.ItemsSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
private List<SectionParameterDescription> CreateItemSource(int componentNo,
|
||||
SectionDimensions dimensionsAtTheBeg,
|
||||
SectionDimensions dimensionsAtTheEnd,
|
||||
SectionCharacteristics characteristicsAtTheBeg,
|
||||
SectionCharacteristics characteristicsAtTheEnd,
|
||||
Autodesk.Revit.DB.DisplayUnit? unitSystem)
|
||||
{
|
||||
List<SectionParameterDescription> secParDescrList = new List<SectionParameterDescription>();
|
||||
|
||||
foreach (object oBeg in dimensionsAtTheBeg)
|
||||
{
|
||||
System.Reflection.PropertyInfo piBeg = oBeg as System.Reflection.PropertyInfo;
|
||||
string name = piBeg.Name;
|
||||
|
||||
double valueAtTheBeg = (double)piBeg.GetValue(dimensionsAtTheBeg, null);
|
||||
if (Math.Abs(valueAtTheBeg) < double.Epsilon)
|
||||
continue;
|
||||
|
||||
double valueAtTheEnd = valueAtTheBeg;
|
||||
|
||||
string unit;
|
||||
if (null == unitSystem)
|
||||
{
|
||||
unit = UnitsAssignment.GetUnitSymbol(name, SectionDimensionsUnits.Assignments);
|
||||
}
|
||||
else
|
||||
{
|
||||
unit = UnitsAssignment.GetUnitSymbol(name, SectionDimensionsUnits.Assignments, (Autodesk.Revit.DB.DisplayUnit)unitSystem);
|
||||
}
|
||||
|
||||
if (dimensionsAtTheEnd != null)
|
||||
{
|
||||
foreach (object oEnd in dimensionsAtTheEnd)
|
||||
{
|
||||
System.Reflection.PropertyInfo piEnd = oEnd as System.Reflection.PropertyInfo;
|
||||
if (name.CompareTo(piEnd.Name) == 0)
|
||||
{
|
||||
valueAtTheEnd = (double)piBeg.GetValue(dimensionsAtTheEnd, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string stringValueAtTheBeg = valueAtTheBeg.ToString();
|
||||
string stringValueAtTheEnd = valueAtTheEnd.ToString();
|
||||
|
||||
if (null == unitSystem)
|
||||
{
|
||||
stringValueAtTheBeg = UnitsAssignment.FormatToRevitUI(name, valueAtTheBeg, SectionDimensionsUnits.Assignments);
|
||||
stringValueAtTheEnd = UnitsAssignment.FormatToRevitUI(name, valueAtTheEnd, SectionDimensionsUnits.Assignments);
|
||||
}
|
||||
|
||||
if (componentNo > 0)
|
||||
{
|
||||
name += componentNo.ToString();
|
||||
}
|
||||
|
||||
SectionParameterDescription secParDescr = new SectionParameterDescription(name, stringValueAtTheBeg, stringValueAtTheEnd, unit);
|
||||
secParDescrList.Add(secParDescr);
|
||||
}
|
||||
|
||||
foreach (object oBeg in characteristicsAtTheBeg)
|
||||
{
|
||||
System.Reflection.PropertyInfo piBeg = oBeg as System.Reflection.PropertyInfo;
|
||||
string name = piBeg.Name;
|
||||
|
||||
double valueAtTheBeg = (double)piBeg.GetValue(characteristicsAtTheBeg, null);
|
||||
if (Math.Abs(valueAtTheBeg) < double.Epsilon)
|
||||
continue;
|
||||
|
||||
double valueAtTheEnd = valueAtTheBeg;
|
||||
|
||||
string unit;
|
||||
if (null == unitSystem)
|
||||
{
|
||||
unit = UnitsAssignment.GetUnitSymbol(name, SectionCharacteristicsUnits.Assignments);
|
||||
}
|
||||
else
|
||||
{
|
||||
unit = UnitsAssignment.GetUnitSymbol(name, SectionCharacteristicsUnits.Assignments, (Autodesk.Revit.DB.DisplayUnit)unitSystem);
|
||||
}
|
||||
|
||||
if (characteristicsAtTheEnd != null)
|
||||
{
|
||||
foreach (object oEnd in characteristicsAtTheEnd)
|
||||
{
|
||||
System.Reflection.PropertyInfo piEnd = oEnd as System.Reflection.PropertyInfo;
|
||||
if (name.CompareTo(piEnd.Name) == 0)
|
||||
{
|
||||
valueAtTheEnd = (double)piBeg.GetValue(characteristicsAtTheEnd, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string stringValueAtTheBeg = valueAtTheBeg.ToString();
|
||||
string stringValueAtTheEnd = valueAtTheEnd.ToString();
|
||||
|
||||
if (null == unitSystem)
|
||||
{
|
||||
stringValueAtTheBeg = UnitsAssignment.FormatToRevitUI(name, valueAtTheBeg, SectionCharacteristicsUnits.Assignments);
|
||||
stringValueAtTheEnd = UnitsAssignment.FormatToRevitUI(name, valueAtTheEnd, SectionCharacteristicsUnits.Assignments);
|
||||
}
|
||||
|
||||
if (componentNo > 0)
|
||||
{
|
||||
name += componentNo.ToString();
|
||||
}
|
||||
|
||||
SectionParameterDescription secParDescr = new SectionParameterDescription(name, stringValueAtTheBeg, stringValueAtTheEnd, unit);
|
||||
secParDescrList.Add(secParDescr);
|
||||
}
|
||||
|
||||
return secParDescrList;
|
||||
}
|
||||
}
|
||||
|
||||
class SectionParameterDescription
|
||||
{
|
||||
public SectionParameterDescription(string name, string valueAtTheBeg, string valueAtTheEnd, string unit)
|
||||
{
|
||||
Name = name;
|
||||
ValueAtTheBeg = valueAtTheBeg;
|
||||
ValueAtTheEnd = valueAtTheEnd;
|
||||
Unit = unit;
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
public string ValueAtTheBeg { get; private set; }
|
||||
public string ValueAtTheEnd { get; private set; }
|
||||
public string Unit { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>AssemblyPath</Assembly>
|
||||
<AddInId>FB51A45D-3EC4-41F8-ADB0-9188FD1CCAB5</AddInId>
|
||||
<FullClassName>SectionPropertiesExplorer.Command</FullClassName>
|
||||
<Text>Section Properties Explorer</Text>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<LanguageType>Unknown</LanguageType>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk,www.Autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F143D61C-115B-4DE9-9A13-FC1FDF4D8BF7}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SectionPropertiesExplorer</RootNamespace>
|
||||
<AssemblyName>SectionPropertiesExplorer</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<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>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</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>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CodeChecking.Engineering">
|
||||
<HintPath>..\..\..\..\..\References\CodeChecking\Engineering\CodeChecking.Engineering.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="RevitAPI">
|
||||
<HintPath>..\..\..\..\..\References\Revit\RevitAPI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="RevitAPIUI">
|
||||
<HintPath>..\..\..\..\..\References\Revit\RevitAPIUI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.cs" />
|
||||
<Compile Include="Geometry.cs" />
|
||||
<Compile Include="SectionDescription.xaml.cs">
|
||||
<DependentUpon>SectionDescription.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SectionParameters.xaml.cs">
|
||||
<DependentUpon>SectionParameters.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tools.cs" />
|
||||
<Compile Include="Units.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="MaterialParameters.xaml.cs">
|
||||
<DependentUpon>MaterialParameters.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SlabDescription.xaml.cs">
|
||||
<DependentUpon>SlabDescription.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WallDescription.xaml.cs">
|
||||
<DependentUpon>WallDescription.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="MaterialParameters.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SectionDescription.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SectionParameters.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SlabDescription.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="WallDescription.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="SectionPropertiesExplorer.addin">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Resource Include="Resources\Images\sectionZsteel.png" />
|
||||
<Resource Include="Resources\Images\sectionC.png" />
|
||||
<Resource Include="Resources\Images\sectionHalfRoundBar.png" />
|
||||
<Resource Include="Resources\Images\sectionI.png" />
|
||||
<Resource Include="Resources\Images\sectionIAsymmetrical.png" />
|
||||
<Resource Include="Resources\Images\sectionIAsymmetricalConcret.png" />
|
||||
<Resource Include="Resources\Images\sectionL.png" />
|
||||
<Resource Include="Resources\Images\sectionPolygonalBar.png" />
|
||||
<Resource Include="Resources\Images\sectionPolygonalHollow.png" />
|
||||
<Resource Include="Resources\Images\sectionQuarterRoundBar.png" />
|
||||
<Resource Include="Resources\Images\sectionRectangularBar.png" />
|
||||
<Resource Include="Resources\Images\sectionRectangularHollowConstant.png" />
|
||||
<Resource Include="Resources\Images\sectionRectangularHollowNotConstant.png" />
|
||||
<Resource Include="Resources\Images\sectionRoundBar.png" />
|
||||
<Resource Include="Resources\Images\sectionRoundTube.png" />
|
||||
<Resource Include="Resources\Images\sectionTAsymmetrical.png" />
|
||||
<Resource Include="Resources\Images\sectionTConcret.png" />
|
||||
<Resource Include="Resources\Images\sectionUnusual.png" />
|
||||
<Resource Include="Resources\Images\sectionT.png" />
|
||||
<Resource Include="Resources\Images\sectionBoxBiSymmetrical.png" />
|
||||
<Resource Include="Resources\Images\sectionBoxMonosymmetrical.png" />
|
||||
<Resource Include="Resources\Images\sectionCrossBiSymmetrical.png" />
|
||||
<Resource Include="Resources\Images\sectionDoubleRectangularBar.png" />
|
||||
<Resource Include="Resources\Images\sectionCompoundSection.png" />
|
||||
<Resource Include="Resources\Images\sectionDoubleSection.png" />
|
||||
<Resource Include="Resources\Images\sectionZ.png" />
|
||||
<Resource Include="Resources\Images\previous_enabled.png" />
|
||||
<Resource Include="Resources\Images\previous_disabled.png" />
|
||||
<Resource Include="Resources\Images\next_enabled.png" />
|
||||
<Resource Include="Resources\Images\next_disabled.png" />
|
||||
<Resource Include="Resources\Images\beam.png" />
|
||||
<Resource Include="Resources\Images\column.png" />
|
||||
<Resource Include="Resources\Images\slab.png" />
|
||||
<Resource Include="Resources\Images\wall.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>if exist ..\..\..\..\..\..\..\Tools\BuildEvents\BuildEvents.exe (
|
||||
..\..\..\..\..\..\..\Tools\BuildEvents\BuildEvents.exe prepare_example $(ProjectDir) $(TargetPath) ..\..\..\..\..\Bin\SDK\CodeChecking\VisualStudio\Examples\$(ProjectName)
|
||||
)</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- 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>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,50 @@
|
||||
<UserControl x:Class="SectionPropertiesExplorer.SlabDescriptionControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="400" d:DesignWidth="690">
|
||||
<DockPanel LastChildFill="True">
|
||||
<DockPanel Name="leftPanel" MinHeight="380" MinWidth="230" Margin="0 10 0 10">
|
||||
<Canvas Name="tSectionViewer" MinHeight="220" MinWidth="250" Margin="0 0 0 5" DockPanel.Dock="Top"></Canvas>
|
||||
<StackPanel Orientation="Vertical" DockPanel.Dock="Top" Margin="0 0 0 0">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Name="familyNameLabel" Content="Family name:" Height="26" Width="80"/>
|
||||
<Label Name="familyName" Content="Unknown" Height="26" Width="150"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Name="typeNameLabel" Content="Type name:" Height="26" Width="80"/>
|
||||
<Label Name="typeName" Content="Unknown" Height="26" Width="150"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Name="levelNameLabel" Content="Level name:" Height="26" Width="80"/>
|
||||
<Label Name="levelName" Content="Unknown" Height="26" Width="150"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical" DockPanel.Dock="Bottom" >
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Canvas Name="pLineSupportSymbolViewer" Height="26" Width="78"></Canvas>
|
||||
<Label Name="pLineSupportSymbolLabel" Content="beam support" Height="26" Width="150"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Canvas Name="pointUpperSupportSymbolViewer" Height="26" Width="26"></Canvas>
|
||||
<Canvas Name="pointSupportSymbolViewer" Height="26" Width="26"></Canvas>
|
||||
<Canvas Name="pointLowerSupportSymbolViewer" Height="26" Width="26"></Canvas>
|
||||
<Label Name="pointSupportSymbolLabel" Content="upper, cross or lower column" Height="26" Width="172"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Canvas Name="wallUpperSupportSymbolViewer" Height="26" Width="26"></Canvas>
|
||||
<Canvas Name="wallSupportSymbolViewer" Height="26" Width="26"></Canvas>
|
||||
<Canvas Name="wallLowerSupportSymbolViewer" Height="26" Width="26"></Canvas>
|
||||
<Label Name="wallSupportSymbolLabel" Content="upper, cross or lower wall" Height="26" Width="150"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
<Canvas Name="slabsViewer" Height="auto" MinHeight="380" MinWidth="435" Margin="10 10 10 10"
|
||||
MouseLeftButtonDown="slabsViewer_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="slabsViewer_MouseLeftButtonUp"
|
||||
MouseMove="slabsViewer_MouseMove">
|
||||
</Canvas>
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,134 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 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.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Controls;
|
||||
|
||||
using Autodesk.Revit.DB.CodeChecking.Engineering;
|
||||
|
||||
namespace SectionPropertiesExplorer
|
||||
{
|
||||
static public class Tools
|
||||
{
|
||||
static public string SectionShapeTypeName(SectionShapeType shapeType)
|
||||
{
|
||||
string secName = "";
|
||||
switch (shapeType)
|
||||
{
|
||||
case SectionShapeType.RectangularHollowNotConstant:
|
||||
secName += "RectangularHollowNotConstant";
|
||||
break;
|
||||
case SectionShapeType.BoxBiSymmetrical:
|
||||
secName += "BoxBiSymmetrical";
|
||||
break;
|
||||
case SectionShapeType.BoxMonoSymmetrical:
|
||||
secName += "BoxMonoSymmetrical";
|
||||
break;
|
||||
case SectionShapeType.C:
|
||||
secName += "C";
|
||||
break;
|
||||
case SectionShapeType.CompoundSection:
|
||||
secName += "CompoundSection";
|
||||
break;
|
||||
case SectionShapeType.CrossBiSymmetrical:
|
||||
secName += "CrossBiSymmetrical";
|
||||
break;
|
||||
case SectionShapeType.DoubleRectangularBar:
|
||||
secName += "DoubleRectangularBar";
|
||||
break;
|
||||
case SectionShapeType.DoubleSection:
|
||||
secName += "DoubleSection";
|
||||
break;
|
||||
case SectionShapeType.I:
|
||||
secName += "I";
|
||||
break;
|
||||
case SectionShapeType.IASymmetrical:
|
||||
secName += "IASymmetrical";
|
||||
break;
|
||||
case SectionShapeType.L:
|
||||
secName += "L";
|
||||
break;
|
||||
case SectionShapeType.PolygonalBar:
|
||||
secName += "PolygonalBar";
|
||||
break;
|
||||
case SectionShapeType.PolygonalHollow:
|
||||
secName += "PolygonalHollow";
|
||||
break;
|
||||
case SectionShapeType.RectangularBar:
|
||||
secName += "RectangularBar";
|
||||
break;
|
||||
case SectionShapeType.RectangularHollowConstant:
|
||||
secName += "RectangularHollowConstant";
|
||||
break;
|
||||
case SectionShapeType.RoundBar:
|
||||
secName += "RoundBar";
|
||||
break;
|
||||
case SectionShapeType.HalfRoundBar:
|
||||
secName += "HalfRoundBar";
|
||||
break;
|
||||
case SectionShapeType.QuarterRoundBar:
|
||||
secName += "QuarterRoundBar";
|
||||
break;
|
||||
case SectionShapeType.T:
|
||||
secName += "T";
|
||||
break;
|
||||
case SectionShapeType.TAsymmetrical:
|
||||
secName += "TAsymmetrical";
|
||||
break;
|
||||
case SectionShapeType.RoundTube:
|
||||
secName += "RoundTube";
|
||||
break;
|
||||
case SectionShapeType.Unusual:
|
||||
secName += "Unusual";
|
||||
break;
|
||||
case SectionShapeType.Z:
|
||||
secName += "Z";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return secName;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExtensionTools
|
||||
{
|
||||
public static void GetViewerWidthAndHeight(this Canvas viewer, out double width, out double height)
|
||||
{
|
||||
width = viewer.MinWidth;
|
||||
if (viewer.Width > viewer.MinWidth)
|
||||
width = viewer.Width;
|
||||
if (viewer.ActualWidth > viewer.MinWidth)
|
||||
width = viewer.ActualWidth;
|
||||
|
||||
height = viewer.MinHeight;
|
||||
if (viewer.Height > viewer.MinHeight)
|
||||
height = viewer.Height;
|
||||
if (viewer.ActualHeight > viewer.MinHeight)
|
||||
height = viewer.ActualHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 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.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace SectionPropertiesExplorer
|
||||
{
|
||||
internal class UnitsTypeAssignment
|
||||
{
|
||||
public UnitsTypeAssignment(UnitSymbolType symbolType, DisplayUnitType displayType)
|
||||
{
|
||||
SymbolType = symbolType;
|
||||
DisplayType = displayType;
|
||||
}
|
||||
|
||||
public UnitSymbolType SymbolType { get; private set; }
|
||||
public DisplayUnitType DisplayType { get; private set; }
|
||||
}
|
||||
|
||||
internal class UnitsAssignment
|
||||
{
|
||||
static UnitsAssignment()
|
||||
{
|
||||
imperialSettings = new Dictionary<UnitType, UnitsTypeAssignment>();
|
||||
imperialSettings.Add(UnitType.UT_Length, new UnitsTypeAssignment(UnitSymbolType.UST_IN_HG, DisplayUnitType.DUT_DECIMAL_INCHES));
|
||||
imperialSettings.Add(UnitType.UT_Section_Property, new UnitsTypeAssignment(UnitSymbolType.UST_IN_HG, DisplayUnitType.DUT_DECIMAL_INCHES));
|
||||
imperialSettings.Add(UnitType.UT_Section_Dimension, new UnitsTypeAssignment(UnitSymbolType.UST_IN_HG, DisplayUnitType.DUT_DECIMAL_INCHES));
|
||||
imperialSettings.Add(UnitType.UT_Section_Area, new UnitsTypeAssignment(UnitSymbolType.UST_IN_SUP_2, DisplayUnitType.DUT_SQUARE_INCHES));
|
||||
imperialSettings.Add(UnitType.UT_Moment_of_Inertia, new UnitsTypeAssignment(UnitSymbolType.UST_IN_SUP_4, DisplayUnitType.DUT_INCHES_TO_THE_FOURTH_POWER));
|
||||
imperialSettings.Add(UnitType.UT_Mass_per_Unit_Length, new UnitsTypeAssignment(UnitSymbolType.UST_LB_MASS_PER_FT, DisplayUnitType.DUT_POUNDS_MASS_PER_FOOT));
|
||||
imperialSettings.Add(UnitType.UT_Stress, new UnitsTypeAssignment(UnitSymbolType.UST_PSF, DisplayUnitType.DUT_POUNDS_FORCE_PER_SQUARE_FOOT));
|
||||
imperialSettings.Add(UnitType.UT_UnitWeight, new UnitsTypeAssignment(UnitSymbolType.UST_LBF_PER_CU_FT, DisplayUnitType.DUT_POUNDS_FORCE_PER_CUBIC_FOOT));
|
||||
imperialSettings.Add(UnitType.UT_Structural_Velocity, new UnitsTypeAssignment(UnitSymbolType.UST_FPS, DisplayUnitType.DUT_FEET_PER_SECOND));
|
||||
|
||||
metricSettings = new Dictionary<UnitType, UnitsTypeAssignment>();
|
||||
metricSettings.Add(UnitType.UT_Length, new UnitsTypeAssignment(UnitSymbolType.UST_M, DisplayUnitType.DUT_METERS));
|
||||
metricSettings.Add(UnitType.UT_Section_Property, new UnitsTypeAssignment(UnitSymbolType.UST_M, DisplayUnitType.DUT_METERS));
|
||||
metricSettings.Add(UnitType.UT_Section_Dimension, new UnitsTypeAssignment(UnitSymbolType.UST_M, DisplayUnitType.DUT_METERS));
|
||||
metricSettings.Add(UnitType.UT_Section_Area, new UnitsTypeAssignment(UnitSymbolType.UST_M_SUP_2, DisplayUnitType.DUT_SQUARE_METERS));
|
||||
metricSettings.Add(UnitType.UT_Moment_of_Inertia, new UnitsTypeAssignment(UnitSymbolType.UST_M_SUP_4, DisplayUnitType.DUT_METERS_TO_THE_FOURTH_POWER));
|
||||
metricSettings.Add(UnitType.UT_Mass_per_Unit_Length, new UnitsTypeAssignment(UnitSymbolType.UST_KGM_PER_M, DisplayUnitType.DUT_KILOGRAMS_MASS_PER_METER));
|
||||
metricSettings.Add(UnitType.UT_Stress, new UnitsTypeAssignment(UnitSymbolType.UST_N_PER_M_SUP_2, DisplayUnitType.DUT_NEWTONS_PER_SQUARE_METER));
|
||||
metricSettings.Add(UnitType.UT_UnitWeight, new UnitsTypeAssignment(UnitSymbolType.UST_KN_PER_M_SUP_3, DisplayUnitType.DUT_KILONEWTONS_PER_CUBIC_METER));
|
||||
metricSettings.Add(UnitType.UT_Structural_Velocity, new UnitsTypeAssignment(UnitSymbolType.UST_M_PER_S, DisplayUnitType.DUT_METERS_PER_SECOND));
|
||||
|
||||
RevitUnits = null;
|
||||
}
|
||||
|
||||
public UnitsAssignment(string valueName, UnitType unitType)
|
||||
{
|
||||
ValueName = valueName;
|
||||
this.unitType = unitType;
|
||||
}
|
||||
|
||||
static public Units RevitUnits { set; private get; }
|
||||
|
||||
static public string GetUnitSymbol(string valueName, UnitsAssignment[] Assignments, Autodesk.Revit.DB.DisplayUnit unitSystem)
|
||||
{
|
||||
foreach (UnitsAssignment ua in Assignments)
|
||||
{
|
||||
if (ua.ValueName.CompareTo(valueName) == 0)
|
||||
{
|
||||
return ua.GetUnitSymbol(unitSystem);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static public string GetUnitSymbol(string valueName, UnitsAssignment[] Assignments)
|
||||
{
|
||||
foreach (UnitsAssignment ua in Assignments)
|
||||
{
|
||||
if (ua.ValueName.CompareTo(valueName) == 0)
|
||||
{
|
||||
FormatOptions fo = RevitUnits.GetFormatOptions(ua.unitType);
|
||||
if (UnitSymbolType.UST_NONE == fo.UnitSymbol)
|
||||
return "";
|
||||
return LabelUtils.GetLabelFor(fo.UnitSymbol);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static public double ConvertToRevitUI(string valueName, double value, UnitsAssignment[] Assignments, DisplayUnit unitSystem)
|
||||
{
|
||||
foreach (UnitsAssignment ua in Assignments)
|
||||
{
|
||||
if (ua.ValueName.CompareTo(valueName) == 0)
|
||||
{
|
||||
UnitsTypeAssignment currentAssignment;
|
||||
switch (unitSystem)
|
||||
{
|
||||
case DisplayUnit.IMPERIAL:
|
||||
if (!imperialSettings.TryGetValue(ua.unitType, out currentAssignment))
|
||||
return value;
|
||||
break;
|
||||
case DisplayUnit.METRIC:
|
||||
if (!metricSettings.TryGetValue(ua.unitType, out currentAssignment))
|
||||
return value;
|
||||
break;
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
value = UnitUtils.Convert(value, currentAssignment.DisplayType, RevitUnits.GetDisplayUnitType());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static public string FormatToRevitUI(string valueName, double value, UnitsAssignment[] Assignments, bool appendUnitSymbol = false)
|
||||
{
|
||||
string formatedValue = value.ToString();
|
||||
|
||||
if (null == RevitUnits)
|
||||
return formatedValue;
|
||||
|
||||
foreach (UnitsAssignment ua in Assignments)
|
||||
{
|
||||
if (ua.ValueName.CompareTo(valueName) == 0)
|
||||
{
|
||||
FormatOptions fo = RevitUnits.GetFormatOptions(ua.unitType);
|
||||
|
||||
FormatValueOptions formatValueOptions = new FormatValueOptions();
|
||||
formatValueOptions.SetFormatOptions(fo);
|
||||
formatValueOptions.AppendUnitSymbol = appendUnitSymbol;
|
||||
|
||||
formatedValue = UnitFormatUtils.FormatValueToString(RevitUnits, ua.unitType, value, false, false, formatValueOptions);
|
||||
|
||||
string unitSymbol = GetUnitSymbol(valueName, Assignments);
|
||||
if(unitSymbol.Length > 0)
|
||||
formatedValue = Regex.Replace(formatedValue, unitSymbol, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return formatedValue;
|
||||
}
|
||||
|
||||
public string ValueName { get; private set; }
|
||||
|
||||
private string GetUnitSymbol(DisplayUnit unitSystem)
|
||||
{
|
||||
UnitsTypeAssignment assignment;
|
||||
switch (unitSystem)
|
||||
{
|
||||
case DisplayUnit.IMPERIAL:
|
||||
if (!imperialSettings.TryGetValue(unitType, out assignment))
|
||||
return "";
|
||||
break;
|
||||
case DisplayUnit.METRIC:
|
||||
if (!metricSettings.TryGetValue(unitType, out assignment))
|
||||
return "";
|
||||
break;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
||||
if (UnitSymbolType.UST_NONE == assignment.SymbolType)
|
||||
return "";
|
||||
return LabelUtils.GetLabelFor(assignment.SymbolType);
|
||||
}
|
||||
|
||||
private UnitType unitType;
|
||||
|
||||
static private Dictionary<UnitType, UnitsTypeAssignment> imperialSettings;
|
||||
static private Dictionary<UnitType, UnitsTypeAssignment> metricSettings;
|
||||
}
|
||||
|
||||
internal class ElementInfoUnits
|
||||
{
|
||||
public static UnitsAssignment[] Assignments = {
|
||||
new UnitsAssignment("GeomLength", UnitType.UT_Length),
|
||||
new UnitsAssignment("LayerThickness", UnitType.UT_Length),
|
||||
new UnitsAssignment("LayerOffset", UnitType.UT_Length),
|
||||
new UnitsAssignment("SlabThickness", UnitType.UT_Length),
|
||||
new UnitsAssignment("SlabDimension", UnitType.UT_Length),
|
||||
new UnitsAssignment("WallThickness", UnitType.UT_Length),
|
||||
new UnitsAssignment("WallDimension", UnitType.UT_Length)
|
||||
};
|
||||
}
|
||||
|
||||
internal class SectionDimensionsUnits
|
||||
{
|
||||
public static UnitsAssignment[] Assignments = {
|
||||
new UnitsAssignment("h", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("hw", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("tw", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("t", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("hw1", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("tw1", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("hw2", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("tw2", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("h1", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("h2", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("b", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("tf", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("bf", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("bf1", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("tf1", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("bf2", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("tf2", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("l1", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("l2", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("s", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("vy", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("vpy", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("vz", UnitType.UT_Section_Dimension),
|
||||
new UnitsAssignment("vpz", UnitType.UT_Section_Dimension)
|
||||
};
|
||||
}
|
||||
|
||||
internal class SectionCharacteristicsUnits
|
||||
{
|
||||
public static UnitsAssignment[] Assignments = {
|
||||
new UnitsAssignment("A", UnitType.UT_Section_Area),
|
||||
new UnitsAssignment("Iy", UnitType.UT_Moment_of_Inertia),
|
||||
new UnitsAssignment("Iz", UnitType.UT_Moment_of_Inertia),
|
||||
new UnitsAssignment("ry", UnitType.UT_Section_Property),
|
||||
new UnitsAssignment("rz", UnitType.UT_Section_Property),
|
||||
new UnitsAssignment("mass", UnitType.UT_Mass_per_Unit_Length)
|
||||
};
|
||||
}
|
||||
|
||||
internal class MaterialCharacteristicsUnits
|
||||
{
|
||||
public static UnitsAssignment[] Assignments = {
|
||||
new UnitsAssignment("YoungModulus", UnitType.UT_Stress),
|
||||
new UnitsAssignment("PoissonRatio", UnitType.UT_Number),
|
||||
new UnitsAssignment("ThermalExpansionCoefficient", UnitType.UT_ThermalExpansion),
|
||||
new UnitsAssignment("UnitWeight", UnitType.UT_UnitWeight),
|
||||
new UnitsAssignment("DampingRatio", UnitType.UT_Number),
|
||||
new UnitsAssignment("ShearModulusG", UnitType.UT_Stress)
|
||||
};
|
||||
}
|
||||
|
||||
internal class MaterialConcreteCharacteristicsUnits
|
||||
{
|
||||
public static UnitsAssignment[] Assignments = {
|
||||
new UnitsAssignment("Compression", UnitType.UT_Stress),
|
||||
new UnitsAssignment("BendingReinforcement", UnitType.UT_Stress),
|
||||
new UnitsAssignment("ShearReinforcement", UnitType.UT_Stress),
|
||||
new UnitsAssignment("ShearStrengthReduction", UnitType.UT_Number)
|
||||
};
|
||||
}
|
||||
|
||||
internal class MaterialMetalCharacteristicsUnits
|
||||
{
|
||||
public static UnitsAssignment[] Assignments = {
|
||||
new UnitsAssignment("MinimumYieldStress", UnitType.UT_Stress),
|
||||
new UnitsAssignment("MinimumTensileStrength", UnitType.UT_Stress),
|
||||
new UnitsAssignment("ReductionShearFactor", UnitType.UT_Number)
|
||||
};
|
||||
}
|
||||
|
||||
internal class MaterialTimberCharacteristicsUnits
|
||||
{
|
||||
public static UnitsAssignment[] Assignments = {
|
||||
new UnitsAssignment("ParallelCompressionStrength", UnitType.UT_Stress),
|
||||
new UnitsAssignment("ParallelShearStrength", UnitType.UT_Stress),
|
||||
new UnitsAssignment("AverageModulusG", UnitType.UT_Stress),
|
||||
new UnitsAssignment("BurningVelocity", UnitType.UT_Structural_Velocity),
|
||||
new UnitsAssignment("BendingStrength", UnitType.UT_Stress),
|
||||
new UnitsAssignment("PerpendicularShearStrength", UnitType.UT_Stress),
|
||||
new UnitsAssignment("PerpendicularCompressionStrength", UnitType.UT_Stress)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<UserControl x:Class="SectionPropertiesExplorer.WallDescriptionControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="400" d:DesignWidth="690">
|
||||
<DockPanel LastChildFill="True">
|
||||
<StackPanel Orientation="Vertical" DockPanel.Dock="Top" Margin="0 10 10 10">
|
||||
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="10 0 0 0">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label Name="familyNameLabel" Content="Family name:" Height="26" Width="80"/>
|
||||
<Label Name="familyName" Content="Unknown" Height="26" Width="250"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="10 0 0 0">
|
||||
<Label Name="typeNameLabel" Content="Type name:" Height="26" Width="80"/>
|
||||
<Label Name="typeName" Content="Unknown" Height="26" Width="250"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Canvas Name="wallViewer" Height="auto" MinHeight="356" MinWidth="670" Margin="10 0 0 0">
|
||||
</Canvas>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,325 @@
|
||||
//
|
||||
// (C) Copyright 2003-2013 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.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
using XYZ = Autodesk.Revit.DB.XYZ;
|
||||
|
||||
using Autodesk.Revit.DB.CodeChecking.Engineering;
|
||||
|
||||
namespace SectionPropertiesExplorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WallDescription.xaml
|
||||
/// </summary>
|
||||
public partial class WallDescriptionControl : UserControl
|
||||
{
|
||||
public WallDescriptionControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void DoBinding(WallInfo wallInfo, Autodesk.Revit.DB.DisplayUnit? unitSystem, double beamLength = 0)
|
||||
{
|
||||
familyNameLabel.Visibility = System.Windows.Visibility.Visible;
|
||||
familyName.Visibility = System.Windows.Visibility.Visible;
|
||||
|
||||
typeNameLabel.Visibility = System.Windows.Visibility.Visible;
|
||||
typeName.Visibility = System.Windows.Visibility.Visible;
|
||||
|
||||
familyName.Content = wallInfo.FamilyName;
|
||||
typeName.Content = wallInfo.TypeName;
|
||||
|
||||
wallViewer.Children.Clear();
|
||||
|
||||
double scale = 1.2;
|
||||
|
||||
double actualWidth = wallViewer.MinWidth;
|
||||
double actualHeight = wallViewer.MinHeight;
|
||||
|
||||
if (wallViewer.ActualWidth > 0)
|
||||
{
|
||||
actualWidth = wallViewer.ActualWidth;
|
||||
}
|
||||
|
||||
if (wallViewer.ActualHeight > 0)
|
||||
{
|
||||
actualHeight = wallViewer.ActualHeight;
|
||||
}
|
||||
|
||||
double horizontalMargin = actualWidth / 8;
|
||||
double verticalMargin = actualHeight / 6;
|
||||
|
||||
double width = actualWidth - 2 * horizontalMargin;
|
||||
double height = actualHeight - 2 * verticalMargin;
|
||||
|
||||
horizontalMargin += (width - width * scale) / 2.0;
|
||||
verticalMargin += (height - height * scale) / 2.0;
|
||||
|
||||
double horizontalShift = horizontalMargin;
|
||||
double verticalShift = verticalMargin;
|
||||
|
||||
XYZ xyz_min = wallInfo.Contour.GetMinimumBoundary();
|
||||
XYZ xyz_max = wallInfo.Contour.GetMaximumBoundary();
|
||||
|
||||
width = Math.Abs(xyz_max.X - xyz_min.X);
|
||||
height = Math.Abs(xyz_max.Y - xyz_min.Y);
|
||||
|
||||
double stretchCoeff = 0;
|
||||
if (height > width)
|
||||
{
|
||||
stretchCoeff = (actualHeight - 2 * verticalMargin) / height;
|
||||
horizontalShift += ((actualWidth - 2 * horizontalMargin) - (width * stretchCoeff)) / 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
stretchCoeff = (actualWidth - 2 * horizontalMargin) / width;
|
||||
verticalShift += ((actualHeight - 2 * verticalMargin) - (height * stretchCoeff)) / 2;
|
||||
}
|
||||
|
||||
if (xyz_min.X < 0)
|
||||
horizontalShift -= stretchCoeff * xyz_min.X;
|
||||
if (xyz_min.Y < 0)
|
||||
verticalShift -= stretchCoeff * xyz_min.Y;
|
||||
|
||||
System.Windows.Shapes.Shape contour = null;
|
||||
List<System.Windows.Shapes.Shape> openings = new List<System.Windows.Shapes.Shape>();
|
||||
|
||||
Polygon polygon = null;
|
||||
PointCollection points = null;
|
||||
|
||||
if (wallInfo.Contour != null && wallInfo.Contour.Points.Count > 2)
|
||||
{
|
||||
polygon = new Polygon();
|
||||
points = new PointCollection();
|
||||
foreach (XYZ xyz in wallInfo.Contour.Points)
|
||||
{
|
||||
points.Add(new Point(xyz.X * stretchCoeff, xyz.Y * stretchCoeff));
|
||||
}
|
||||
polygon.Points = points;
|
||||
polygon.Fill = Brushes.LightSlateGray;
|
||||
polygon.Stretch = Stretch.None;
|
||||
polygon.Stroke = Brushes.Black;
|
||||
polygon.StrokeThickness = 1;
|
||||
|
||||
contour = polygon;
|
||||
}
|
||||
|
||||
foreach (Autodesk.Revit.DB.CodeChecking.Engineering.Shape opening in wallInfo.Openings)
|
||||
{
|
||||
polygon = new Polygon();
|
||||
points = new PointCollection();
|
||||
foreach (XYZ xyz in opening.Points)
|
||||
{
|
||||
points.Add(new Point(xyz.X * stretchCoeff, xyz.Y * stretchCoeff));
|
||||
}
|
||||
polygon.Points = points;
|
||||
polygon.Fill = Brushes.White;
|
||||
polygon.Stretch = Stretch.None;
|
||||
polygon.Stroke = Brushes.Black;
|
||||
polygon.StrokeThickness = 1;
|
||||
|
||||
openings.Add(polygon);
|
||||
}
|
||||
|
||||
if (contour != null)
|
||||
{
|
||||
Canvas.SetLeft(contour, horizontalShift);
|
||||
Canvas.SetTop(contour, verticalShift);
|
||||
wallViewer.Children.Add(contour);
|
||||
}
|
||||
|
||||
foreach (System.Windows.Shapes.Shape opening in openings)
|
||||
{
|
||||
Canvas.SetLeft(opening, horizontalShift);
|
||||
Canvas.SetTop(opening, verticalShift);
|
||||
wallViewer.Children.Add(opening);
|
||||
}
|
||||
|
||||
double viewerWidth, viewerHeight;
|
||||
wallViewer.GetViewerWidthAndHeight(out viewerWidth, out viewerHeight);
|
||||
|
||||
double dimHeight = Math.Abs(xyz_max.Y - xyz_min.Y);
|
||||
double dimWidth = Math.Abs(xyz_max.X - xyz_min.X);
|
||||
|
||||
if(viewerWidth/2.0 > horizontalShift)
|
||||
{
|
||||
horizontalShift += dimWidth * stretchCoeff;
|
||||
}
|
||||
|
||||
double offset = 0.0;
|
||||
if (viewerHeight / 2.0 > verticalShift)
|
||||
{
|
||||
offset = dimHeight * stretchCoeff;
|
||||
}
|
||||
else
|
||||
{
|
||||
verticalShift -= dimHeight * stretchCoeff;
|
||||
}
|
||||
|
||||
double x = horizontalShift + 10;
|
||||
Point start = new Point(x, verticalShift);
|
||||
Point end = new Point(x, start.Y + dimHeight * stretchCoeff);
|
||||
CreateDimensionLine(dimHeight, start, end, stretchCoeff, unitSystem);
|
||||
|
||||
double y = verticalShift + dimHeight * stretchCoeff + 10;
|
||||
start = new Point(horizontalShift - (dimWidth * stretchCoeff), y);
|
||||
end = new Point(start.X + dimWidth * stretchCoeff, y);
|
||||
CreateDimensionLine(dimWidth, start, end, stretchCoeff, unitSystem);
|
||||
}
|
||||
|
||||
private void CreateDimensionLine(double dim,
|
||||
Point start, Point end,
|
||||
double stretchCoeff,
|
||||
Autodesk.Revit.DB.DisplayUnit? unitSystem)
|
||||
{
|
||||
bool horizontal = Math.Abs(end.Y - start.Y) < 1 ? true : false;
|
||||
bool vertical = Math.Abs(end.X - start.X) < 1 ? true : false;
|
||||
|
||||
double dimValueWidth = dim * stretchCoeff;
|
||||
|
||||
string dimValueText = "";
|
||||
|
||||
if (null == unitSystem)
|
||||
{
|
||||
dimValueText += UnitsAssignment.FormatToRevitUI("WallDimension", dim, ElementInfoUnits.Assignments, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
double val = Math.Round(dim, 6, MidpointRounding.AwayFromZero);
|
||||
dimValueText += val.ToString();
|
||||
dimValueText += " " + UnitsAssignment.GetUnitSymbol("WallDimension", ElementInfoUnits.Assignments, (Autodesk.Revit.DB.DisplayUnit)unitSystem);
|
||||
}
|
||||
|
||||
TextBlock dimValue = new TextBlock();
|
||||
dimValue.Text = dimValueText;
|
||||
dimValue.Foreground = new SolidColorBrush(Colors.Gray);
|
||||
dimValue.Width = dimValueWidth;
|
||||
dimValue.TextAlignment = TextAlignment.Center;
|
||||
|
||||
double viewerWidth, viewerHeight;
|
||||
wallViewer.GetViewerWidthAndHeight(out viewerWidth, out viewerHeight);
|
||||
|
||||
double dimValueStartX = start.X;
|
||||
if (horizontal)
|
||||
{
|
||||
double dx = viewerWidth - dimValueStartX - dimValueWidth;
|
||||
if (dx > dimValueStartX)
|
||||
dx = dimValueStartX;
|
||||
dimValueStartX -= dx;
|
||||
if (dx > 0.0)
|
||||
{
|
||||
dimValue.Width += 2 * dx;
|
||||
}
|
||||
|
||||
Canvas.SetTop(dimValue, start.Y);
|
||||
}
|
||||
|
||||
double dimValueStartY = start.Y;
|
||||
if (vertical)
|
||||
{
|
||||
double dy = viewerHeight - dimValueStartY - dimValueWidth;
|
||||
if (dy > dimValueStartY)
|
||||
dy = dimValueStartY;
|
||||
dimValueStartY += dy + dimValueWidth;
|
||||
if (dy > 0.0)
|
||||
{
|
||||
dimValue.Width += 2 * dy;
|
||||
}
|
||||
|
||||
dimValue.RenderTransform = new RotateTransform(-90);
|
||||
|
||||
Canvas.SetTop(dimValue, dimValueStartY);
|
||||
}
|
||||
|
||||
Canvas.SetLeft(dimValue, dimValueStartX);
|
||||
|
||||
wallViewer.Children.Add(dimValue);
|
||||
|
||||
Polyline polyline = new Polyline();
|
||||
|
||||
PointCollection points = new PointCollection();
|
||||
double offset = dimValue.FontSize + 5;
|
||||
|
||||
if (horizontal)
|
||||
{
|
||||
double dlx = end.X > start.X ? 6 : -6;
|
||||
double dx = end.X > start.X ? 0.5 : -0.5;
|
||||
double dy = 1;
|
||||
|
||||
dx *= 2;
|
||||
points.Add(new Point(start.X - dlx, start.Y + offset));
|
||||
points.Add(new Point(start.X, start.Y + offset));
|
||||
points.Add(new Point(start.X + dx, start.Y - dy + offset));
|
||||
points.Add(new Point(start.X - dx, start.Y + dy + offset));
|
||||
points.Add(new Point(start.X, start.Y + offset));
|
||||
|
||||
points.Add(new Point(end.X, end.Y + offset));
|
||||
|
||||
points.Add(new Point(end.X + dx, start.Y - dy + offset));
|
||||
points.Add(new Point(end.X - dx, start.Y + dy + offset));
|
||||
points.Add(new Point(end.X, start.Y + offset));
|
||||
points.Add(new Point(end.X + dlx, start.Y + offset));
|
||||
}
|
||||
|
||||
if (vertical)
|
||||
{
|
||||
double dx = 1;
|
||||
double dy = end.Y > start.Y ? 1 : -1;
|
||||
double dly = end.Y > start.Y ? 6 : -6;
|
||||
|
||||
points.Add(new Point(start.X + offset, start.Y - dly));
|
||||
points.Add(new Point(start.X + offset, start.Y));
|
||||
points.Add(new Point(start.X - dx + offset, start.Y - dy));
|
||||
points.Add(new Point(start.X + dx + offset, start.Y + dy));
|
||||
points.Add(new Point(start.X + offset, start.Y));
|
||||
|
||||
points.Add(new Point(start.X + offset, start.Y));
|
||||
points.Add(new Point(end.X + offset, end.Y));
|
||||
|
||||
points.Add(new Point(end.X - dx + offset, end.Y - dy));
|
||||
points.Add(new Point(end.X + dx + offset, end.Y + dy));
|
||||
points.Add(new Point(end.X + offset, end.Y));
|
||||
points.Add(new Point(end.X + offset, end.Y + dly));
|
||||
}
|
||||
|
||||
polyline.Points = points;
|
||||
polyline.Stretch = Stretch.None;
|
||||
polyline.Stroke = Brushes.Gray;
|
||||
polyline.StrokeThickness = 1;
|
||||
|
||||
wallViewer.Children.Add(polyline);
|
||||
}
|
||||
}
|
||||
}
|
||||