Skip to content

Commit 6f05ade

Browse files
committed
Added 2018 Support
1 parent 5c41cff commit 6f05ade

7 files changed

Lines changed: 117 additions & 17 deletions

File tree

74 Bytes
Binary file not shown.

SketchUp/SketchUpNET/SketchUpForDynamo/Material.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,56 +33,100 @@ public string GetTextureFileName()
3333
return Internal.MaterialTexture.Name;
3434
}
3535

36+
/// <summary>
37+
/// Get Textrue Height
38+
/// </summary>
39+
/// <returns></returns>
3640
public int GetTextureHeight()
3741
{
3842
return Internal.MaterialTexture.Height;
3943
}
4044

45+
/// <summary>
46+
/// Get Texture Width
47+
/// </summary>
48+
/// <returns></returns>
4149
public int GetTextureWidth()
4250
{
4351
return Internal.MaterialTexture.Width;
4452
}
4553

54+
/// <summary>
55+
/// Get Texture Scale in Height
56+
/// </summary>
57+
/// <returns></returns>
4658
public double GetTextureScaleH()
4759
{
4860
return Internal.MaterialTexture.ScaleH;
4961
}
5062

63+
/// <summary>
64+
/// Get Textute Scale in Width
65+
/// </summary>
66+
/// <returns></returns>
5167
public double GetTextureScaleW()
5268
{
5369
return Internal.MaterialTexture.ScaleW;
5470
}
5571

72+
/// <summary>
73+
/// Does the material texture use alpha?
74+
/// </summary>
75+
/// <returns></returns>
5676
public bool GetTextureUsesAlpha()
5777
{
5878
return Internal.MaterialTexture.useAlpha;
5979
}
6080

81+
/// <summary>
82+
/// Get Colour
83+
/// </summary>
84+
/// <returns></returns>
6185
public DSCore.Color GetColour()
6286
{
6387
return Internal.Colour.ToDSColour();
6488
}
6589

90+
/// <summary>
91+
/// Get Texture Colour
92+
/// </summary>
93+
/// <returns></returns>
6694
public DSCore.Color GetTextureColour()
6795
{
6896
return Internal.MaterialTexture.Colour.ToDSColour();
6997
}
7098

99+
/// <summary>
100+
/// Get Opacity
101+
/// </summary>
102+
/// <returns></returns>
71103
public double GetOpacity()
72104
{
73105
return Internal.Opacity;
74106
}
75107

108+
/// <summary>
109+
/// Does the material use opacity?
110+
/// </summary>
111+
/// <returns></returns>
76112
public bool GetUseOpacity()
77113
{
78114
return Internal.UseOpacity;
79115
}
80116

117+
/// <summary>
118+
/// Does the material use colour?
119+
/// </summary>
120+
/// <returns></returns>
81121
public bool GetUsesColor()
82122
{
83123
return Internal.UsesColor;
84124
}
85125

