integrate Revit 2025 SDK

This commit is contained in:
Jeremy Tammik
2024-04-11 13:47:20 +02:00
parent e786953544
commit f414362f2b
889 changed files with 26676 additions and 26865 deletions
@@ -0,0 +1,88 @@
//
// (C) Copyright 2003-2008 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
namespace Revit.SDK.Samples.ValidateParameters.CS
{
partial class MessageForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.messageRichTextBox = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// messageRichTextBox
//
this.messageRichTextBox.BackColor = System.Drawing.SystemColors.Info;
this.messageRichTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.messageRichTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.messageRichTextBox.ForeColor = System.Drawing.SystemColors.InfoText;
this.messageRichTextBox.Location = new System.Drawing.Point(0, 0);
this.messageRichTextBox.Name = "messageRichTextBox";
this.messageRichTextBox.Size = new System.Drawing.Size(415, 216);
this.messageRichTextBox.TabIndex = 0;
this.messageRichTextBox.Text = "";
//
// MessageForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(415, 216);
this.Controls.Add(this.messageRichTextBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MessageForm";
this.ShowInTaskbar = false;
this.Text = "MessageForm";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.RichTextBox messageRichTextBox;
}
}
@@ -0,0 +1,108 @@
//
// (C) Copyright 2003-2008 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using MacroSamples_RFA;
namespace Revit.SDK.Samples.ValidateParameters.CS
{
/// <summary>
/// The form is used to show the result
/// </summary>
public partial class MessageForm : Form
{
/// <summary>
/// store the log file name
/// </summary>
string m_logFileName = string.Empty;
/// <summary>
/// construction of form
/// </summary>
public MessageForm(ThisApplication thisApp)
{
InitializeComponent();
//create regeneration log file
if (thisApp.ActiveUIDocument.Document.PathName != null)
{
m_logFileName = Path.GetDirectoryName(thisApp.ActiveUIDocument.Document.PathName) + "\\ValidateParametersLog.txt";
}
}
/// <summary>
/// construction method with parameter
/// </summary>
/// <param name="messages">messages</param>
public MessageForm(string[] messages, ThisApplication thisApp)
: this(thisApp)
{
string msgText = "";
//If the size of error messages is 0, means the validate parameters is successful
this.Text = "Validate Parameters Message Form";
StreamWriter writer = File.CreateText(m_logFileName);
writer.Close();
if (messages.Length == 0)
{
msgText = "All types and parameters passed the validation for API";
WriteLog(msgText);
messageRichTextBox.Text = msgText;
}
else
{
foreach (string row in messages)
{
if (row == null) continue;
else
{
WriteLog(row);
msgText += row + "\n";
}
}
}
msgText += "\n\nIf you want to know the validating parameters result, please get the log file at \n"+m_logFileName;
messageRichTextBox.Text = msgText;
this.StartPosition = FormStartPosition.CenterParent;
CheckForIllegalCrossThreadCalls = false;
}
/// <summary>
/// The method is used to write line to log file
/// </summary>
/// <param name="logStr">the log string</param>
private void WriteLog(string logStr)
{
StreamWriter? writer = null;
writer = File.AppendText(m_logFileName);
writer.WriteLine(logStr);
writer.Close();
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,148 @@
//
// (C) Copyright 2003-2008 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.Forms;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using MacroSamples_RFA;
namespace Revit.SDK.Samples.ValidateParameters.CS
{
/// <summary>
/// this class controls the class which subscribes handle events and the events' information UI.
/// like a bridge between them.
/// </summary>
public class ValidateParameters
{
#region Class Memeber Variables
/// <summary>
/// store the family manager
/// </summary>
private FamilyManager? m_familyManager;
private Autodesk.Revit.ApplicationServices.Application? m_revit = null;
private ThisApplication m_thisApp;
#endregion
public ValidateParameters(ThisApplication thisApp)
{
m_thisApp = thisApp;
m_revit = thisApp.ActiveUIDocument.Document.Application;
}
#region Class Interface Implementation
/// <summary>
/// Run
/// </summary>
public void Run()
{
Document document = m_thisApp.ActiveUIDocument.Document;
// only a family document can retrieve family manager
if (document.IsFamilyDocument)
{
m_familyManager = document.FamilyManager;
List<string> errorMessages = Validate(m_familyManager);
using (MessageForm msgForm = new MessageForm(errorMessages.ToArray(), m_thisApp))
{
msgForm.StartPosition = FormStartPosition.CenterParent;
msgForm.ShowDialog();
return;
}
}
else
{
System.Windows.Forms.MessageBox.Show("Current document is not family document.");
return;
}
}
#endregion
#region Class Implementation
/// <summary>
/// implementation of validate parameters, get all family types and parameters,
/// use the function FamilyType.HasValue() to make sure if the parameter needs to
/// validate. Then along to the storage type to validate the parameters.
/// </summary>
/// <returns>error information list</returns>
public static List<string> Validate(FamilyManager familyManager)
{
List<string> errorInfo = new List<string>();
// go though all parameters
foreach (FamilyType type in familyManager.Types)
{
bool right = true;
foreach (FamilyParameter para in familyManager.Parameters)
{
try
{
if (type.HasValue(para))
{
switch (para.StorageType)
{
case StorageType.Double:
if (!(type.AsDouble(para) is double))
right = false;
break;
case StorageType.ElementId:
try
{
ElementId elemId=type.AsElementId(para);
}
catch
{
right = false;
}
break;
case StorageType.Integer:
if (!(type.AsInteger(para) is int))
right = false;
break;
case StorageType.String:
if (!(type.AsString(para) is string))
right = false;
break;
default:
break;
}
}
}
// output the parameters which failed during validating.
catch
{
errorInfo.Add("Family Type:" + type.Name + " Family Parameter:"
+ para.Definition.Name + " validating failed!");
}
if (!right)
{
errorInfo.Add("Family Type:" + type.Name + " Family Parameter:"
+ para.Definition.Name + " validating failed!");
}
}
}
return errorInfo;
}
#endregion
}
}