-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathRevitIniReader.cs
More file actions
64 lines (54 loc) · 2.19 KB
/
RevitIniReader.cs
File metadata and controls
64 lines (54 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Text;
using Revit_glTF_Exporter;
using System.IO;
using System.Linq;
using Autodesk.Revit.ApplicationServices;
namespace Common_glTF_Exporter.Utils
{
public static class RevitIniReader
{
public static List<string> GetAdditionalRenderAppearancePaths()
{
string revitVersion = ExternalApplication.RevitCollectorService.GetApplication().VersionNumber;
string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string iniDir = Path.Combine(
appData,
"Autodesk",
"Revit",
$"Autodesk Revit {revitVersion}"
);
string iniPath = Path.Combine(iniDir, "Revit.ini");
if (!File.Exists(iniPath))
return null;
foreach (var line in File.ReadAllLines(iniPath))
{
if (line.StartsWith("AdditionalRenderAppearancePaths="))
{
string pathString = line.Substring("AdditionalRenderAppearancePaths=".Length);
var paths = pathString.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
var absolutePaths = new List<string>();
string userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
foreach (var p in paths)
{
string trimmedPath = p.Trim();
// If already rooted, normalize it
if (Path.IsPathRooted(trimmedPath))
{
absolutePaths.Add(Path.GetFullPath(trimmedPath));
}
else
{
// Combine with user profile to resolve relative path
string fullPath = Path.GetFullPath(Path.Combine(userProfile, trimmedPath));
absolutePaths.Add(fullPath);
}
}
return absolutePaths;
}
}
return null;
}
}
}