Hi all,
I am able to export the assembly as one step file with the full model tree but I am trying to export an assembly into individual step files of every component in that assembly, is there any way to do this easily?
Cheers,
Iain
Solved! Go to Solution.
Hi all,
I am able to export the assembly as one step file with the full model tree but I am trying to export an assembly into individual step files of every component in that assembly, is there any way to do this easily?
Cheers,
Iain
Solved! Go to Solution.
Solved by Justin.Williams. Go to Solution.
Hi Iain,
I don't think you can do this in Inventor without customization.
NXTdim Batch Publish van do it. You can download a trial form the Inventor Exchange
https://apps.autodesk.com/en/Publisher/PublisherHomepage?ID=HUSPL4JKGND7
Otherwise you need to write your own VBA or iLogic rule to do this.
Hi Iain,
I don't think you can do this in Inventor without customization.
NXTdim Batch Publish van do it. You can download a trial form the Inventor Exchange
https://apps.autodesk.com/en/Publisher/PublisherHomepage?ID=HUSPL4JKGND7
Otherwise you need to write your own VBA or iLogic rule to do this.
Hi Roelof,
Thank you for your reply, is there anywhere I can look for guidance on creating an ilogic rule to do this?
Iain
Hi Roelof,
Thank you for your reply, is there anywhere I can look for guidance on creating an ilogic rule to do this?
Iain
Look at your Task Scheduler ...
It has an Export option. You can do all of the files in an IPJ..
Might need to tweak it a bit
Look at your Task Scheduler ...
It has an Export option. You can do all of the files in an IPJ..
Might need to tweak it a bit
Hi Michael,
I used Task Scheduler in the end but it wasn't ideal because all the files were in several different folders and not necessarily all the files in that folder either.
What I really want is for all the components visible in the model view of an assembly to be exported, I am currently trying to write an illogic script to do just that.
Cheers,
Iain
Hi Michael,
I used Task Scheduler in the end but it wasn't ideal because all the files were in several different folders and not necessarily all the files in that folder either.
What I really want is for all the components visible in the model view of an assembly to be exported, I am currently trying to write an illogic script to do just that.
Cheers,
Iain
I have been using the iLogic code provided in the link below to export PDF files of drawings for each component in an assembly.
I bet this code can be modified to make it export .stp instead of a PDF of the drawing. I wish I knew how, because this is something I also want to be able to do. I currently use task scheduler and select each component manually and change the export option to .stp one at a time.
Does anyone know how to modify it to make it export .stp?
http://inventortrenches.blogspot.com/2012/11/ilogic-batch-output-pdfs-from-assembly.html
'define the active document as an assembly file Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) 'check that the active document is an assembly file 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 PDF file for all of the asembly components that have drawings files." _ & vblf & "This rule expects that the drawing file shares the same name and location as the component." _ & vblf & " " _ & vblf & "Are you sure you want to create PDF Drawings for all of the assembly components?" _ & vblf & "This could take a while.", "iLogic - Batch Output PDFs ",MessageBoxButtons.YesNo) If RUsure = vbNo Then Return Else End If '- - - - - - - - - - - - -PDF setup - - - - - - - - - - - - oPath = ThisDoc.Path PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then 'oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 End If 'get PDF target folder path oFolder = oPath & "\" & oAsmName & " PDF Files" 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If '- - - - - - - - - - - - - '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - - 'look at the files referenced by the assembly Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document 'work the the drawing files for the referenced models 'this expects that the model has a drawing of the same path and name For Each oRefDoc In oRefDocs idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw" 'check to see that the model has a drawing of the same path and name If(System.IO.File.Exists(idwPathName)) Then Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.Documents.Open(idwPathName, True) oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) -3) On error Resume Next ' if PDF exists and is open or read only, resume next 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & "pdf" 'Write out the PDF Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium) 'close the file oDrawDoc.Close Else 'If the model has no drawing of the same path and name - do nothing End If Next '- - - - - - - - - - - - - '- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - - oAsmDrawing = ThisDoc.ChangeExtension(".idw") oAsmDrawingDoc = ThisApplication.Documents.Open(oAsmDrawing, True) oAsmDrawingName = Left(oAsmDrawingDoc.DisplayName, Len(oAsmDrawingDoc.DisplayName) -3) 'write out the PDF for the Top Level Assembly Drawing file On error Resume Next ' if PDF exists and is open or read only, resume next 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oAsmDrawingName & "pdf" 'Write out the PDF Call PDFAddIn.SaveCopyAs(oAsmDrawingDoc, oContext, oOptions, oDataMedium) 'Close the top level drawing oAsmDrawingDoc.Close '- - - - - - - - - - - - - MessageBox.Show("New Files Created in: " & vblf & oFolder, "iLogic") 'open the folder where the new ffiles are saved Shell("explorer.exe " & oFolder,vbNormalFocus)
I have been using the iLogic code provided in the link below to export PDF files of drawings for each component in an assembly.
I bet this code can be modified to make it export .stp instead of a PDF of the drawing. I wish I knew how, because this is something I also want to be able to do. I currently use task scheduler and select each component manually and change the export option to .stp one at a time.
Does anyone know how to modify it to make it export .stp?
http://inventortrenches.blogspot.com/2012/11/ilogic-batch-output-pdfs-from-assembly.html
'define the active document as an assembly file Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) 'check that the active document is an assembly file 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 PDF file for all of the asembly components that have drawings files." _ & vblf & "This rule expects that the drawing file shares the same name and location as the component." _ & vblf & " " _ & vblf & "Are you sure you want to create PDF Drawings for all of the assembly components?" _ & vblf & "This could take a while.", "iLogic - Batch Output PDFs ",MessageBoxButtons.YesNo) If RUsure = vbNo Then Return Else End If '- - - - - - - - - - - - -PDF setup - - - - - - - - - - - - oPath = ThisDoc.Path PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then 'oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 End If 'get PDF target folder path oFolder = oPath & "\" & oAsmName & " PDF Files" 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If '- - - - - - - - - - - - - '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - - 'look at the files referenced by the assembly Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document 'work the the drawing files for the referenced models 'this expects that the model has a drawing of the same path and name For Each oRefDoc In oRefDocs idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw" 'check to see that the model has a drawing of the same path and name If(System.IO.File.Exists(idwPathName)) Then Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.Documents.Open(idwPathName, True) oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) -3) On error Resume Next ' if PDF exists and is open or read only, resume next 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & "pdf" 'Write out the PDF Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium) 'close the file oDrawDoc.Close Else 'If the model has no drawing of the same path and name - do nothing End If Next '- - - - - - - - - - - - - '- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - - oAsmDrawing = ThisDoc.ChangeExtension(".idw") oAsmDrawingDoc = ThisApplication.Documents.Open(oAsmDrawing, True) oAsmDrawingName = Left(oAsmDrawingDoc.DisplayName, Len(oAsmDrawingDoc.DisplayName) -3) 'write out the PDF for the Top Level Assembly Drawing file On error Resume Next ' if PDF exists and is open or read only, resume next 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oAsmDrawingName & "pdf" 'Write out the PDF Call PDFAddIn.SaveCopyAs(oAsmDrawingDoc, oContext, oOptions, oDataMedium) 'Close the top level drawing oAsmDrawingDoc.Close '- - - - - - - - - - - - - MessageBox.Show("New Files Created in: " & vblf & oFolder, "iLogic") 'open the folder where the new ffiles are saved Shell("explorer.exe " & oFolder,vbNormalFocus)
drawings as stp?
you mean assembly structure (parts and subcomponents to stp)?
it's not that difficult, will give it a stab.....
Oops....I've done it already, and forgot about it.
Check it here: http://blog.ads-sol.com/2016/01/batch-assembly-export.html
Good Luck.
drawings as stp?
you mean assembly structure (parts and subcomponents to stp)?
it's not that difficult, will give it a stab.....
Oops....I've done it already, and forgot about it.
Check it here: http://blog.ads-sol.com/2016/01/batch-assembly-export.html
Good Luck.
Thanks for sharing! That was helpful, but I need step files for ONLY files which have a drawing. I modified your code a bit so that it first checks to see if a file has a drawing, and if a drawing exists, it will export the step file.
Hopefully someone else finds it helpful! This will be a huge time saver for me
'define the active document as an assembly file Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) 'check that the active document is an assembly file 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 STP file for all of the asembly components that have drawings files." _ & vbLf & "This rule expects that the drawing file shares the same name and location as the component." _ & vbLf & " " _ & vbLf & "Are you sure you want to create PDF Drawings for all of the assembly components?" _ & vbLf & "This could take a while.", "iLogic - Batch Output PDFs ",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 '- - - - - - - - - - - - - '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - - 'look at the files referenced by the assembly Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document 'work the the drawing files for the referenced models 'this expects that the model has a drawing of the same path and name For Each oRefDoc In oRefDocs idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw" 'check to see that the model has a drawing of the same path and name If(System.IO.File.Exists(idwPathName)) Then Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.Documents.Open(idwPathName, True) oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) -3) On Error Resume Next ' if PDF exists and is open or read only, resume next 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & "pdf" 'Write out the PDF Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium) 'close the file oDrawDoc.Close Else 'If the model has no drawing of the same path and name - do nothing End If Next '- - - - - - - - - - - - - '- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - - oAsmDrawing = ThisDoc.ChangeExtension(".idw") oAsmDrawingDoc = ThisApplication.Documents.Open(oAsmDrawing, True) oAsmDrawingName = Left(oAsmDrawingDoc.DisplayName, Len(oAsmDrawingDoc.DisplayName) -3) 'write out the PDF for the Top Level Assembly Drawing file On Error Resume Next ' if PDF exists and is open or read only, resume next 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oAsmDrawingName & "pdf" 'Write out the PDF Call PDFAddIn.SaveCopyAs(oAsmDrawingDoc, oContext, oOptions, oDataMedium) 'Close the top level drawing oAsmDrawingDoc.Close '- - - - - - - - - - - - - MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") 'open the folder where the new ffiles are saved Shell("explorer.exe " & oFolder,vbNormalFocus)
Thanks for sharing! That was helpful, but I need step files for ONLY files which have a drawing. I modified your code a bit so that it first checks to see if a file has a drawing, and if a drawing exists, it will export the step file.
Hopefully someone else finds it helpful! This will be a huge time saver for me
'define the active document as an assembly file Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) 'check that the active document is an assembly file 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 STP file for all of the asembly components that have drawings files." _ & vbLf & "This rule expects that the drawing file shares the same name and location as the component." _ & vbLf & " " _ & vbLf & "Are you sure you want to create PDF Drawings for all of the assembly components?" _ & vbLf & "This could take a while.", "iLogic - Batch Output PDFs ",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 '- - - - - - - - - - - - - '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - - 'look at the files referenced by the assembly Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document 'work the the drawing files for the referenced models 'this expects that the model has a drawing of the same path and name For Each oRefDoc In oRefDocs idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw" 'check to see that the model has a drawing of the same path and name If(System.IO.File.Exists(idwPathName)) Then Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.Documents.Open(idwPathName, True) oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) -3) On Error Resume Next ' if PDF exists and is open or read only, resume next 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & "pdf" 'Write out the PDF Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium) 'close the file oDrawDoc.Close Else 'If the model has no drawing of the same path and name - do nothing End If Next '- - - - - - - - - - - - - '- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - - oAsmDrawing = ThisDoc.ChangeExtension(".idw") oAsmDrawingDoc = ThisApplication.Documents.Open(oAsmDrawing, True) oAsmDrawingName = Left(oAsmDrawingDoc.DisplayName, Len(oAsmDrawingDoc.DisplayName) -3) 'write out the PDF for the Top Level Assembly Drawing file On Error Resume Next ' if PDF exists and is open or read only, resume next 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oAsmDrawingName & "pdf" 'Write out the PDF Call PDFAddIn.SaveCopyAs(oAsmDrawingDoc, oContext, oOptions, oDataMedium) 'Close the top level drawing oAsmDrawingDoc.Close '- - - - - - - - - - - - - MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") 'open the folder where the new ffiles are saved Shell("explorer.exe " & oFolder,vbNormalFocus)
Uhhh..... goodies
I am soooo gonna be stealing your code now!
Brill find, keep up the good work @Justin.Williams
Uhhh..... goodies
I am soooo gonna be stealing your code now!
Brill find, keep up the good work @Justin.Williams
Thanks for all the responses! That code works miracles! I also found this thread from Feb '16 that looks to see if the file is part of the Normal BOM structure before export.
Cheers,
Iain
Thanks for all the responses! That code works miracles! I also found this thread from Feb '16 that looks to see if the file is part of the Normal BOM structure before export.
Cheers,
Iain
This post is a Great! 🙂
Thanks
Let me one question. If I want to add more data to a step file name (custom iProperties), how can I make it?
So I create a custom iProperty (i.e.: "comp_drawno") in a custom property tab. How can I add to the code to create the step file name with comp_drawno?
Many thanks
This post is a Great! 🙂
Thanks
Let me one question. If I want to add more data to a step file name (custom iProperties), how can I make it?
So I create a custom iProperty (i.e.: "comp_drawno") in a custom property tab. How can I add to the code to create the step file name with comp_drawno?
Many thanks
Could you please explain of how to fix the compile errors that occur .
I clicked on Add Rule, gave it a name(Rule) and pasted the code.
Could you please explain of how to fix the compile errors that occur .
I clicked on Add Rule, gave it a name(Rule) and pasted the code.
Hi guys,
I appreciate your effort in providing a solution. Unfortunately, my problem goes a little further. Maybe one of you has an idea how to fix it.
I also need a way to export assemblies as STEP files with individual files for each of the assembly's components.
However, in the end I want the STEP-file of the assembly to only contain references to the components' files but not the entire assembly's geometry.
In creo parametric there is such an option.
The reason we need this is that our own software is capable of importing step data. If we or our customers were able to sort out certain components such as standard parts in the windows explorer, the imported models would be much leaner, increasing our software's performance.
If you could think of any way to establish such a procedure, I would really appreciate any hint.
Thank you! Cheers, Malte Vollmer
Hi guys,
I appreciate your effort in providing a solution. Unfortunately, my problem goes a little further. Maybe one of you has an idea how to fix it.
I also need a way to export assemblies as STEP files with individual files for each of the assembly's components.
However, in the end I want the STEP-file of the assembly to only contain references to the components' files but not the entire assembly's geometry.
In creo parametric there is such an option.
The reason we need this is that our own software is capable of importing step data. If we or our customers were able to sort out certain components such as standard parts in the windows explorer, the imported models would be much leaner, increasing our software's performance.
If you could think of any way to establish such a procedure, I would really appreciate any hint.
Thank you! Cheers, Malte Vollmer
Hi! I think I know what you are talking about. But, I don't think Inventor supports such STEP Export workflow. I need to work with the project team to understand the request better and how we can accommodate it.
Many thanks!
Hi! I think I know what you are talking about. But, I don't think Inventor supports such STEP Export workflow. I need to work with the project team to understand the request better and how we can accommodate it.
Many thanks!
Hi! I got confirmation from the project team that the distributed STEP files are not yet supported. Please submit it as an idea to Inventor Ideas forum (https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232).
Many thanks!
Hi! I got confirmation from the project team that the distributed STEP files are not yet supported. Please submit it as an idea to Inventor Ideas forum (https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232).
Many thanks!
This is what I was able to come up with for PDF & STEP files. Works good, but I can imagine it would take a while with larger assemblies. This was created in Inventor 2017, so I hope there are not 2018 bugs for you.
Sub Main() Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) 'check that the active document is an assembly file If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If 'get user input If MessageBox.Show ( _ "This will create a PDF & STEP file for all of the assembly components that have drawings files." _ & vbLf & "This rule expects that the drawing file shares the same name and location as the component." _ & vbLf & " " _ & vbLf & "Are you sure you want to create these files for all of the assembly components?" _ & vbLf & "This could take a while.", "iLogic - Batch Output STPs ",MessageBoxButtons.YesNo) = vbNo Then Exit Sub End If Dim PDFAddIn As TranslatorAddIn Dim oContext As TranslationContext Dim oOptions As NameValueMap Dim oDataMedium As DataMedium Call ConfigurePDFAddinSettings(PDFAddIn, oContext, oOptions, oDataMedium) oPath = ThisDoc.Path oFolder = oPath & "\_" & oAsmName & " PDF & STEP Files" If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - -' 'look at the files referenced by the assembly Dim oRefDoc As Document For Each oRefDoc In oAsmDoc.AllReferencedDocuments idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentNaMe) - 3) & "idw" If(System.IO.File.Exists(idwPathName)) Then Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.Documents.Open(idwPathName, True) Dim oSTEPDoc As Document oSTEPDoc = ThisApplication.Documents.Open(oRefDoc.FullFileName, True) oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) -4) oRevNum = oDrawDoc.PropertySets.Item("Inventor Summary Information").Item("Revision Number").Value ' On Error Resume Next ' 'Set the PDF target file name If oRevNum = Nothing Then oDataMedium.FileName = oFolder & "\" & oFileName & ".pdf" oSTEPDoc.SaveAs(oFolder & "\" & oFileName & (".stp") , True) Else oDataMedium.FileName = oFolder & "\" & oFileName & " Rev." & oRevNum & ".pdf" End If Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium) oSTEPDoc.SaveAs(oFolder & "\" & oFileName & (".stp") , True) oDrawDoc.Close oRefDoc.Close On Error Goto 0 End If Next '- - - - - - - - - - - - - '- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - - Dim oAsmDrawingDoc As DrawingDocument oAsmDrawingDoc = ThisApplication.Documents.Open(ThisDoc.ChangeExtension(".idw"), True) oAsmDrawingName = Left(oAsmDrawingDoc.DisplayName, Len(oAsmDrawingDoc.DisplayName) -4) oAsmDrawingRev = oAsmDrawingDoc.PropertySets.Item("Inventor Summary Information").Item("Revision Number").Value ' ' On Error Resume Next' 'Set the PDF target file name If oAsmDrawingRev = Nothing Then oDataMedium.FileName = oFolder & "\" & oAsmDrawingName & ".pdf" Else oDataMedium.FileName = oFolder & "\" & oAsmDrawingName & " Rev." & oRevNum & ".pdf" End If Call PDFAddIn.SaveCopyAs(oAsmDrawingDoc, oContext, oOptions, oDataMedium) oAsmDrawingDoc.Close MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") Shell("explorer.exe " & oFolder,vbNormalFocus) End Sub Sub ConfigurePDFAddinSettings(ByRef PDFAddIn As TranslatorAddIn, ByRef oContext As TranslationContext, ByRef oOptions As NameValueMap, ByRef oDataMedium As DataMedium) oPath = ThisDoc.Path PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 0 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets oOptions.Value("Custom_Begin_Sheet") = 1 oOptions.Value("Custom_End_Sheet") = 1 oDataMedium = ThisApplication.TransientObjects.CreateDataMedium End Sub
This is what I was able to come up with for PDF & STEP files. Works good, but I can imagine it would take a while with larger assemblies. This was created in Inventor 2017, so I hope there are not 2018 bugs for you.
Sub Main() Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) 'check that the active document is an assembly file If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If 'get user input If MessageBox.Show ( _ "This will create a PDF & STEP file for all of the assembly components that have drawings files." _ & vbLf & "This rule expects that the drawing file shares the same name and location as the component." _ & vbLf & " " _ & vbLf & "Are you sure you want to create these files for all of the assembly components?" _ & vbLf & "This could take a while.", "iLogic - Batch Output STPs ",MessageBoxButtons.YesNo) = vbNo Then Exit Sub End If Dim PDFAddIn As TranslatorAddIn Dim oContext As TranslationContext Dim oOptions As NameValueMap Dim oDataMedium As DataMedium Call ConfigurePDFAddinSettings(PDFAddIn, oContext, oOptions, oDataMedium) oPath = ThisDoc.Path oFolder = oPath & "\_" & oAsmName & " PDF & STEP Files" If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - -' 'look at the files referenced by the assembly Dim oRefDoc As Document For Each oRefDoc In oAsmDoc.AllReferencedDocuments idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentNaMe) - 3) & "idw" If(System.IO.File.Exists(idwPathName)) Then Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.Documents.Open(idwPathName, True) Dim oSTEPDoc As Document oSTEPDoc = ThisApplication.Documents.Open(oRefDoc.FullFileName, True) oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) -4) oRevNum = oDrawDoc.PropertySets.Item("Inventor Summary Information").Item("Revision Number").Value ' On Error Resume Next ' 'Set the PDF target file name If oRevNum = Nothing Then oDataMedium.FileName = oFolder & "\" & oFileName & ".pdf" oSTEPDoc.SaveAs(oFolder & "\" & oFileName & (".stp") , True) Else oDataMedium.FileName = oFolder & "\" & oFileName & " Rev." & oRevNum & ".pdf" End If Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium) oSTEPDoc.SaveAs(oFolder & "\" & oFileName & (".stp") , True) oDrawDoc.Close oRefDoc.Close On Error Goto 0 End If Next '- - - - - - - - - - - - - '- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - - Dim oAsmDrawingDoc As DrawingDocument oAsmDrawingDoc = ThisApplication.Documents.Open(ThisDoc.ChangeExtension(".idw"), True) oAsmDrawingName = Left(oAsmDrawingDoc.DisplayName, Len(oAsmDrawingDoc.DisplayName) -4) oAsmDrawingRev = oAsmDrawingDoc.PropertySets.Item("Inventor Summary Information").Item("Revision Number").Value ' ' On Error Resume Next' 'Set the PDF target file name If oAsmDrawingRev = Nothing Then oDataMedium.FileName = oFolder & "\" & oAsmDrawingName & ".pdf" Else oDataMedium.FileName = oFolder & "\" & oAsmDrawingName & " Rev." & oRevNum & ".pdf" End If Call PDFAddIn.SaveCopyAs(oAsmDrawingDoc, oContext, oOptions, oDataMedium) oAsmDrawingDoc.Close MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") Shell("explorer.exe " & oFolder,vbNormalFocus) End Sub Sub ConfigurePDFAddinSettings(ByRef PDFAddIn As TranslatorAddIn, ByRef oContext As TranslationContext, ByRef oOptions As NameValueMap, ByRef oDataMedium As DataMedium) oPath = ThisDoc.Path PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 0 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets oOptions.Value("Custom_Begin_Sheet") = 1 oOptions.Value("Custom_End_Sheet") = 1 oDataMedium = ThisApplication.TransientObjects.CreateDataMedium End Sub
Hi, i am trying to export Step files of the parts only from the main assembly and want the description and filename to be a part of Step file name.
Is there any way around that? i tried to run the provided ilogic in sections but no result.
Hi, i am trying to export Step files of the parts only from the main assembly and want the description and filename to be a part of Step file name.
Is there any way around that? i tried to run the provided ilogic in sections but no result.
I suspect that the Inventor Task Scheduler would be helpful here. You don't say which version of Inventor you're using, but here is the 2020 Help section for Task Scheduler.
Task Scheduler allows you to select files to be exported by project, by folder, or by individual selection. Hope that does what you need.
Sam B
Inventor Pro 2021.2 | Windows 10 Home 2004
LinkedIn
I suspect that the Inventor Task Scheduler would be helpful here. You don't say which version of Inventor you're using, but here is the 2020 Help section for Task Scheduler.
Task Scheduler allows you to select files to be exported by project, by folder, or by individual selection. Hope that does what you need.
Sam B
Inventor Pro 2021.2 | Windows 10 Home 2004
LinkedIn
Hi hamza.khan -
I added a line to grab description from components and changed the Save As path (shown in bold green below). This is more simplified than the PDF & STEP one that I posted earlier, but if you still want that functionality, just add to it. Hope that's what you were looking for.
Sub Main() Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) 'check that the active document is an assembly file If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If 'get user input ' If MessageBox.Show ( _ ' "This will create a STP file for all of the asembly components that have drawings files." _ ' & vbLf & "This rule expects that the drawing file shares the same name and location as the component." _ ' & vbLf & " " _ ' & vbLf & "Are you sure you want to create STP Drawings for all of the assembly components?" _ ' & vbLf & "This could take a while.", "iLogic - Batch Output STPs ",MessageBoxButtons.YesNo) = vbNo Then ' ' Exit Sub ' End If Dim STEPTranslator As TranslatorAddIn Dim oContext As TranslationContext Dim oOptions As NameValueMap Dim oDataMedium As DataMedium Call ConfigureSTEPTranslatorSettings(STEPTranslator, oContext, oOptions, oDataMedium) oPath = ThisDoc.Path oFolder = oPath & "\_" & oAsmName & " STEP Files" If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - -' 'look at the files referenced by the assembly Dim oRefDoc As Document For Each oRefDoc In oAsmDoc.AllReferencedDocuments idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw" If(System.IO.File.Exists(idwPathName)) Then Dim oSTEPDoc As Document oSTEPDoc = ThisApplication.Documents.Open(oRefDoc.FullFileName, True) oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) -4) oDesc = oSTEPDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value ' On Error Resume Next 'Save as STEP oSTEPDoc.SaveAs(oFolder & "\" & oFileName & " " & oDesc & (".stp") , True) Call STEPTranslator.SaveCopyAs(oSTEPDoc, oContext, oOptions, oDataMedium) oRefDoc.Close On Error GoTo 0 End If Next MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") Shell("explorer.exe " & oFolder,vbNormalFocus) End Sub Sub ConfigureSTEPTranslatorSettings(ByRef STEPTranslator As TranslatorAddIn, ByRef oContext As TranslationContext, ByRef oOptions As NameValueMap, ByRef oDataMedium As DataMedium) oPath = ThisDoc.Path oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then ' Set application protocol. ' 2 = AP 203 - Configuration Controlled Design ' 3 = AP 214 - Automotive Design oOptions.Value("ApplicationProtocolType") = 3 ' Other options... 'oOptions.Value("Author") = "" 'oOptions.Value("Authorization") = "" 'oOptions.Value("Description") = "" 'oOptions.Value("Organization") = "" oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism ' Dim oData As DataMedium oDataMedium = ThisApplication.TransientObjects.CreateDataMedium oDataMedium.FileName = ThisDoc.PathAndFileName(False) & ".stp" oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oDataMedium) End If oDataMedium = ThisApplication.TransientObjects.CreateDataMedium End Sub
Hi hamza.khan -
I added a line to grab description from components and changed the Save As path (shown in bold green below). This is more simplified than the PDF & STEP one that I posted earlier, but if you still want that functionality, just add to it. Hope that's what you were looking for.
Sub Main() Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) 'check that the active document is an assembly file If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If 'get user input ' If MessageBox.Show ( _ ' "This will create a STP file for all of the asembly components that have drawings files." _ ' & vbLf & "This rule expects that the drawing file shares the same name and location as the component." _ ' & vbLf & " " _ ' & vbLf & "Are you sure you want to create STP Drawings for all of the assembly components?" _ ' & vbLf & "This could take a while.", "iLogic - Batch Output STPs ",MessageBoxButtons.YesNo) = vbNo Then ' ' Exit Sub ' End If Dim STEPTranslator As TranslatorAddIn Dim oContext As TranslationContext Dim oOptions As NameValueMap Dim oDataMedium As DataMedium Call ConfigureSTEPTranslatorSettings(STEPTranslator, oContext, oOptions, oDataMedium) oPath = ThisDoc.Path oFolder = oPath & "\_" & oAsmName & " STEP Files" If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If '- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - -' 'look at the files referenced by the assembly Dim oRefDoc As Document For Each oRefDoc In oAsmDoc.AllReferencedDocuments idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw" If(System.IO.File.Exists(idwPathName)) Then Dim oSTEPDoc As Document oSTEPDoc = ThisApplication.Documents.Open(oRefDoc.FullFileName, True) oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) -4) oDesc = oSTEPDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value ' On Error Resume Next 'Save as STEP oSTEPDoc.SaveAs(oFolder & "\" & oFileName & " " & oDesc & (".stp") , True) Call STEPTranslator.SaveCopyAs(oSTEPDoc, oContext, oOptions, oDataMedium) oRefDoc.Close On Error GoTo 0 End If Next MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") Shell("explorer.exe " & oFolder,vbNormalFocus) End Sub Sub ConfigureSTEPTranslatorSettings(ByRef STEPTranslator As TranslatorAddIn, ByRef oContext As TranslationContext, ByRef oOptions As NameValueMap, ByRef oDataMedium As DataMedium) oPath = ThisDoc.Path oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then ' Set application protocol. ' 2 = AP 203 - Configuration Controlled Design ' 3 = AP 214 - Automotive Design oOptions.Value("ApplicationProtocolType") = 3 ' Other options... 'oOptions.Value("Author") = "" 'oOptions.Value("Authorization") = "" 'oOptions.Value("Description") = "" 'oOptions.Value("Organization") = "" oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism ' Dim oData As DataMedium oDataMedium = ThisApplication.TransientObjects.CreateDataMedium oDataMedium.FileName = ThisDoc.PathAndFileName(False) & ".stp" oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oDataMedium) End If oDataMedium = ThisApplication.TransientObjects.CreateDataMedium End Sub
Can't find what you're looking for? Ask the community or share your knowledge.