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,80 @@
<Window x:Class="Revit.SDK.Samples.CloudAPISample.CS.View.ViewInputMigrationInfo"
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"
ResizeMode="NoResize"
d:DesignHeight="600" d:DesignWidth="800"
Height="480" Width="360">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="90" />
</Grid.ColumnDefinitions>
<StackPanel Margin="10" Grid.Row="0">
<Label Content="Target Account" />
<TextBox Width="Auto"
Text="{Binding Path=DataContext.Model.AccountGuid, RelativeSource={RelativeSource AncestorType={x:Type Window }}}" />
<Label Content="Target Project" />
<TextBox
Text="{Binding Path=DataContext.Model.ProjectGuid, RelativeSource={RelativeSource AncestorType={x:Type Window }}}" />
</StackPanel>
<ListView Margin="10" Name="lvFolders" Grid.Column="0" Grid.Row="1"
ItemsSource="{Binding Path=DataContext.Model.AvailableFolders, RelativeSource={RelativeSource AncestorType={x:Type Window }}}">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Name}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Urn" Width="130">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Urn}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<StackPanel Margin="0,10,0,10" Grid.Column="1" Grid.Row="1">
<StackPanel.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Margin" Value="5" />
</Style>
</StackPanel.Resources>
<Button Click="OnBtnAddFolder_Click">Add a folder</Button>
<Button Click="OnBtnRemoveFolder_Click">Remove</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Margin" Value="5" />
<Setter Property="Height" Value="20" />
<Setter Property="Width" Value="70" />
</Style>
</Grid.Resources>
<Button Click="OnBtnImport_Click" Grid.Column="1">Import</Button>
<Button Click="OnBtnExport_Click" Grid.Column="2">Export</Button>
</Grid>
</Grid>
</Window>
@@ -0,0 +1,105 @@
//
// (C) Copyright 2003-2020 by Autodesk, Inc. All rights reserved.
//
// 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 ITS 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.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
using System.Windows;
using Microsoft.Win32;
using Revit.SDK.Samples.CloudAPISample.CS.Migration;
namespace Revit.SDK.Samples.CloudAPISample.CS.View
{
/// <summary>
/// Interaction logic for ViewInputMigrationInfo.xaml
/// </summary>
public partial class ViewInputMigrationInfo : Window
{
/// <summary>
/// Constructor for ViewSamplePortal
/// ViewSamplePortal is a child window aggregating all sample case with tabs
/// </summary>
public ViewInputMigrationInfo(MigrationToBim360 sampleContext)
{
DataContext = sampleContext;
InitializeComponent();
}
private void OnBtnAddFolder_Click(object sender, RoutedEventArgs e)
{
((MigrationToBim360) DataContext).Model.AvailableFolders.Add(new FolderLocation());
}
private void OnBtnRemoveFolder_Click(object sender, RoutedEventArgs e)
{
var model = ((MigrationToBim360) DataContext).Model;
if (lvFolders.SelectedIndex >= 0 && lvFolders.SelectedIndex < model.AvailableFolders.Count)
model.AvailableFolders.RemoveAt(lvFolders.SelectedIndex);
}
private void OnBtnImport_Click(object sender, RoutedEventArgs e)
{
var openFileDialog = new OpenFileDialog {Filter = "Json file (*.json)|*.json|All files (*.*)|*.*"};
if (openFileDialog.ShowDialog() == true)
{
var model = ((MigrationToBim360) DataContext).Model;
var jsonString = File.ReadAllText(openFileDialog.FileName);
JavaScriptSerializer serializer = new JavaScriptSerializer();
var info = serializer.Deserialize<SerializableProjectInfo>(jsonString);
model.AccountGuid = info.AccountGuid;
model.ProjectGuid = info.ProjectGuid;
model.AvailableFolders.Clear();
foreach (var folder in info.AvailableFolders) model.AvailableFolders.Add(folder);
}
}
private void OnBtnExport_Click(object sender, RoutedEventArgs e)
{
var saveFileDialog = new SaveFileDialog {Filter = "Json file (*.json)|*.json"};
if (saveFileDialog.ShowDialog() == true)
{
var model = ((MigrationToBim360) DataContext).Model;
var info = new SerializableProjectInfo
{
AccountGuid = model.AccountGuid,
ProjectGuid = model.ProjectGuid,
AvailableFolders = model.AvailableFolders.ToArray()
};
JavaScriptSerializer serializer = new JavaScriptSerializer();
var jsonString = serializer.Serialize(info);
File.WriteAllText(saveFileDialog.FileName, jsonString);
}
}
[DataContract]
internal class SerializableProjectInfo
{
[DataMember] public string AccountGuid { get; set; }
[DataMember] public string ProjectGuid { get; set; }
[DataMember] public FolderLocation[] AvailableFolders { get; set; }
}
}
}
@@ -0,0 +1,115 @@
<UserControl x:Class="Revit.SDK.Samples.CloudAPISample.CS.View.ViewMigrationToBim360"
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="450" d:DesignWidth="800">
<Grid Background="#FFE5E5E5">
<Grid.Resources>
<Style TargetType="{x:Type Control}" x:Key="Space">
<Setter Property="Margin" Value="5" />
<Setter Property="Background" Value="Transparent" />
</Style>
<Style TargetType="Button">
<Setter Property="Margin" Value="0,5,0,5" />
</Style>
<Style TargetType="TextBox">
<Setter Property="Height" Value="24" />
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Margin="10" Grid.Column="0">
<Label Content="Step 1. Download" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Label Content="Models" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Name="tbLocalFolder" />
<Button Width="20" Grid.Column="1" Click="OnBtnBrowseDirectory_Click">...</Button>
</Grid>
<Button Click="OnBtnReveal_Click">Reveal in explorer</Button>
<TextBlock Margin="10" TextWrapping="Wrap">
1. Manually download cloud models from anywhere, such as BIM 360 Team via eTransmit package.<LineBreak /><LineBreak />
2. Click “...” to select a folder location.
</TextBlock>
</StackPanel>
<StackPanel Margin="10" Grid.Column="1">
<Label Content="Step 2. Config" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Button Click="OnBtnConfig_Click">Configuration</Button>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="Rules" />
<Button Width="20" Grid.Column="2" Click="OnBtnRemoveRule_Click">-</Button>
<Button Width="20" Grid.Column="3" Click="OnBtnAddRule_Click">+</Button>
</Grid>
<ListView MinHeight="120" Name="lvRules"
ItemsSource="{Binding Path=DataContext.Model.Rules, RelativeSource={RelativeSource AncestorType={x:Type UserControl }}}">
<ListView.View>
<GridView>
<GridViewColumn Header="Pattern" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Pattern}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Target Folder" Width="130">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox
ItemsSource="{Binding Path=DataContext.Model.AvailableFolders,
RelativeSource={RelativeSource AncestorType={x:Type UserControl }}}"
DisplayMemberPath="Name"
SelectedValue="{Binding Target}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<TextBlock Margin="10" TextWrapping="Wrap">
1. Click “Configuration” to input target cloud information.<LineBreak /><LineBreak />
2. Click “+” to add rules to the target folder for models with a specific pattern. The first rule is assigned the highest priority.
<LineBreak /><LineBreak />
3. A model with no matching pattern will be uploaded to the folder specified by the last rule in the list.
</TextBlock>
</StackPanel>
<Grid Margin="10" Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<Label Content="Step 3. Upload" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Button Click="OnBtnUpload_Click">Upload</Button>
<Label Content="Progress" Name="lbUploadStatus" />
<ProgressBar Height="20" Name="pbUploading" />
<TextBlock Margin="10" TextWrapping="Wrap">
1. Ensure you are logged in to your Autodesk Account.<LineBreak /><LineBreak />
2. Click “Upload” to upload models to the target cloud folder.
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="1">
<Label Content="Step 4. Reload" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Button Click="OnBtnRefresh_Click">Refresh</Button>
<Label Content="Progress" Name="lbReloadStatus" />
<ProgressBar Height="20" Name="pbReloading" />
<TextBlock Margin="10" TextWrapping="Wrap">
1. Click “Refresh” to direct links to the correct model in the cloud.
</TextBlock>
</StackPanel>
</Grid>
</Grid>
</UserControl>
@@ -0,0 +1,142 @@
//
// (C) Copyright 2003-2020 by Autodesk, Inc. All rights reserved.
//
// 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 ITS 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.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Forms;
using Revit.SDK.Samples.CloudAPISample.CS.Coroutine;
using Revit.SDK.Samples.CloudAPISample.CS.Migration;
using MessageBox = System.Windows.MessageBox;
using UserControl = System.Windows.Controls.UserControl;
namespace Revit.SDK.Samples.CloudAPISample.CS.View
{
/// <summary>
/// Interaction logic for ViewMigrationToBim360.xaml
/// </summary>
public partial class ViewMigrationToBim360 : UserControl
{
/// <summary>
/// The view for <see cref="MigrationToBim360" />
/// </summary>
public ViewMigrationToBim360(MigrationToBim360 sampleContext)
{
DataContext = sampleContext;
InitializeComponent();
}
/// <summary>
/// Update progress for uploading process.
/// </summary>
/// <param name="status">Text prompt to indicate the process</param>
/// <param name="progress">The percentage progress, from 0 to 100</param>
public void UpdateUploadingProgress(string status, int progress)
{
lbUploadStatus.Content = status;
pbUploading.Value = progress;
}
/// <summary>
/// Update progress for reloading process
/// </summary>
/// <param name="status">Text prompt to indicate the process</param>
/// <param name="progress">The percentage progress, from 0 to 100</param>
public void UpdateReloadingProgress(string status, int progress)
{
lbReloadStatus.Content = status;
pbReloading.Value = progress;
}
private void OnBtnBrowseDirectory_Click(object sender, RoutedEventArgs e)
{
using (var fbd = new FolderBrowserDialog())
{
var result = fbd.ShowDialog();
if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
tbLocalFolder.Text = fbd.SelectedPath;
}
}
private void OnBtnReveal_Click(object sender, RoutedEventArgs e)
{
if (!Directory.Exists(tbLocalFolder.Text))
MessageBox.Show("Invalid folder path");
else
Process.Start(tbLocalFolder.Text);
}
private void OnBtnConfig_Click(object sender, RoutedEventArgs e)
{
var ctx = (MigrationToBim360) DataContext;
var viewConfiguration = new ViewInputMigrationInfo(ctx);
viewConfiguration.Show();
}
private void OnBtnRemoveRule_Click(object sender, RoutedEventArgs e)
{
var model = ((MigrationToBim360) DataContext).Model;
if (lvRules.SelectedIndex >= 0 && lvRules.SelectedIndex < model.Rules.Count)
model.Rules.RemoveAt(lvRules.SelectedIndex);
}
private void OnBtnAddRule_Click(object sender, RoutedEventArgs e)
{
var model = ((MigrationToBim360) DataContext).Model;
model.Rules.Add(new MigrationRule());
}
private void OnBtnUpload_Click(object sender, RoutedEventArgs e)
{
if (DataContext is MigrationToBim360 sampleContext)
{
if (sampleContext.Model.Rules.Count <= 0)
{
MessageBox.Show("Please add at least 1 migration rule.");
return;
}
// Upload local models to target project
var localDir = tbLocalFolder.Text;
var sAccountId = sampleContext.Model.AccountGuid;
var sProjectId = sampleContext.Model.ProjectGuid;
if (Guid.TryParse(sAccountId, out var accountId) && Guid.TryParse(sProjectId, out var projectId))
CoroutineScheduler.StartCoroutine(sampleContext.Upload(localDir, accountId, projectId,
sampleContext.Model.Rules));
}
}
private void OnBtnRefresh_Click(object sender, RoutedEventArgs e)
{
if (DataContext is MigrationToBim360 sampleContext)
{
var localDir = tbLocalFolder.Text;
var sProjectId = sampleContext.Model.ProjectGuid;
if (Guid.TryParse(sProjectId, out var projectId))
CoroutineScheduler.StartCoroutine(sampleContext.ReloadLinks(localDir, projectId));
}
}
}
}
@@ -0,0 +1,16 @@
<Window x:Class="Revit.SDK.Samples.CloudAPISample.CS.View.ViewSamplePortal"
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"
ResizeMode="NoResize"
d:DesignHeight="600" d:DesignWidth="800"
Height="600" Width="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TabControl Name="ContentTabs" />
</Grid>
</Window>
@@ -0,0 +1,55 @@
//
// (C) Copyright 2003-2020 by Autodesk, Inc. All rights reserved.
//
// 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 ITS 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.Windows;
using System.Windows.Controls;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.CloudAPISample.CS.View
{
/// <summary>
/// Interaction logic for ViewSamplePortal.xaml
/// </summary>
public partial class ViewSamplePortal : Window
{
/// <summary>
/// Constructor for ViewSamplePortal
/// ViewSamplePortal is a child window aggregating all sample case with tabs
/// </summary>
public ViewSamplePortal(UIApplication app)
{
InitializeComponent();
}
/// <summary>
/// Add a sample tab
/// </summary>
/// <param name="title">The sample title</param>
/// <param name="control">The root control for this sample</param>
public void AddTab(string title, UserControl control)
{
var item = new TabItem {Header = title};
ContentTabs.Items.Add(item);
item.Content = control;
}
}
}