As announced previously, Revit Addin Wizard (RevitAddinWizard) and its various wizards, coders and widgets have supported Revit API 2012 additionally natively and seamlessly.
In this post, let us have a look at the new look of the Revit Manifest Register Wizard. Its welcome page is the same as before. Other wizard pages have been changed a lot but the backward compatibility is perfectly maintained. The manifest source page looks like the following now:
When the version 2012 is chosen, the Vendor Id edit box will appear in the coming manifest information page:
Other fields are the same as before. The summary page will also reflect the additional settings:
The resultant auto-generated code will reflect the version chosen and the vendor id information as well for the manifest file:
using System;
using System.Collections;
using System.ComponentModel;
using System.Text;
using System.Configuration.Install;
using System.IO;
namespace RevitAddinWizard
{
[RunInstaller(true)]
public class RevitManifestRegister1 : Installer
{
#region Constants and Fields
const string Assembly_Path_Parameber = "ASSEMBLYPATH";
const string All_Users_Parameter = "ALLUSERS";
const string Manifest_Version = "2012";
const string Folder_Format = "%{0}%\\Autodesk\\Revit\\Addins\\{1}";
const string Folder_Format_XP = "%{0}%\\Application Data\\Autodesk\\Revit\\Addins\\{1}";
const string Current_User_Profile = "AppData";
const string All_Users_Profile = "ALLUSERSPROFILE";
string fileName, filePath, roamingFolder, assemblyName, assemblyPath, className, clientId, appName;
string vendorId;
#endregion
#region Constructor
public RevitManifestRegister1()
{
fileName = @"RevitAddinCS1.Addin";
assemblyName = @"RevitAddinCS1.dll";
className = @"RevitAddinCS1.ExtApp";
clientId = @"beab5b60-488d-4787-a9e2-62c00f7216c1";
appName = @"ExtApp";
vendorId = @"ABC";
}
#endregion
#region Overrides
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
try
{
if (Context.Parameters.ContainsKey(Assembly_Path_Parameber) &&
!string.IsNullOrEmpty(Context.Parameters[Assembly_Path_Parameber]))
{
assemblyPath = Path.Combine(Path.GetDirectoryName(Context.Parameters[Assembly_Path_Parameber]), assemblyName);
}
//
// Please add /ALLUSERS=[ALLUSERS] to the CustomActionData of the Custom Actions if the manifest file is going to be deployed
// to different locations based on the user choise of the installation dialog if applicable and necessary.
// Otherwise the current user roaming folder will be used.
//
if (Context.Parameters.ContainsKey(All_Users_Parameter) &&
!string.IsNullOrEmpty(Context.Parameters[All_Users_Parameter]) &&
Context.Parameters[All_Users_Parameter] == "1")
{
if (IsXP())
{
roamingFolder = Environment.ExpandEnvironmentVariables(string.Format(Folder_Format_XP, All_Users_Profile, Manifest_Version));
}
else if (IsVistaOrWin7())
{
roamingFolder = Environment.ExpandEnvironmentVariables(string.Format(Folder_Format, All_Users_Profile, Manifest_Version));
}
}
else
{
roamingFolder = Environment.ExpandEnvironmentVariables(string.Format(Folder_Format, Current_User_Profile, Manifest_Version));
}
DirectoryInfo dirInfo = new DirectoryInfo(roamingFolder);
if (!dirInfo.Exists)
{
dirInfo.Create();
}
filePath = Path.Combine(roamingFolder, fileName);
CreateManifestFile(filePath, assemblyPath, className, clientId, appName, vendorId);
stateSaver.Add("RawAddinPath", filePath);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
}
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
try
{
filePath = (string)savedState["RawAddinPath"];
if (File.Exists(filePath))
{
File.Delete(filePath);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
try
{
filePath = (string)savedState["RawAddinPath"];
if (File.Exists(filePath))
{
File.Delete(filePath);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
#endregion
#region Methods
bool IsXP()
{
OperatingSystem OS = Environment.OSVersion;
return OS.Platform == PlatformID.Win32NT && (OS.Version.Major == 5 && OS.Version.Minor >= 1);
}
bool IsVistaOrWin7()
{
OperatingSystem OS = Environment.OSVersion;
return OS.Platform == PlatformID.Win32NT && (OS.Version.Major == 6 && OS.Version.Minor <= 1);
}
void CreateManifestFile(string filename, string assembly, string classname, string id, string appname, string vendorId)
{
using (StreamWriter writer = new StreamWriter(filename, false, Encoding.UTF8))
{
writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
writer.WriteLine("<RevitAddIns>");
writer.WriteLine(string.Format("\t<AddIn Type=\"Application\">"));
writer.WriteLine(string.Format("\t\t<Assembly>{0}</Assembly>", assembly));
writer.WriteLine(string.Format("\t\t<FullClassName>{0}</FullClassName>", classname));
writer.WriteLine(string.Format("\t\t<ClientId>{0}</ClientId>", id));
writer.WriteLine(string.Format("\t\t<Name>{0}</Name>", appname));
writer.WriteLine(string.Format("\t\t<VendorId>{0}</VendorId>", vendorId));
writer.WriteLine(string.Format("\t</AddIn>"));
writer.WriteLine("</RevitAddIns>");
}
}
#endregion
}
}
Revit Addin Wizard (RevitAddinWizard) and its various wizards, coders and widgets have supported Revit API 2012 additionally natively and seamlessly.
Happy New Year!
Recent Comments