@@ -77,6 +77,18 @@ public void Run(Document doc)
77
77
78
78
try
79
79
{
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
+
80
92
extractedBOM = ProcessAssembly ( ( AssemblyDocument ) doc ) ;
81
93
}
82
94
catch ( Exception e )
@@ -101,6 +113,29 @@ public void Run(Document doc)
101
113
102
114
}
103
115
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
+
104
139
public void RunWithArguments ( Document doc , NameValueMap map )
105
140
{
106
141
LogError ( "RunWithArguments is not functional" ) ;
0 commit comments