Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit 6692476

Browse files
authored
INVGEN-45246 activate project before BOM extraction (#316)
* activate project before BOM extraction * increased assembly version
1 parent efbfe8a commit 6692476

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

AppBundles/ExportBOMPlugin/ExportBOMAutomation.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ public void Run(Document doc)
7777

7878
try
7979
{
80+
// TODO: remove this project activation when new inventorcoreconsole.exe
81+
// will be available on PROD environment
82+
var fullFileName = doc.FullFileName;
83+
// close the orignal doc
84+
doc.Close(true);
85+
// activate default project
86+
var dir = System.IO.Directory.GetCurrentDirectory();
87+
ActivateProject(dir);
88+
// open doc with project activated
89+
doc = inventorApplication.Documents.Open(fullFileName);
90+
// ^
91+
8092
extractedBOM = ProcessAssembly((AssemblyDocument)doc);
8193
}
8294
catch (Exception e)
@@ -101,6 +113,29 @@ public void Run(Document doc)
101113

102114
}
103115

116+
private void ActivateProject(string dir)
117+
{
118+
var defaultProjectName = "FDADefault";
119+
120+
var projectFullFileName = System.IO.Path.Combine(dir, defaultProjectName + ".ipj");
121+
122+
DesignProject project = null;
123+
if (System.IO.File.Exists(projectFullFileName))
124+
{
125+
project = inventorApplication.DesignProjectManager.DesignProjects.AddExisting(projectFullFileName);
126+
Trace.TraceInformation("Adding existing default project file: {0}", projectFullFileName);
127+
128+
}
129+
else
130+
{
131+
project = inventorApplication.DesignProjectManager.DesignProjects.Add(MultiUserModeEnum.kSingleUserMode, defaultProjectName, dir);
132+
Trace.TraceInformation("Creating default project file with name: {0} at {1}", defaultProjectName, dir);
133+
}
134+
135+
Trace.TraceInformation("Activating default project {0}", project.FullFileName);
136+
project.Activate(true);
137+
}
138+
104139
public void RunWithArguments(Document doc, NameValueMap map)
105140
{
106141
LogError("RunWithArguments is not functional");

AppBundles/ExportBOMPlugin/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
[assembly: Guid("f1c9d7e2-53a8-4e4e-af9e-931ca891715d")]
88

9-
[assembly: AssemblyVersion("1.0.0.3")]
10-
[assembly: AssemblyFileVersion("1.0.0.3")]
9+
[assembly: AssemblyVersion("1.0.0.4")]
10+
[assembly: AssemblyFileVersion("1.0.0.4")]

0 commit comments

Comments
 (0)