Skip to content

Commit 09be809

Browse files
[1.4.1] Improved med file detection
1 parent 6841290 commit 09be809

9 files changed

Lines changed: 65 additions & 33 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,5 @@ yarn.lock
6969
vs-code-aster-*.vsix
7070
.vscode-test
7171
out/
72+
73+
.claude/

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.vscode/**
22
.vscode-test/**
33
.github/**
4+
.claude/**
45
out/**
56
node_modules/**
67
src/**

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to the **VS Code Aster** extension will be documented in thi
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.4.1] - 2026-03-03
9+
10+
Improved med file detection.
11+
12+
### Fixed
13+
- Med files that do not have a .*med extension are now properly detected as med files for the med viewer.
14+
815
## [1.4.0] - 2026-02-04
916

1017
Added support for more comm file extensions

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cff-version: 1.4.0
1+
cff-version: 1.4.1
22
title: VS Code Aster
33
message: >-
44
If you use this software, please cite it using the

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<p align="center"><img src="https://raw.githubusercontent.com/simvia-tech/vs-code-aster/main/resources/images/simvia.png" alt="Simvia Logo" width="50%" /></p>
22

33
<p align="center">
4-
<a href="/"><img src="https://img.shields.io/badge/version-1.4.0-blue" alt="Version" /></a>
4+
<a href="/"><img src="https://img.shields.io/badge/version-1.4.1-blue" alt="Version" /></a>
55
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-GPL%203.0-green" alt="License" /></a>
66
</p>
77

ROADMAP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
The extension aims to reduce friction between modeling, validation, execution, and analysis by bringing **code_aster** native workflows into the editor.
66

7-
## Current Capabilities (v1.4.0)
7+
## Current Capabilities (v1.4.1)
88

99
- `.export` file generator
1010
- 3D mesh viewer

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vs-code-aster",
33
"displayName": "VS Code Aster",
4-
"version": "1.4.0",
4+
"version": "1.4.1",
55
"description": "VS Code extension for code_aster",
66
"publisher": "simvia",
77
"license": "GPL-3.0",

src/VisuManager.ts

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,11 @@ export async function readObjFilesContent(
187187
}
188188

189189
/**
190-
* Finds the .*med files corresponding to a given .comm file by reading .export files in the same folder.
190+
* Finds med files corresponding to a given .comm file by reading .export files in the same folder.
191+
* Looks for F lines whose type field ends with "med" (e.g. mmed, rmed) and ioFlag is "D".
192+
* The med file may have any extension (e.g. .med, .21, .17).
191193
* @param commFilePath Path to the .comm file
192-
* @returns Paths to the .*med files if found, [] otherwise
194+
* @returns Paths to the med files if found, [] otherwise
193195
*/
194196
export function findMedFiles(commFilePath: string): string[] {
195197
try {
@@ -218,34 +220,36 @@ export function findMedFiles(commFilePath: string): string[] {
218220

219221
const lines = content.split(/\r?\n/);
220222
for (const line of lines) {
221-
if (!/\bD\b/.test(line)) {
223+
const cleanLine = line.split("#")[0].trim();
224+
const tokens = cleanLine.split(/\s+/);
225+
226+
if (tokens.length !== 5 || tokens[0] !== "F") {
222227
continue;
223228
}
224229

225-
const match = line.match(/([\w\-./\\]+\.[a-z]?med)\b/i);
226-
if (match) {
227-
const medFileName = path.basename(match[1]);
228-
const medPath = path.join(dir, medFileName);
229-
230-
if (fs.existsSync(medPath)) {
231-
console.log(`[findMedFiles] found med file: ${medFileName}`);
232-
foundMedFiles.push(medPath);
233-
} else {
234-
vscode.window.showErrorMessage(
235-
`The file "${medFileName}" mentioned in "${exportFile}" does not exist in the current directory (${path.basename(
236-
dir,
237-
)}/).`,
238-
);
239-
}
230+
const [, type, name, ioFlag] = tokens;
231+
232+
if (!type.endsWith("med") || ioFlag !== "D") {
233+
continue;
234+
}
235+
236+
const medFileName = path.basename(name);
237+
const medPath = path.join(dir, medFileName);
238+
239+
if (fs.existsSync(medPath)) {
240+
console.log(`[findMedFiles] found med file: ${medFileName}`);
241+
foundMedFiles.push(medPath);
242+
} else {
243+
vscode.window.showErrorMessage(
244+
`The file "${medFileName}" mentioned in "${exportFile}" does not exist in the current directory (${path.basename(dir)}/).`,
245+
);
240246
}
241247
}
242248
}
243249

244250
if (foundMedFiles.length === 0) {
245251
vscode.window.showErrorMessage(
246-
`No .export file in "${path.basename(
247-
dir,
248-
)}/" references any entry .med file associated with ${commFileName}.`,
252+
`No .export file in "${path.basename(dir)}/" references any input med file associated with ${commFileName}.`,
249253
);
250254
}
251255

@@ -350,18 +354,36 @@ async function generateObjFromMed(
350354
);
351355

352356
let stderr = "";
357+
let settled = false;
353358

354359
process.stderr.on("data", (data) => {
355360
stderr += data.toString();
356361
console.log(`[generateObjFromMed] stderr: ${data}`);
357362
});
358363

359-
process.on("error", (err) => {
364+
process.on("error", (err: NodeJS.ErrnoException) => {
365+
if (settled) {
366+
return;
367+
}
368+
settled = true;
360369
console.error(`[generateObjFromMed] Process error: ${err.message}`);
361-
reject(new Error(`Failed to generate .obj file: ${err.message}`));
370+
if (err.code === "ENOENT") {
371+
reject(
372+
new Error(
373+
`Python executable not found: "${pythonExecutablePath}". ` +
374+
`Please update the "vs-code-aster.pythonExecutablePath" setting.`,
375+
),
376+
);
377+
} else {
378+
reject(new Error(`Failed to generate .obj file: ${err.message}`));
379+
}
362380
});
363381

364382
process.on("close", (code) => {
383+
if (settled) {
384+
return;
385+
}
386+
settled = true;
365387
if (code === 0) {
366388
console.log(
367389
`[generateObjFromMed] Successfully generated: ${objFilePath}`,

0 commit comments

Comments
 (0)