Recognize commercial parts with alphabetic names in .asm scanning
Pro-E numeric codes cover most components, but parts downloaded as STEP from online catalogs (rings, bushings, knobs...) get alphabetic Creo names with no predictable shape. Add a second extraction path that tokenizes the binary generically and validates candidates against the known codes in cad_index.db, applying the same placement/occurrence rule used for bare numeric codes. Numeric extraction is unchanged, so missing-from-index reporting for renamed/moved Pro-E codes still works. Also load all known prt/asm codes once per scan instead of one query per candidate, in both RisolviAlberoComponenti and VerificaCompletezzaAssiemi. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c75dd21551
commit
8a8a7d0417
7 files changed
+363
-106
No files matched your search
@@ -92,7 +92,7 @@ public class AssemblyComponentScannerTests
|
||||
"Componente ID 1 (R12--_-_U6592<UNI6592>.PRT) x Componente ID 2 (R12--_-_U6592<UNI6592>.PRT)");
|
||||
try
|
||||
{
|
||||
var codici = AssemblyComponentScanner.EstraiCodiciReferenziati(percorso);
|
||||
var codici = AssemblyComponentScanner.EstraiCodiciReferenziati(percorso, codiciNoti: new[] { "UNI6592" });
|
||||
Assert.Contains("UNI6592", codici);
|
||||
Assert.DoesNotContain("R12--_-_U6592<UNI6592>", codici);
|
||||
}
|
||||
@@ -103,4 +103,49 @@ public class AssemblyComponentScannerTests
|
||||
public void File_inesistente_lancia_eccezione_IO() =>
|
||||
Assert.Throws<DirectoryNotFoundException>(() =>
|
||||
AssemblyComponentScanner.EstraiCodiciReferenziati(@"C:\non\esiste\pippo.asm.1"));
|
||||
|
||||
[Fact]
|
||||
public void Riconosce_parte_commerciale_con_nome_alfabetico_se_nel_db()
|
||||
{
|
||||
// Visto su un caso reale: le parti commerciali scaricate come STEP (es. anelli,
|
||||
// boccole) hanno nomi Creo alfabetici, non un codice numerico Pro-E - si
|
||||
// riconoscono solo se il nome esiste davvero come codice indicizzato.
|
||||
string percorso = ScriviAsmFinto(
|
||||
"blah Componente ID 11 (ANELLO_ESTERNO-1-SOLID1.PRT) blah RUMORE_CASUALE blah");
|
||||
try
|
||||
{
|
||||
var codiciNoti = new[] { "ANELLO_ESTERNO-1-SOLID1" };
|
||||
var codici = AssemblyComponentScanner.EstraiCodiciReferenziati(percorso, codiciNoti);
|
||||
Assert.Contains("ANELLO_ESTERNO-1-SOLID1", codici);
|
||||
}
|
||||
finally { File.Delete(percorso); }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Scarta_token_alfabetico_nel_db_ma_senza_placement()
|
||||
{
|
||||
// Un token che coincide per puro caso con un codice DB corto/generico (es. una
|
||||
// keyword interna di Creo) non basta: senza un vero placement resta rumore.
|
||||
string percorso = ScriviAsmFinto("start_part blah blah start_part");
|
||||
try
|
||||
{
|
||||
var codiciNoti = new[] { "start_part" };
|
||||
var codici = AssemblyComponentScanner.EstraiCodiciReferenziati(percorso, codiciNoti);
|
||||
Assert.DoesNotContain("start_part", codici);
|
||||
}
|
||||
finally { File.Delete(percorso); }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ignora_token_alfabetici_non_presenti_nel_db()
|
||||
{
|
||||
string percorso = ScriviAsmFinto(
|
||||
"blah Componente ID 1 (QUALCOSA_DI_INESISTENTE-1.PRT) blah");
|
||||
try
|
||||
{
|
||||
var codici = AssemblyComponentScanner.EstraiCodiciReferenziati(percorso, codiciNoti: new[] { "ALTRO_CODICE" });
|
||||
Assert.DoesNotContain("QUALCOSA_DI_INESISTENTE-1", codici);
|
||||
}
|
||||
finally { File.Delete(percorso); }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user