Skip to content

Commit

Permalink
Merge branch 'gh-pages' of https://github.com/va3c/RvtVa3c into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Tammik committed Feb 16, 2015
2 parents be8cf10 + d7fd1a4 commit 9918f52
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 10 deletions.
93 changes: 93 additions & 0 deletions DynVa3c/DynVa3c.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1127D4DE-31BB-4D7E-B663-759ACE7B8230}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DynVa3c</RootNamespace>
<AssemblyName>DynVa3c</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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>
</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>
</PropertyGroup>
<ItemGroup>
<Reference Include="DSCoreNodes">
<HintPath>..\..\..\..\..\..\Program Files\Dynamo 0.7\DSCoreNodes.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="DynamoCore">
<HintPath>..\..\..\..\..\..\Program Files\Dynamo 0.7\DynamoCore.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ProtoCore">
<HintPath>..\..\..\..\..\..\Program Files\Dynamo 0.7\ProtoCore.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ProtoGeometry">
<HintPath>..\..\..\..\..\..\Program Files\Dynamo 0.7\ProtoGeometry.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ProtoInterface">
<HintPath>..\..\..\..\..\..\Program Files\Dynamo 0.7\ProtoInterface.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RevitAPI">
<HintPath>..\..\..\..\..\..\Program Files\Autodesk\Revit 2015\RevitAPI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RevitAPIUI">
<HintPath>..\..\..\..\..\..\Program Files\Autodesk\Revit 2015\RevitAPIUI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RevitNodes">
<HintPath>..\..\..\..\..\..\Program Files\Dynamo 0.7\Revit_2015\RevitNodes.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RevitServices">
<HintPath>..\..\..\..\..\..\Program Files\Dynamo 0.7\Revit_2015\RevitServices.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RvtVa3c">
<HintPath>..\RvtVa3c\bin\Debug\RvtVa3c.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Va3c4Dynamo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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>
36 changes: 36 additions & 0 deletions DynVa3c/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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("DynVa3c")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Thornton Tomasetti, Inc.")]
[assembly: AssemblyProduct("DynVa3c")]
[assembly: AssemblyCopyright("Copyright © Thornton Tomasetti, Inc. 2015")]
[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("0973e4fd-9e9f-47b6-879b-261e78528669")]

// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
91 changes: 91 additions & 0 deletions DynVa3c/Va3c4Dynamo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//Revit & Dynamo
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Analysis;
using Autodesk.Revit.UI;
using DSCore;
using Dynamo.Models;
using Dynamo.Nodes;
using Dynamo.Utilities;
using ProtoCore.AST.AssociativeAST;
using RevitServices.Persistence;
using RevitServices.Transactions;
using ProtoCore;
using ProtoCore.Utils;
using Autodesk.DesignScript.Runtime;
using Revit.GeometryConversion;
using RvtVa3c;
using System.IO;

