Hallo, also ich benutze das hier als Externe Regel um zu prüfen ob ich alle Zeichnungen gemacht habe, und ob diese im richtigen Ordner liegen. (Die suche ist auf den Arbeitsbereich des Aktiven Projekts beschränkt)
Wenn eine fehlt, oder falsch abliegt, kriege ich im Protokoll eine Liste:
Bei fehlender, --> Dateiname gefolgt von der Titel iProperty
Bei falschem Pfad, --> Den Pfad wo die Zeichnung abliegt
In Zeile 30+31 schließe ich Dateien aus die bei mir nie eine Zeichnung haben, das müsstest du an eure Bedürfnisse anpassen
Sub Main()
Dim oDoc As Document
oDoc = ThisDoc.Document
oDocName = System.IO.Path.GetDirectoryName(oDoc.FullFileName) & "\" & System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)
If Not (oDoc.DocumentType = kAssemblyDocumentObject) Then
MessageBox.Show("Please run this rule from the assembly / Bitte in einer Baugruppe ausführen", "iLogic")
Exit Sub
End If
Dim oNoDwgString As String
Dim oWrongPathString As String
'- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - -
Dim oRefDoc As Document
Dim oDrawDoc As DrawingDocument
For Each oRefDoc In oDoc.AllReferencedDocuments
oBaseName = System.IO.Path.GetFileNameWithoutExtension(oRefDoc.FullFileName)
oPathAndName = System.IO.Path.GetDirectoryName(oRefDoc.FullFileName) & "\" & oBaseName
Dim oEigenschaftProp As PropertySet
oEigenschaftProp = oRefDoc.PropertySets.Item("Document Summary Information")
Dim oKategorie As Inventor.Property
oKategorie = oEigenschaftProp.Item("Category")
Dim oEigenschaftProp2 As PropertySet
oEigenschaftProp2 = oRefDoc.PropertySets.Item("Summary Information")
Dim oTitle As Inventor.Property
oTitle = oEigenschaftProp2.Item("Title")
Select Case oKategorie.Value
Case "NT","SK","PH","LG","MO",""
Case Else
If String.IsNullOrEmpty(GetDrawingPath(oBaseName)) Then
oNoDwgString = oNoDwgString & vbLf & oBaseName & " " & oTitle.Value
Else If GetDrawingPath(oBaseName) <> oPathAndName Then
oWrongPathString = oWrongPathString & vbLf & GetDrawingPath(oBaseName)
End If
End Select
Next
'- - - - - - - - - - - - -
'- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - -
oBaseName = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)
oPathAndName = System.IO.Path.GetDirectoryName(oDoc.FullFileName) & "\" & oBaseName
If String.IsNullOrEmpty(GetDrawingPath(oBaseName)) Then
oNoDwgString = oNoDwgString & vbLf & oBaseName & " " & iProperties.Value("Summary", "Title") & " OBERSTE BAUGRUPPE"
Else If GetDrawingPath(oBaseName) <> oPathAndName Then
oWrongPathString = oWrongPathString & vbLf & GetDrawingPath(oBaseName)
End If
If oNoDwgString <> "" Then
Logger.Warn( _
" Keine Zeichnung gefunden:" _
& vbNewLine & oNoDwgString & vbNewLine & vbNewLine)
End If
If oWrongPathString <> "" Then
Logger.Warn( _
" Zeichnung vorhanden, aber nicht im Modellpfad:" _
& vbNewLine & oWrongPathString & vbNewLine & vbNewLine)
End If
End Sub
Function GetDrawingPath (docname As String) As String
Dim filename As String = docname & ".idw"
Dim workspacepath As String = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath & "\"
Dim filestring As String = ThisApplication.DesignProjectManager.ResolveFile(workspacepath, filename)
If Not String.IsNullOrEmpty(filestring) Then
Return Strings.Left(filestring, (filestring.Length-4))
Else
End If
End Function
Fanden Sie diesen Beitrag hilfreich? Fühlen Sie sich frei, diesen Beitrag zu liken.
Wurde Ihre Frage erfolgreich beantwortet? Klicken Sie dann auf die Schaltfläche LÖSUNG AKZEPTIEREN
Inventor Versionen:
2023.4.3
2025.2