export step parti da assieme - ilogic da modificare

matteostasim

Utente standard
professione: ingegnere
software: inventor
regione: friuli
Buongiorno,
sono in urgenza, tempi strettissimi (vorrei mandare i files oggi), quindi vado diretto.
Devo mandare a lasertubo una marea di tubi tutti simili ma diversi relativi a 10 assiemi.
Al laserista van bene i file step per fortuna.
Quindi devo esportare dagli assieme i singoli step delle singole parti.
Ho trovato in giro una bella regola ilogic che me lo fa.
Ha solo 1 problema: mi salva gli step con il nome del FILE della parte originaria (orrenda essendo telai).
Qualcuno sa cosa devo cambiare per salvarli col numero parte al posto del nome file (in cui ho già cambiato i nomi in caso di lunghezze uguali)?

Di seguito la regola e un paio di immagini per far capire cosa vorrei.
Grazie infinite

SyntaxEditor Code Snippet'define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = ThisDoc.FileName(False) 'without extension

If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
Exit Sub
End If
'get user input
RUsure = MessageBox.Show ( _
"This will create a STEP file for all components." _
& vbLf & " " _
& vbLf & "Are you sure you want to create STEP Drawings for all of the assembly components?" _
& vbLf & "This could take a while.", "iLogic - Batch Output STEPs ",MessageBoxButtons.YesNo)
If RUsure = vbNo Then
Return
Else
End If
'- - - - - - - - - - - - -STEP setup - - - - - - - - - - - -
oPath = ThisDoc.Path
'get STEP target folder path
oFolder = oPath & "\" & oAsmName & " STEP Files"
'Check for the step folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If


'- - - - - - - - - - - - -Assembly - - - - - - - - - - - -
ThisDoc.Document.SaveAs(oFolder & "\" & oAsmName &(".stp") , True)

'- - - - - - - - - - - - -Components - - - - - - - - - - - -
'look at the files referenced by the assembly
Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
'work the referenced models
For Each oRefDoc In oRefDocs
Dim oCurFile As Document
oCurFile = ThisApplication.Documents.Open(oRefDoc.FullFileName, True)
oCurFileName = oCurFile.FullFileName

'defines backslash As the subdirectory separator
Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar

'find the postion of the last backslash in the path
FNamePos = InStrRev(oCurFileName, "\", -1)
'get the file name with the file extension
Name = Right(oCurFileName, Len(oCurFileName) - FNamePos)
'get the file name (without extension)
ShortName = Left(Name, Len(Name) - 4)

Try
oCurFile.SaveAs(oFolder & "\" & ShortName & (".stp") , True)
Catch
MessageBox.Show("Error processing " & oCurFileName, "ilogic")
End Try
oCurFile.Close
Next
'- - - - - - - - - - - - -
MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic")
'open the folder where the new files are saved
Shell("explorer.exe " & oFolder,vbNormalFocus)
 

Allegati

  • Screenshot_1.png
    Screenshot_1.png
    32.9 KB · Views : 7
  • Screenshot_1.1.png
    Screenshot_1.1.png
    24.4 KB · Views : 7
Ultima modifica:

Catafratto

Utente Standard
professione: Disegnatore/progettista
software: Inventor 2024
regione: Veneto
Buongiorno,
sono in urgenza, tempi strettissimi (vorrei mandare i files oggi),

Certo che serve per oggi, se serviva per domani si chiedeva domani 😁

Prima fai un test, su piccolo assieme, ho fatto solo una prova veloce, eseguivo soltanto gli ordini bla bla bla...

Prova questo, comunque mi pare funzioni.

Codice:
'define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = ThisDoc.FileName(False) 'without extension

If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
Exit Sub
End If
'get user input
RUsure = MessageBox.Show ( _
"This will create a STEP file for all components." _
& vbLf & " " _
& vbLf & "Are you sure you want to create STEP Drawings for all of the assembly components?" _
& vbLf & "This could take a while.", "iLogic - Batch Output STEPs ",MessageBoxButtons.YesNo)
If RUsure = vbNo Then
Return
Else
End If
'- - - - - - - - - - - - -STEP setup - - - - - - - - - - - -
oPath = ThisDoc.Path
'get STEP target folder path
oFolder = oPath & "\" & oAsmName & " STEP Files"
'Check for the step folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If


'- - - - - - - - - - - - -Assembly - - - - - - - - - - - -
ThisDoc.Document.SaveAs(oFolder & "\" & oAsmName &(".stp") , True)

'- - - - - - - - - - - - -Components - - - - - - - - - - - -
'look at the files referenced by the assembly
Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
'work the referenced models
For Each oRefDoc In oRefDocs
Dim oCurFile As Document
oCurFile = ThisApplication.Documents.Open(oRefDoc.FullFileName, True)
oCurFileName = oCurFile.FullFileName

'defines backslash As the subdirectory separator
Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar

'find the postion of the last backslash in the path
FNamePos = InStrRev(oCurFileName, "\", -1)
'get the file name with the file extension
Name = Right(oCurFileName, Len(oCurFileName) - FNamePos)
'get the file name (without extension)
'ShortName = Left(Name, Len(Name) - 4)


' ------------------ LEGGE IPROPERTY NUMERO PARTE -----------------------------
ShortName = oCurFile.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").Item("Part Number").Value


Try
oCurFile.SaveAs(oFolder & "\" & ShortName & (".stp") , True)
Catch
MessageBox.Show("Error processing " & oCurFileName, "ilogic")
End Try
oCurFile.Close
Next
'- - - - - - - - - - - - -
MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic")
'open the folder where the new files are saved
Shell("explorer.exe " & oFolder,vbNormalFocus)
 

matteostasim

Utente standard
professione: ingegnere
software: inventor
regione: friuli
Catafratto santo subito! non mi vengono in mente altre risposte adeguate.
Anzi si, devo capire di che zona del Veneto sei (io Friuli) che se sono dalle tue parti ti offro almeno pizza e birra.
Perfettoooooo!!
 

Allegati

  • Screenshot_3.png
    Screenshot_3.png
    183.6 KB · Views : 7

Statistiche forum

Discussioni
59,343
Messaggi
506,802
Utenti registrati
111,663
Ultimo utente registrato
GEOSCAN

Utenti online

Nessun utente è online al momento.
Top