namespace DynVa3c
{
public class Va3c4Dynamo
{
// [IsVisibleInDynamoLibrary(false)]
// public static System.Reflection.Assembly
//CurrentDomain_AssemblyResolve(
// object sender,
// ResolveEventArgs args)
// {
// if (args.Name.Contains("Newtonsoft"))
// {
// string filename = Path.GetDirectoryName(
// System.Reflection.Assembly
// .GetExecutingAssembly().Location);

// filename = Path.Combine(filename,
// "Newtonsoft.Json.dll");

// if (System.IO.File.Exists(filename))
// {
// return System.Reflection.Assembly
// .LoadFrom(filename);
// }
// }
// return null;
// }

public static void Exportva3C(string filename)
{
// 1. Get active document 3d view
//local variables
Document RvtDoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument.Document;

// 2. Call ExportView3D from RvtVac3
//RvtVa3c.Command.ExportView3D(RvtDoc.ActiveView as View3D, filename);

//AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

RvtVa3c.Va3cExportContext context = new Va3cExportContext(RvtDoc, filename);

CustomExporter exporter = new CustomExporter(RvtDoc, context);

exporter.IncludeFaces = false;

exporter.ShouldStopOnError = false;


try
{
exporter.Export(RvtDoc.ActiveView as View3D);
}
catch (Exception) // Autodesk.Revit.Exceptions.ExternalApplicationException
{

//throw;
}

string test = context.myjs;
System.IO.File.WriteAllText(filename, test);
// 3. Return Report
//return test;

}

}
}
10 changes: 9 additions & 1 deletion RvtVa3c.sln
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 2013
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RvtVa3c", "RvtVa3c\RvtVa3c.csproj", "{3F865D22-8849-4DFA-9E7C-3533A8A159EA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynVa3c", "DynVa3c\DynVa3c.csproj", "{1127D4DE-31BB-4D7E-B663-759ACE7B8230}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -13,6 +17,10 @@ Global
{3F865D22-8849-4DFA-9E7C-3533A8A159EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F865D22-8849-4DFA-9E7C-3533A8A159EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F865D22-8849-4DFA-9E7C-3533A8A159EA}.Release|Any CPU.Build.0 = Release|Any CPU
{1127D4DE-31BB-4D7E-B663-759ACE7B8230}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1127D4DE-31BB-4D7E-B663-759ACE7B8230}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1127D4DE-31BB-4D7E-B663-759ACE7B8230}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1127D4DE-31BB-4D7E-B663-759ACE7B8230}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion RvtVa3c/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class Command : IExternalCommand
/// Export a given 3D view to JSON using
/// our custom exporter context.
/// </summary>
void ExportView3D( View3D view3d, string filename )
public void ExportView3D( View3D view3d, string filename )
{
AppDomain.CurrentDomain.AssemblyResolve
+= CurrentDomain_AssemblyResolve;
Expand Down
27 changes: 19 additions & 8 deletions RvtVa3c/Va3cExportContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace RvtVa3c
// Check for file size
// Instance/type reuse

class Va3cExportContext : IExportContext
public class Va3cExportContext : IExportContext
{
/// <summary>
/// Scale entire top level BIM object nove in JSON
Expand All @@ -34,7 +34,7 @@ class Va3cExportContext : IExportContext
/// so that a typical model has a chance of fitting
/// into a cube with side length 100, i.e. 10 metres.
/// </summary>
double _scale_bim = 0.01;
double _scale_bim = 1.0;

/// <summary>
/// Scale applied to each vertex in each individual
Expand Down Expand Up @@ -250,6 +250,8 @@ public int AddVertex( PointInt p )

string _currentMaterialUid;

public string myjs = null;

Va3cContainer.Va3cObject CurrentObjectPerMaterial
{
get
Expand Down Expand Up @@ -282,6 +284,10 @@ Transform CurrentTransform
}
}

public override string ToString()
{
return myjs;
}
/// <summary>
/// Set the current material
/// </summary>
Expand All @@ -307,7 +313,7 @@ Va3cContainer.Va3cMaterial m
m.ambient = m.color;
m.emissive = 0;
m.specular = m.color;
m.shininess = material.Shininess; // todo: does this need scaling to e.g. [0,100]?
m.shininess = 1; // todo: does this need scaling to e.g. [0,100]?
m.opacity = 0.01 * (double) ( 100 - material.Transparency ); // Revit has material.Transparency in [0,100], three.js expects opacity in [0.0,1.0]
m.transparent = 0 < material.Transparency;
m.wireframe = false;
Expand Down Expand Up @@ -379,7 +385,7 @@ public bool Start()
_container.obj = new Va3cContainer.Va3cObject();
_container.obj.uuid = _doc.ActiveView.UniqueId;
_container.obj.name = "BIM " + _doc.Title;
_container.obj.type = "Object3D";
_container.obj.type = "Scene";

// Scale entire BIM from millimetres to metres.

Expand All @@ -392,7 +398,7 @@ public bool Start()
return true;
}

public void Finish()
public void Finish()
{
// Finish populating scene

Expand Down Expand Up @@ -424,9 +430,11 @@ Formatting formatting
? Formatting.Indented
: Formatting.None;

File.WriteAllText( _filename,
JsonConvert.SerializeObject(
_container, formatting, settings ) );
myjs = JsonConvert.SerializeObject(
_container, formatting, settings );


File.WriteAllText( _filename, myjs);

#if USE_DYNAMIC_JSON
// This saves the whole hassle of explicitly
Expand Down Expand Up @@ -759,6 +767,9 @@ Dictionary<string, string> d

_currentElement.userData = d;

//also add guid to user data dict
_currentElement.userData.Add("revit_id", uid);

_objects.Add( _currentElement.uuid, _currentElement );

_elementStack.Pop();
Expand Down

0 comments on commit 9918f52

Please sign in to comment.