126+
/// <summary>
127+
/// Does the material use texture?
128+
/// </summary>
129+
/// <returns></returns>
86130
public bool GetUsesTexture()
87131
{
88132
return Internal.UsesTexture;

SketchUp/SketchUpNET/SketchUpForDynamo/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.5.0.0")]
36-
[assembly: AssemblyFileVersion("1.5.0.0")]
35+
[assembly: AssemblyVersion("1.5.2.0")]
36+
[assembly: AssemblyFileVersion("1.5.2.0")]

SketchUp/SketchUpNET/SketchUpForDynamo/SketchUp.cs

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,37 @@ namespace SketchUpForDynamo
3232

3333
public static class SketchUp
3434
{
35-
public static int T(int a, int b) { return a + b; }
3635
/// <summary>
37-
/// Load SketchUp Model
36+
/// Reformats an existing SketchUp Model to another Version
37+
/// </summary>
38+
/// <param name="filepath">Original Model</param>
39+
/// <param name="version">Target Version like 2015 or 2018</param>
40+
/// <param name="newfilepath">Target Model Path</param>
41+
/// <returns></returns>
42+
public static bool ReformatModel(string filepath, string version, string newfilepath)
43+
{
44+
SketchUpNET.SketchUp skp = new SketchUpNET.SketchUp();
45+
SKPVersion v = SKPVersion.V2013;
46+
switch (version)
47+
{
48+
case "2014": v = SKPVersion.V2014; break;
49+
case "2015": v = SKPVersion.V2015; break;
50+
case "2016": v = SKPVersion.V2016; break;
51+
case "2017": v = SKPVersion.V2017; break;
52+
case "2018": v = SKPVersion.V2018; break;
53+
}
54+
return skp.SaveAs(filepath, v, newfilepath);
55+
}
56+
57+
/// <summary>
58+
/// Load SketchUp Model by Path.
59+
/// This node will load all SketchUp content into Dynamo.
60+
/// By default it will include meshes.
61+
/// Turn meshes off if you are experiencing performance issues.
3862
/// </summary>
3963
/// <param name="path">Path to SketchUp file</param>
40-
[MultiReturn(new[] { "Surfaces", "Layers", "Instances", "Curves", "Edges", "Meshes", "Groups" })]
64+
/// <param name="includeMeshes">Include Meshes (might be faster to turn it off)</param>
65+
[MultiReturn(new[] { "Surfaces", "Layers", "Instances", "Curves", "Edges", "Meshes", "Groups", "Materials" })]
4166
public static Dictionary<string, object> LoadModel(string path, bool includeMeshes = true)
4267
{
4368
List<Autodesk.DesignScript.Geometry.Surface> surfaces = new List<Autodesk.DesignScript.Geometry.Surface>();
@@ -47,6 +72,7 @@ public static Dictionary<string, object> LoadModel(string path, bool includeMesh
4772
List<List<Autodesk.DesignScript.Geometry.Line>> curves = new List<List<Autodesk.DesignScript.Geometry.Line>>();
4873
List<Autodesk.DesignScript.Geometry.Line> edges = new List<Autodesk.DesignScript.Geometry.Line>();
4974
List<Group> grp = new List<Group>();
75+
List<Material> mats = new List<Material>();
5076

5177
SketchUpNET.SketchUp skp = new SketchUpNET.SketchUp();
5278
if (skp.LoadModel(path, includeMeshes))
@@ -74,6 +100,9 @@ public static Dictionary<string, object> LoadModel(string path, bool includeMesh
74100
foreach (Group gr in skp.Groups)
75101
grp.Add(gr);
76102

103+
foreach (var mat in skp.Materials)
104+
mats.Add(new Material(mat.Value));
105+
77106
}
78107

79108
return new Dictionary<string, object>
@@ -84,19 +113,30 @@ public static Dictionary<string, object> LoadModel(string path, bool includeMesh
84113
{ "Curves", curves },
85114
{ "Edges", edges },
86115
{ "Meshes", meshes},
87-
{ "Groups", grp }
116+
{ "Groups", grp },
117+
{ "Materials", mats }
88118
};
89119
}
90120

91-
92-
[MultiReturn(new[] { "Surfaces", "Instances", "Edges", "Meshes", "Groups" })]
121+
/// <summary>
122+
/// Load SketchUp Model by Path and Layername.
123+
/// This node loads only contents of the specified layer into Dynamo.
124+
/// By default it will include meshes.
125+
/// Turn meshes off if you are experiencing performance issues.
126+
/// </summary>
127+
/// <param name="path"></param>
128+
/// <param name="layername"></param>
129+
/// <param name="includeMeshes"></param>
130+
/// <returns></returns>
131+
[MultiReturn(new[] { "Surfaces", "Instances", "Edges", "Meshes", "Groups", "Materials" })]
93132
public static Dictionary<string, object> LoadModelByLayer(string path, string layername, bool includeMeshes = true)
94133
{
95134
List<Autodesk.DesignScript.Geometry.Surface> surfaces = new List<Autodesk.DesignScript.Geometry.Surface>();
96135
List<Autodesk.DesignScript.Geometry.Mesh> meshes = new List<Autodesk.DesignScript.Geometry.Mesh>();
97136
List<Instance> Instances = new List<Instance>();
98137
List<Autodesk.DesignScript.Geometry.Line> edges = new List<Autodesk.DesignScript.Geometry.Line>();
99138
List<Group> grp = new List<Group>();
139+
List<Material> mats = new List<Material>();
100140

101141
SketchUpNET.SketchUp skp = new SketchUpNET.SketchUp();
102142
if (skp.LoadModel(path, includeMeshes))
@@ -118,6 +158,9 @@ public static Dictionary<string, object> LoadModelByLayer(string path, string la
118158
foreach (Group gr in skp.Groups.Where(s => s.Layer == layername))
119159
grp.Add(gr);
120160

161+
foreach (var mat in skp.Materials)
162+
mats.Add(new Material(mat.Value));
163+
121164
}
122165

123166
return new Dictionary<string, object>
@@ -126,14 +169,16 @@ public static Dictionary<string, object> LoadModelByLayer(string path, string la
126169
{ "Instances", Instances },
127170
{ "Edges", edges },
128171
{ "Meshes", meshes},
129-
{ "Groups", grp }
172+
{ "Groups", grp },
173+
{ "Materials", mats }
130174
};
131175
}
132176

133177

134178

135179
/// <summary>
136-
/// SketchUp Component Instance Data
180+
/// SketchUp Component Instance Data.
181+
/// This node extracts all components from an instance.
137182
/// </summary>
138183
/// <param name="instance">SketchUp Component Instance</param>
139184
[MultiReturn(new[] { "Surfaces","Curves","Instances","Meshes","Edges", "Position", "Scale", "Name", "Parent Name", "Groups", "MaterialsFront", "MaterialsBack" })]
@@ -187,7 +232,8 @@ public static Dictionary<string, object> GetInstance(Instance instance)
187232
}
188233

189234
/// <summary>
190-
/// SketchUp Component Instance Data
235+
/// SketchUp Group Data.
236+
/// This node extracts all contents from a group.
191237
/// </summary>
192238
/// <param name="group">SketchUp Component Instance</param>
193239
[MultiReturn(new[] { "Surfaces", "Curves", "Instances", "Meshes", "Edges", "Name", "Groups" })]
@@ -226,7 +272,8 @@ public static Dictionary<string, object> GetGroup(Group group)
226272

227273

228274
/// <summary>
229-
/// Flatten Instances
275+
/// Flatten Instances.
276+
/// This node returns a list of all geometries from a list of instances.
230277
/// </summary>
231278
/// <param name="instances"></param>
232279
/// <returns>All Geometries</returns>
@@ -261,9 +308,12 @@ private static void FlattenInstance(Instance instance, ref List<Autodesk.DesignS
261308
}
262309

263310
/// <summary>
264-
/// Write SketchUp Model
311+
/// Write SketchUp Model.
312+
/// This node writes surfaces and cures into a SketchUp model.
265313
/// </summary>
266314
/// <param name="path">Path to SketchUp file</param>
315+
/// <param name="surfaces">Surface Geometries</param>
316+
/// <param name="curves">Curve Geometries</param>
267317
public static void WriteModel(string path, List<Autodesk.DesignScript.Geometry.Surface> surfaces = null, List<Autodesk.DesignScript.Geometry.Curve> curves = null)
268318
{
269319
SketchUpNET.SketchUp skp = new SketchUpNET.SketchUp();

SketchUp/SketchUpNET/SketchUpNET/Material.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ namespace SketchUpNET
8282
this->MaterialTexture = gcnew Texture();
8383
};
8484

85-
85+
virtual String^ ToString() override
86+
{
87+
return this->Name;
88+
}
89+
8690
internal:
8791

8892

SketchUp/SketchUpNET/SketchUpNET/SketchUpNET.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ namespace SketchUpNET
5353
V2014,
5454
V2015,
5555
V2016,
56-
V2017
56+
V2017,
57+
V2018
5758
};
5859

5960
/// <summary>
@@ -138,7 +139,6 @@ namespace SketchUpNET
138139
Groups = gcnew System::Collections::Generic::List<Group^>();
139140
Components = gcnew System::Collections::Generic::Dictionary<String^,Component^>();
140141
Materials = gcnew System::Collections::Generic::Dictionary<String^, Material^>();
141-
Materials->Add("", gcnew Material());
142142

143143
SUEntitiesRef entities = SU_INVALID;
144144
SUModelGetEntities(model, &entities);
@@ -245,7 +245,7 @@ namespace SketchUpNET
245245
if (res != SU_ERROR_NONE)
246246
return false;
247247

248-
SUModelVersion saveversion = SUModelVersion::SUModelVersion_SU2017;
248+
SUModelVersion saveversion = SUModelVersion::SUModelVersion_SU2018;
249249

250250
if (version == SKPVersion::V2013)
251251
saveversion = SUModelVersion::SUModelVersion_SU2013;
@@ -257,6 +257,8 @@ namespace SketchUpNET
257257
saveversion = SUModelVersion::SUModelVersion_SU2016;
258258
else if (version == SKPVersion::V2017)
259259
saveversion = SUModelVersion::SUModelVersion_SU2017;
260+
else if (version == SKPVersion::V2018)
261+
saveversion = SUModelVersion::SUModelVersion_SU2018;
260262

261263
SUModelSaveToFileWithVersion(model, Utilities::ToString(newFilename), saveversion);
262264

-70 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)