added Revit 2022 SDK minus except *rvt and *rfa

This commit is contained in:
Jeremy Tammik
2021-04-20 11:36:21 +02:00
parent 1133a82dc5
commit 7e327986e8
3034 changed files with 1245318 additions and 0 deletions
@@ -0,0 +1,177 @@
//
// (C) Copyright 2003-2019 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using System.Drawing.Design;
namespace Revit.SDK.Samples.NewHostedSweep.CS
{
/// <summary>
/// This class contains the data for hosted sweep creation.
/// </summary>
public class CreationData
{
/// <summary>
/// Represents the method that will handle the EdgeAdded or EdgeRemoved events
/// of CreationData
/// </summary>
/// <param name="edge">Edge</param>
public delegate void EdgeEventHandler(Edge edge);
/// <summary>
/// Represents the method that will handle the SymbolChanged events
/// of CreationData
/// </summary>
/// <param name="sym">Symbol</param>
public delegate void SymbolChangedEventHandler(ElementType sym);
/// <summary>
/// Edge is added to HostedSweep.
/// </summary>
public event EdgeEventHandler EdgeAdded;
/// <summary>
/// Edge is removed from HostedSweep.
/// </summary>
public event EdgeEventHandler EdgeRemoved;
/// <summary>
/// HostedSweep symbol is changed.
/// </summary>
public event SymbolChangedEventHandler SymbolChanged;
/// <summary>
/// Creator contains the necessary data to fetch the edges and get the symbol.
/// </summary>
private HostedSweepCreator m_creator;
/// <summary>
/// Symbol for HostedSweep creation.
/// </summary>
private ElementType m_symbol;
/// <summary>
/// Edges which contains references for HostedSweep creation.
/// </summary>
private List<Edge> m_edgesForHostedSweep = new List<Edge>();
/// <summary>
/// Back up of Symbol.
/// </summary>
private ElementType m_backUpSymbol;
/// <summary>
/// Back up of Edges.
/// </summary>
private List<Edge> m_backUpEdges = new List<Edge>();
/// <summary>
/// Constructor.
/// </summary>
/// <param name="creator">HostedSweepCreator</param>
public CreationData(HostedSweepCreator creator)
{
m_creator = creator;
}
/// <summary>
/// Back up the Symbol and Edges.
/// </summary>
public void BackUp()
{
m_backUpSymbol = m_symbol;
m_backUpEdges.Clear();
m_backUpEdges.AddRange(m_edgesForHostedSweep);
}
/// <summary>
/// Restore the Symbol and Edges.
/// </summary>
public void Restore()
{
m_symbol = m_backUpSymbol;
m_edgesForHostedSweep.Clear();
m_edgesForHostedSweep.AddRange(m_backUpEdges);
}
/// <summary>
/// If CreationData changed, notify its observers.
/// </summary>
public void Update()
{
if (SymbolChanged != null && m_backUpSymbol != null &&
m_backUpSymbol.Id.IntegerValue != m_symbol.Id.IntegerValue)
SymbolChanged(m_symbol);
if (EdgeRemoved != null)
{
foreach (Edge edge in m_backUpEdges)
{
if (m_edgesForHostedSweep.IndexOf(edge) == -1)
{
EdgeRemoved(edge);
}
}
}
if(EdgeAdded != null)
{
foreach (Edge edge in m_edgesForHostedSweep)
{
if (m_backUpEdges.IndexOf(edge) == -1)
{
EdgeAdded(edge);
}
}
}
}
/// <summary>
/// Creator contains the necessary data to fetch the edges and get the symbol.
/// </summary>
public HostedSweepCreator Creator
{
get { return m_creator; }
}
/// <summary>
/// Symbol for HostedSweep creation.
/// </summary>
public ElementType Symbol
{
get { return m_symbol; }
set { m_symbol = value; }
}
/// <summary>
/// Edges which contains references for HostedSweep creation.
/// </summary>
public List<Edge> EdgesForHostedSweep
{
get { return m_edgesForHostedSweep; }
}
}
}
@@ -0,0 +1,404 @@
//
// (C) Copyright 2003-2019 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit;
using Autodesk.Revit.DB.Architecture;
using System.Drawing.Design;
using System.ComponentModel;
namespace Revit.SDK.Samples.NewHostedSweep.CS
{
/// <summary>
/// This class contains the data for hosted sweep modification.
/// </summary>
public class ModificationData
{
/// <summary>
/// Element to modify.
/// </summary>
private HostedSweep m_elemToModify;
/// <summary>
/// Creation data can be modified.
/// </summary>
private CreationData m_creationData;
/// <summary>
/// Revit active document.
/// </summary>
private Document m_rvtDoc;
/// <summary>
/// Revit UI document.
/// </summary>
private UIDocument m_rvtUIDoc;
/// <summary>
/// Sub transaction
/// </summary>
Transaction m_transaction;
/// <summary>
/// Constructor with HostedSweep and CreationData as parameters.
/// </summary>
/// <param name="elem">Element to modify</param>
/// <param name="creationData">CreationData</param>
public ModificationData(HostedSweep elem, CreationData creationData)
{
m_rvtDoc = creationData.Creator.RvtDocument;
m_rvtUIDoc = creationData.Creator.RvtUIDocument;
m_elemToModify = elem;
m_creationData = creationData;
m_transaction = new Transaction(m_rvtDoc, "External Tool");
m_creationData.EdgeAdded +=
new CreationData.EdgeEventHandler(m_creationData_EdgeAdded);
m_creationData.EdgeRemoved +=
new CreationData.EdgeEventHandler(m_creationData_EdgeRemoved);
m_creationData.SymbolChanged +=
new CreationData.SymbolChangedEventHandler(m_creationData_SymbolChanged);
}
/// <summary>
/// Name of the Creator.
/// </summary>
public string CreatorName
{
get
{
return m_creationData.Creator.Name;
}
}
/// <summary>
/// Change the symbol of the HostedSweep.
/// </summary>
/// <param name="sym"></param>
private void m_creationData_SymbolChanged(ElementType sym)
{
try
{
StartTransaction();
m_elemToModify.ChangeTypeId(sym.Id);
CommitTransaction();
}
catch
{
RollbackTransaction();
}
}
/// <summary>
/// Remove the edge from the HostedSweep.
/// </summary>
/// <param name="edge"></param>
private void m_creationData_EdgeRemoved(Edge edge)
{
try
{
StartTransaction();
m_elemToModify.RemoveSegment(edge.Reference);
CommitTransaction();
}
catch
{
RollbackTransaction();
}
}
/// <summary>
/// Add the edge to the HostedSweep.
/// </summary>
/// <param name="edge"></param>
private void m_creationData_EdgeAdded(Edge edge)
{
try
{
StartTransaction();
if (m_elemToModify is Fascia)
{
(m_elemToModify as Fascia).AddSegment(edge.Reference);
}
else if (m_elemToModify is Gutter)
{
(m_elemToModify as Gutter).AddSegment(edge.Reference);
}
else if (m_elemToModify is SlabEdge)
{
(m_elemToModify as SlabEdge).AddSegment(edge.Reference);
}
CommitTransaction();
}
catch
{
RollbackTransaction();
}
}
/// <summary>
/// Show the element in a good view.
/// </summary>
public void ShowElement()
{
try
{
StartTransaction();
m_rvtUIDoc.ShowElements(m_elemToModify);
CommitTransaction();
}
catch
{
RollbackTransaction();
}
}
/// <summary>
/// Name will be displayed in property grid.
/// </summary>
[Category("Identity Data")]
public String Name
{
get
{
String result = "[Id:" + m_elemToModify.Id.IntegerValue + "] ";
return result + m_elemToModify.Name;
}
}
/// <summary>
/// HostedSweep Angle property.
/// </summary>
[Category("Profile")]
public String Angle
{
get
{
Parameter angle = GetParameter("Angle");
if (angle != null)
return angle.AsValueString();
else
return m_elemToModify.Angle.ToString();
}
set
{
try
{
StartTransaction();
Parameter angle = GetParameter("Angle");
if (angle != null)
angle.SetValueString(value);
else
m_elemToModify.Angle = double.Parse(value);
CommitTransaction();
}
catch
{
RollbackTransaction();
}
}
}
/// <summary>
/// HostedSweep profiles edges, the edges can be removed or added in the
/// pop up dialog.
/// </summary>
[TypeConverter(typeof(CreationDataTypeConverter)),
Editor(typeof(EdgeFormUITypeEditor), typeof(UITypeEditor)),
Category("Profile"), DisplayName("Profile Edges")]
public CreationData AddOrRemoveSegments
{
get
{
return m_creationData;
}
}
/// <summary>
/// HostedSweep Length property.
/// </summary>
[Category("Dimensions")]
public string Length
{
get
{
Parameter length = GetParameter("Length");
if (length != null)
return length.AsValueString();
else
return m_elemToModify.Length.ToString();
}
}
/// <summary>
/// HostedSweep HorizontalFlipped property.
/// </summary>
[Category("Constraints"), DisplayName("Horizontal Profile Flipped")]
public bool HorizontalFlipped
{
get { return m_elemToModify.HorizontalFlipped; }
set
{
if (value != m_elemToModify.HorizontalFlipped)
{
try
{
StartTransaction();
m_elemToModify.HorizontalFlip();
CommitTransaction();
}
catch
{
RollbackTransaction();
}
}
}
}
/// <summary>
/// HostedSweep HorizontalOffset property.
/// </summary>
[Category("Constraints"), DisplayName("Horizontal Profile Offset")]
public String HorizontalOffset
{
get
{
Parameter horiOff = GetParameter("Horizontal Profile Offset");
if (horiOff != null)
return horiOff.AsValueString();
else
return m_elemToModify.HorizontalOffset.ToString();
}
set
{
try
{
StartTransaction();
Parameter horiOff = GetParameter("Horizontal Profile Offset");
if (horiOff != null)
horiOff.SetValueString(value);
else
m_elemToModify.HorizontalOffset = double.Parse(value);
CommitTransaction();
}
catch
{
RollbackTransaction();
}
}
}
/// <summary>
/// HostedSweep VerticalFlipped property.
/// </summary>
[Category("Constraints"), DisplayName("Vertical Profile Flipped")]
public bool VerticalFlipped
{
get
{
return m_elemToModify.VerticalFlipped;
}
set
{
if (value != m_elemToModify.VerticalFlipped)
{
try
{
StartTransaction();
m_elemToModify.VerticalFlip();
CommitTransaction();
}
catch
{
RollbackTransaction();
}
}
}
}
/// <summary>
/// HostedSweep VerticalOffset property.
/// </summary>
[Category("Constraints"), DisplayName("Vertical Profile Offset")]
public String VerticalOffset
{
get
{
Parameter vertOff = GetParameter("Vertical Profile Offset");
if (vertOff != null)
return vertOff.AsValueString();
else
return m_elemToModify.VerticalOffset.ToString();
}
set
{
try
{
StartTransaction();
Parameter vertOff = GetParameter("Vertical Profile Offset");
if (vertOff != null)
vertOff.SetValueString(value);
else
m_elemToModify.VerticalOffset = double.Parse(value);
CommitTransaction();
}
catch
{
RollbackTransaction();
}
}
}
/// <summary>
/// Get parameter by given name.
/// </summary>
/// <param name="name">name of parameter</param>
/// <returns>parameter whose definition name is the given name.</returns>
protected Parameter GetParameter(String name)
{
return m_elemToModify.LookupParameter(name);
}
public TransactionStatus StartTransaction()
{
return m_transaction.Start();
}
public TransactionStatus CommitTransaction()
{
return m_transaction.Commit();
}
public TransactionStatus RollbackTransaction()
{
return m_transaction.RollBack();
}
}
}