So, nun bin ich erst einmal am Ende meiner Weisheit...
Vielleicht sehe ich den Wald vor lauter Bäumen nicht mehr?!
Ich versuche es nochmal kurz zu umschreiben...
Z.B.:
Eine Schweißteil-Konstruktion eines Gehäuses könnte aus etliche Blechen (teils gekantet), Profilen, Dreh- und Frästeilen bestehen.
Nehmen wir an, dass neben der Zusammenstellungszeichnung eine recht lange Stückliste entsteht. diese legen wir auf weitere Blätter ab (z.B. drei A4 Zeichnungsblätter).
Dreh- und Frästeile liegen auf separaten Zeichnungen (brauchen hier nicht berücksichtigt werden).
Profile, Kauf- und Normteile werden nicht weiter beschrieben.
Jedoch alle Bleche (ggf. auch gekantet) bekommen ein eigenes Blatt, auf der die Abwicklung platz findet.
So entsteht eine Zeichnung (IDW) mit mehreren Blättern:
Blatt 1 "Gehäuse:1"
Blatt 2 "Stückliste:2"
Blatt 3 "Stückliste:3"
Blatt 4 "Stückliste:4"
Blatt 5 "pos01_1.4301_0006_0775_0550"
Blatt 6 "pos02_1.4301_0006_0775_0550"
Blatt 7 "pos03_1.4301_0006_0775_0550"
Blatt 8 "pos04_1.4301_0010_0775_0550"
Blatt 9 "pos05_1.4301_0010_0775_0550"
Blatt 10 "pos06_1.4301_0010_0775_0550"
Blatt 11 "pos07_1.4301_0002_0775_0550"
Blatt 12 "pos08_1.4301_0002_0775_0550"
Mit dem angehängten Listing soll:
1. eine PDF-Datei (mit allen Blättern) erstellt werden.
>das funktioniert<
2. (im o.g. Fall) DWG-Dateien von Blatt1-4, mit den passenden Dateinamen.
>die Dateien werden erstellt, jedoch immer nur mit Blatt 1<
3. (im o.g. Fall) DXF-Dateien von Blatt5-12, mit den passenden Dateinamen.
>die Dateien werden erstellt, jedoch immer nur mit Blatt 1<
Ich hoffe, dass es nur eine Kleinigkeit ist...?
Mag mir jemand helfen??
Sub PDF_erstellen()
Dim fso As Object
Dim iDoc As DrawingDocument
Set iDoc = ThisApplication.ActiveDocument
Dim iPropInf1 As PropertySet
Set iPropInf1 = iDoc.PropertySets.Item("Design Tracking Properties")
Dim iPropInf2 As PropertySet
Set iPropInf2 = iDoc.PropertySets.Item("Inventor Summary Information")
Dim iStockNumberProp As Property
Set iStockNumberProp = iPropInf1.Item("Stock Number")
Dim iRevisionId As Property
Set iRevisionId = iPropInf1.Item("Part Property Revision Id")
Dim iRevisionNo As Property
Set iRevisionNo = iPropInf2.Item("Revision Number")
Dim iDescription As Property
Set iDescription = iPropInf1.Item("Description")
Set fso = CreateObject("Scripting.FilesystemObject")
Dim iPropInfUser As PropertySet
Set iPropInfUser = iDoc.PropertySets.Item("Inventor User Defined Properties")
Call iDoc.Activate
If iDoc Is Nothing Then
Exit Sub
Else
If Len(Trim(iDoc.FullFileName)) > 0 Then
Dim PDFAddIn As TranslatorAddIn
Set PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
oDataMedium.FileName = fso.GetParentFolderName(iDoc.FullFileName) & "\" & iStockNumberProp.Value & iRevisionNo.Value & "_" & iDescription.Value & ".pdf"
If PDFAddIn.HasSaveCopyAsOptions(iDoc, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 1200
oOptions.Value("Sheet_Range") = kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
Call PDFAddIn.SaveCopyAs(iDoc, oContext, oOptions, oDataMedium)
Else
Exit Sub
End If
End If
End If
' MsgBox "Zeichnungs-Nummer: " & iStockNumberProp.Value
' MsgBox "Revisions-Nummer: " & iRevisionNo.Value
' MsgBox "Beschreibung: " & iDescription.Value
' MsgBox "Dateiname: " & fso.GetParentFolderName(iDoc.FullFileName) & "\" & iStockNumberProp.Value & iRevisionNo.Value & "_" & iDescription.Value & ".pdf"
Dim iapp As Inventor.Application
Set iapp = ThisApplication
If iapp.ActiveDocument Is Nothing Then
Exit Sub
End If
If iapp.ActiveDocumentType <> kDrawingDocumentObject Then
Exit Sub
End If
Set iDoc = iapp.ActiveDocument
Dim DXFAddIn As TranslatorAddIn
Set DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
Dim strIniFile As String
Dim i As Integer
Dim e As Integer
i = 1
For i = 2 To iDoc.Sheets.Count
If i < 10 Then
If Left(iDoc.Sheets.Item(i).Name, 10) <> "Stückliste" Then
oDataMedium.FileName = fso.GetParentFolderName(iDoc.FullFileName) & "\" & iStockNumberProp.Value & iRevisionNo.Value & "_" & Left(iDoc.Sheets.Item(i).Name, Len(iDoc.Sheets.Item(i).Name) - 2) & ".dxf"
strIniFile = "\\POLYCAD-01\Inventor_System\Vorlagen\DXF-Vorgabe.ini"
oOptions.Value("Export_Acad_IniFile") = strIniFile
Call DXFAddIn.SaveCopyAs(iDoc, oContext, oOptions, oDataMedium)
End If
Else
If Left(iDoc.Sheets.Item(i).Name, 10) <> "Stückliste" Then
oDataMedium.FileName = fso.GetParentFolderName(iDoc.FullFileName) & "\" & iStockNumberProp.Value & iRevisionNo.Value & "_" & Left(iDoc.Sheets.Item(i).Name, Len(iDoc.Sheets.Item(i).Name) - 3) & ".dxf"
strIniFile = "\\POLYCAD-01\Inventor_System\Vorlagen\DXF-Vorgabe.ini"
oOptions.Value("Export_Acad_IniFile") = strIniFile
Call DXFAddIn.SaveCopyAs(iDoc, oContext, oOptions, oDataMedium)
End If
End If
Next
Dim DWGAddIn As TranslatorAddIn
Set DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")
i = 1
For i = 1 To iDoc.Sheets.Count
If i < 10 Then
If Left(iDoc.Sheets.Item(i).Name, 10) = "Stückliste" Then
e = i - 1
oDataMedium.FileName = fso.GetParentFolderName(iDoc.FullFileName) & "\" & iStockNumberProp.Value & iRevisionNo.Value & "_" & Left(iDoc.Sheets.Item(i).Name, Len(iDoc.Sheets.Item(i).Name) - 2) & "_" & e & ".dwg"
' MsgBox "Dateiname: " & iStockNumberProp.Value & iRevisionNo.Value & "_" & Left(iDoc.Sheets.Item(i).Name, Len(iDoc.Sheets.Item(i).Name)) & "_" & i & ".dwg"
strIniFile = "\\POLYCAD-01\Inventor_System\Vorlagen\DWG-Vorgabe.ini"
oOptions.Value("Export_Acad_IniFile") = strIniFile
Call DWGAddIn.SaveCopyAs(iDoc, oContext, oOptions, oDataMedium)
Else
If i < 2 Then
oDataMedium.FileName = fso.GetParentFolderName(iDoc.FullFileName) & "\" & iStockNumberProp.Value & iRevisionNo.Value & "_" & Left(iDoc.Sheets.Item(1).Name, Len(iDoc.Sheets.Item(1).Name) - 2) & ".dwg"
strIniFile = "\\POLYCAD-01\Inventor_System\Vorlagen\DWG-Vorgabe.ini"
oOptions.Value("Export_Acad_IniFile") = strIniFile
Call DWGAddIn.SaveCopyAs(iDoc, oContext, oOptions, oDataMedium)
End If
End If
Else
If Left(iDoc.Sheets.Item(i).Name, 10) = "Stückliste" Then
e = i - 1
oDataMedium.FileName = fso.GetParentFolderName(iDoc.FullFileName) & "\" & iStockNumberProp.Value & iRevisionNo.Value & "_" & Left(iDoc.Sheets.Item(i).Name, Len(iDoc.Sheets.Item(i).Name) - 3) & "_" & e & ".dwg"
' MsgBox "Dateiname: " & iStockNumberProp.Value & iRevisionNo.Value & "_" & Left(iDoc.Sheets.Item(i).Name, Len(iDoc.Sheets.Item(i).Name)) & "_" & i & ".dwg"
strIniFile = "\\POLYCAD-01\Inventor_System\Vorlagen\DWG-Vorgabe.ini"
oOptions.Value("Export_Acad_IniFile") = strIniFile
Call DWGAddIn.SaveCopyAs(iDoc, oContext, oOptions, oDataMedium)
Else
If i < 2 Then
oDataMedium.FileName = fso.GetParentFolderName(iDoc.FullFileName) & "\" & iStockNumberProp.Value & iRevisionNo.Value & "_" & Left(iDoc.Sheets.Item(1).Name, Len(iDoc.Sheets.Item(1).Name) - 3) & ".dwg"
strIniFile = "\\POLYCAD-01\Inventor_System\Vorlagen\DWG-Vorgabe.ini"
oOptions.Value("Export_Acad_IniFile") = strIniFile
Call DWGAddIn.SaveCopyAs(iDoc, oContext, oOptions, oDataMedium)
End If
End If
End If
Next
End Sub
Gruß, Jürgen
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP