Help with saving copy as iges or step of part within assembly

Help with saving copy as iges or step of part within assembly

dschulteHR4D5
Advocate Advocate
3,011 Views
47 Replies
Message 1 of 48

Help with saving copy as iges or step of part within assembly

dschulteHR4D5
Advocate
Advocate

Hello all, I am looking for some assistance with iLogic coding... Let me try to explain what i am looking for here, bear with me.

 

For my workflow, i am designing one-off tooling that trims plastic blow molded parts. We have an in house tool room where we design and build most of the tooling we use. With that being said, we build some of the parts, some times some of them get sent out to other companies to build then we assemble depending on the job. 

 

So i will design an entire project for say a trim station, and the parts we build i will save as an igs for our cnc department to use. Then some of the companies need the files as a stp and the drawings as a dxf. 

 

What i am trying to do essentially is take the entire assembly, and hide the parts i do not want to convert to say an iges. But when i use this code it saves everything in the assembly, and i believe it saves assemblies within the assembly as an iges as well, whereas i want each individual part saved as an iges, not the whole assembly. So it seems i need to add something to recognize only visible items, and to only select parts, not assemblies within the assembly. Is this possible? This is the current code i am using right now. 

 

'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document


'path from current file
oFolder = ThisDoc.WorkspacePath() & "\CNC FILES"

 'Check for the destination folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
    System.IO.Directory.CreateDirectory(oFolder)
End If

'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments                
'format  file name                   
Dim FNamePos As Long
'postion of last back slash
FNamePos = InStrRev(docFile.FullFileName, "\", -1)                        
Dim docFName As String 
'file name with extension
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 
'file name without extension
shortname = Left(docFName, Len(docFName) -4) 

	' Get the IGES translator Add-In.
	Dim oIGESTranslator As TranslatorAddIn
	oIGESTranslator = ThisApplication.ApplicationAddIns.ItemById _ 
	("{90AF7F44-0C01-11D5-8E83-0010B541CD80}")
	Dim oContext As TranslationContext
	oContext = ThisApplication.TransientObjects.CreateTranslationContext
	Dim oOptions As NameValueMap
	oOptions = ThisApplication.TransientObjects.CreateNameValueMap
	If oIGESTranslator.HasSaveCopyAsOptions(docFile, oContext, oOptions) Then
	   ' Set geometry type for wireframe.
	   ' 0 = Surfaces, 1 = Solids, 2 = Wireframe
	   'oOptions.Value("GeometryType") = 1
	   ' To set other translator values:
	   ' oOptions.Value("SolidFaceType") = n
	   ' 0 = NURBS, 1 = Analytic
	   ' oOptions.Value("SurfaceType") = n
	   ' 0 = 143(Bounded), 1 = 144(Trimmed)
	oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
	Dim oData As DataMedium
	oData = ThisApplication.TransientObjects.CreateDataMedium
	'set file path for IGS file
	oData.FileName =  oFolder & "\" & shortname & ".igs"
	oIGESTranslator.SaveCopyAs(docFile, oContext, oOptions, oData)
	End If
Next

 This code also checks and makes a folder for CNC FILES if there isnt one there, as mentioned, i use this for our CNC department so it works, but it seems like it saves subassemblies as one igs file, and not the individual parts within a subassembly. 

 

Also i would like to map out how to reference if i translate to an step file, to find a reference drawing of that part and also save the drawing as a dxf if this would be possible. 

 

Thanks for any help!! Ill take anything i can get for knowledge of this, i am pretty new to ilogic but have made this code from cross referencing a number of posts and different codes and eventually got it to work. 

0 Likes
Accepted solutions (4)
3,012 Views
47 Replies
Replies (47)
Message 41 of 48

dschulteHR4D5
Advocate
Advocate
in this part is where i am trying to add the name, if it finds a drawing file it opens, and continues on, if not, add the name to the list. which so far has been working, but only getting it to work to output the names on an inputbox, and ill have to look that over and see, i have an idea of what you are talking about but i feel like we might be on a different page, maybe? the parts list that is already setup i believe checks the parts so it doesnt go over the same one multiple times, which i have noticed it doesn't save as or anything else, but it will pull up multiple names on a list, or before i was having it prompt a message if it found a component without a drawing file, and if i had say 5 bolts with no print, it would prompt each time to say it didnt find one, so maybe thats where that is coming from, so ill have to play with that part of it. as far as i know the partslist in the iterate sub is only checking for duplicates, the list i am trying to get is a list of the components names that the code did not find a drawing file for, right now in the arraylist below is where it is getting the names. i will play with this some tonight at work when i get some time as see what i can come up with.

'Find referenced IDW and continue save as process'
Function GetDrawing(oModelDoc As Document) As DrawingDocument
oWSPath = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
Dim oDrawingsFolder As String = oWSPath & "\DRAWINGS"
oFileName = System.IO.Path.GetFileNameWithoutExtension(oModelDoc.FullFileName)
Dim oDrawingFile As String = oDrawingsFolder & "\" & oFileName & ".idw"
'Reference IDW but don't open'
If System.IO.File.Exists(oDrawingFile) Then
Dim oDrawingDoc As DrawingDocument = ThisApplication.Documents.Open(oDrawingFile, False)
Return oDrawingDoc
Else

------------myArrayList.Add(oFileName)


End If
Return Nothing
End Function
0 Likes
Message 42 of 48

dschulteHR4D5
Advocate
Advocate

2022-07-26.png

 also you are talking about the oprocceseddocs, i feel like i know what you mean with this, but i dont know how to arrange them, me reading this, seems to make sense, if then processeddocs = new list, and then if oprocesseddocs.contains(opdoc) then continue for

im not sure how this could be wrong, i can move the dim oprocesseddocs within this sub, but i will have to post back on this after i play with this part of it, not sure how to manage moving these if they are not correct

0 Likes
Message 43 of 48

dschulteHR4D5
Advocate
Advocate

.

0 Likes
Message 44 of 48

WCrihfield
Mentor
Mentor

Hi @dschulteHR4D5.  As I tried to explain before, there was nothing wrong with your existing lines of code concerning the 'oProcessedDocs' variable which is representing a List(Of PartDocument), or the locations of those lines of code.  Declaring that variable outside of the Subs is the right way to go, because that allows it to be shared, and the Sub that iterates the components may be ran through several times (due to being 'recursive'), and we do not want to re-create a new List each time that Sub runs.  What was missing though, was an additional line of code near the end of that recursive Sub that adds the PartDocument to the oProcessedDocs List after we have processed it (or at least attempted to process it).  Once it gets added to the list, then the earlier line of code that checks if it is in the list, may actually find it in there, allowing it to skip attempting to process it again.  Without that extra line of code, if it encounters multiple components that represent the same PartDocument, it will try to process it again, because it did not know that it had already been processed.

 

Here is a slightly edited version of your 'IterateComponentsRecursively' Sub, in which I have added the extra line of code...and several new lines of comments, just to be thorough.  With this new version of the Sub, it is expecting that the oProcessedDocs variable has already been declared outside of the Sub.

Dim oProcessedDocs As List(Of PartDocument)
Sub IterateComponentsRecursively(oComps As ComponentOccurrences)
	If IsNothing(oComps) OrElse oComps.Count = 0 Then Exit Sub
	'initialize the List(Of PartDocument) if it has not already been initialized
	'when initialized (using New), variable's Value will no longer be Nothing, but List will not contain any items yet)
	'if previously initialized (using New), the List may already contain items, so don't re-create the List
	If IsNothing(oProcessedDocs) Then oProcessedDocs = New List(Of PartDocument)
	For Each oComp As ComponentOccurrence In oComps
		'Only process Visible components'
		If oComp.Visible = False Then Continue For
		'If component is Visible, and an Assembly, recursively process its components'
		If oComp.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			IterateComponentsRecursively(oComp.Definition.Occurrences)
		End If
		'Make sure it is a Part'
		If oComp.DefinitionDocumentType <> DocumentTypeEnum.kPartDocumentObject Then Continue For
		If Not TypeOf oComp.Definition Is PartComponentDefinition Then Continue For
		Dim oPDoc As PartDocument = oComp.ReferencedDocumentDescriptor.ReferencedDocument
		'If we have already processed this referenced document, skip to next component
		'(this next line will only work properly if you are adding the PartDocument to the List after 'processing' it)
		If oProcessedDocs.Contains(oPDoc) Then Continue For
		Dim oFileName As String = System.IO.Path.GetFileNameWithoutExtension(oPDoc.FullFileName)
		'export Part as STEP file
		Dim oSTEPFullFileName As String = oSTEPFilesFolder & "\" & oFileName & ".stp"
		ExportToSTEP(oPDoc, oSTEPFullFileName)
		'Find component referenced drawing file
		Dim oDrawDoc As DrawingDocument = GetDrawing(oPDoc)
		If Not IsNothing(oDrawDoc) Then
			'Export referenced IDW to DXF and PDF
			Dim oDXFFullFileName As String = oDXFFilesFolder & "\" & oFileName & ".dxf"
			ExportIDWtoDXF(oDrawDoc, oDXFFullFileName)
			Dim oPDFFullFileName As String = oPDFFilesFolder & "\" & oFileName & ".pdf"
			ExportIDWtoPDF(oDrawDoc, oPDFFullFileName)
		End If
		'now that this PartDocument has been 'processed', add it to the List(Of PartDocument)
		'so that it will be found in our check above and will not be processed again
		oProcessedDocs.Add(oPDoc)
	Next
End Sub

That should help eliminate the same document getting listed multiple times.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 45 of 48

dschulteHR4D5
Advocate
Advocate

.

0 Likes
Message 46 of 48

dschulteHR4D5
Advocate
Advocate

.

0 Likes
Message 47 of 48

dschulteHR4D5
Advocate
Advocate

OKAY

So again sorry for all the back and forth on this, again , BUT, i had A LOT of time this weekend to experiment and test some things out, so i think i have successfully figured it out. I ended up finding a thread you were commenting on, using a message box to return a boolean value, so after alot of trial and error i got it to work that way. If you could maybe skim over it, and see if you see anything wrong with it, as far as i can tell across the couple smaller assemblies i have tested it on, it seems to work 100%, and now the code steps through a yes no process, asking if you want to save each found component with a referenced IDW, and also to print, if yes to print it goes through the print settings, if print settings are incorrect and NO is selected cancels the whole rule. If yes on any of the save as variables, creates the needed folder and continues, and ANY visible component found without an IDW, it will add the name to a list at the end.

 

----------------------IM SO EXCITED, AND THANK YOU SO MUCH FOR THE HELP!!!!!! If you see anything that should be added, or any kind of fail proofing or anything that would help let me know.

 

*EDIT, if and when you get a moment, i have been trying to get this same code to work, but from a part file instead of assembly.. Say for example the code is ran and batch sent all the needed files, later on i find a missing hole on a part, so now i need a new STP, and new drawing, i would like to set this same rule, but only run from one part, having a hard time getting the code to recognize the reference drawing from the component i think, something isnt communicating properly. But essentially i would change each of the save as parameters so save over an existing instead of exiting sub. If you could work the definition into finding the reference drawing instead of doing it from as assembly that would be great.

 

Full working code with all the Yes No variables

 

Sub Main
	
	'Rule only finds visible components within main assembly that have a referenced IDW, so will only process a file if an IDW of a visible component is found
	'If sub-assembly is found, only finds visible components from the default saved assembly of said sub-assembly, can set visibily and save assembly of needed components
	'If no referenced IDW is found for any visible component, add name to list and export list to Notepad
	'Export list is to verify if a needed component was missed that needs an IDW and export
	'If export file is found with the same name, skip save as process of component and or IDW
	'Due to this rule only finding visible components and their referenced drawings, it will not print or export any assembly files or IDWs
'This rule expects the reference IDWs are in "DRAWINGS" folder in the root workspace folder of the project 'dschulte 07/31/2022 'Make sure ASM document is active' If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "") Exit Sub End If 'Set export file paths Dim oWSPath As String = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath oSTEPFilesFolder = oWSPath & "\STEP FILES" oPDFFilesFolder = oWSPath & "\PDF FILES" oDXFFilesFolder = oWSPath & "\DXF FILES" 'Yes or No selection to save as and print 'If yes, create folder for each export, and prompt to verify printer settings 'If System Printer Settings are incorrect and select No, will cancel the rule all together STP = MessageBox.Show("Would you like to create a .STP for every visible component?", "Create .STP?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) If STP = vbNo Then oSTP = True Else System.IO.Directory.CreateDirectory(oSTEPFilesFolder) End If PDF = MessageBox.Show("Would you like to create a .PDF of each reference drawing?", "Create .PDF?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) If PDF = vbNo Then oPDF = True Else System.IO.Directory.CreateDirectory(oPDFFilesFolder) End If DXF = MessageBox.Show("Would you like to create a .DXF of each reference drawing?", "Create .DXF?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) If DXF = vbNo Then oDXFF = True Else System.IO.Directory.CreateDirectory(oDXFFilesFolder) End If PRINTS = MessageBox.Show("Would you like to print each IDW?", "Create PRINT?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) If PRINTS = vbNo Then oPRINT = True Else PrintSetup(Setup) End If If oPrintSettings = True Then Exit Sub End If Dim oADoc As AssemblyDocument = ThisDoc.Document 'Loop through visible components and define the save as criteria' oOccs = oADoc.ComponentDefinition.Occurrences IterateComponentsRecursively(oOccs) 'Show number of found referenced drawings MessageBox.Show ("There were " & numFiles & " referenced drawings found."," Job Complete ") 'Close any referenced documents' ThisApplication.Documents.CloseAll(True) 'Open workspace folder' ThisDoc.Launch(ThisDoc.WorkspacePath) 'Export list of missing IDWs to text' WriteListOfStringsToTextFile(oNames) End Sub Sub PrintSetup(Setup) 'Show default printer and print settings Dim oPrintMgr As PrintManager = ThisApplication.ActiveDocument.PrintManager If MsgBox("Using Printer " & oPrintMgr.Printer & ", Letter Size, 1:1 Scale, Landscape Mode." _ & vbLf & " " _ & vbLf & " Do you want to continue?" _ , vbYesNo + vbQuestion, "System Printer Settings ") = vbNo Then oPrintSettings = True End if If oPrintSettings = True Then Exit Sub End If 'Determine if the prints should be in color or black and white oColorAsBlack="False" RUsure = MessageBox.Show ( "Do you want to print in COLOR?"& vbLf & "", "Color or B/W Prints",MessageBoxButtons.YesNo) If RUsure = vbNo Then oColorAsBlack="True" : Else: End If End Sub 'Write list of missing IDWs to text' Sub WriteListOfStringsToTextFile(oStrings As List(Of String)) 'write List contents (Strings) to a Text file Dim oTxtFile As String = "C:\Temp\MISSINGS IDWs.txt" Dim oWriter As System.IO.StreamWriter = System.IO.File.CreateText(oTxtFile) For Each oString In oStrings oWriter.WriteLine(oString) Next oWriter.Close ThisDoc.Launch(oTxtFile) End Sub Dim oSTEPFilesFolder As String Dim oDXFFilesFolder As String Dim oPDFFilesFolder As String Dim oNames As New List(Of String) Dim oProcessedDocs As List(Of PartDocument) Dim numFiles As Integer = 0 Dim oSTP As Boolean = False Dim oPDF As Boolean = False Dim oDXFF As Boolean = False Dim oPRINT As Boolean = False Dim oPrintSettings As Boolean = False Sub IterateComponentsRecursively(oComps As ComponentOccurrences) If IsNothing(oComps) OrElse oComps.Count = 0 Then Exit Sub 'initialize the List(Of PartDocument) if it has not already been initialized 'when initialized (using New), variable's Value will no longer be Nothing, but List will not contain any items yet) 'if previously initialized (using New), the List may already contain items, so don't re-create the List If IsNothing(oProcessedDocs) Then oProcessedDocs = New List(Of PartDocument) For Each oComp As ComponentOccurrence In oComps 'Only process Visible components' If oComp.Visible = False Then Continue For 'If component is Visible, and an Assembly, recursively process its components' If oComp.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then IterateComponentsRecursively(oComp.Definition.Occurrences) End If 'Make sure it is a Part' If oComp.DefinitionDocumentType <> DocumentTypeEnum.kPartDocumentObject Then Continue For If Not TypeOf oComp.Definition Is PartComponentDefinition Then Continue For Dim oPDoc As PartDocument = oComp.ReferencedDocumentDescriptor.ReferencedDocument 'If we have already processed this referenced document, skip to next component '(this next line will only work properly if you are adding the PartDocument to the List after 'processing' it) If oProcessedDocs.Contains(oPDoc) Then Continue For Dim oFileName As String = System.IO.Path.GetFileNameWithoutExtension(oPDoc.FullFileName) Dim oWSPath As String = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath 'Find component referenced drawing file Dim oDrawDoc As DrawingDocument = GetDrawing(oPDoc) If Not IsNothing(oDrawDoc) Then numFiles = numFiles + 1 Dim oSTEPFullFileName As String = oSTEPFilesFolder & "\" & oFileName & ".stp" ExportToSTEP(oPDoc, oSTEPFullFileName) If oPRINT = False Then PrintIDW(oDrawDoc) Else End If Dim oDXFFullFileName As String = oDXFFilesFolder & "\" & oFileName & ".dxf" ExportIDWtoDXF(oDrawDoc, oDXFFullFileName) Dim oPDFFullFileName As String = oPDFFilesFolder & "\" & oFileName & ".pdf" ExportIDWtoPDF(oDrawDoc, oPDFFullFileName) oDrawDoc.Close(True) End If 'now that this PartDocument has been 'processed', add it to the List(Of PartDocument) 'so that it will be found in our check above and will not be processed again oProcessedDocs.Add(oPDoc) Next End Sub Sub PrintIDW(oDrawing As DrawingDocument) oDrawing.Activate oDrawing.Save oDrgPrintMgr = oDrawing.PrintManager oDrgPrintMgr.AllColorsAsBlack = oColorAsBlack oPrintMgr = ThisApplication.ActiveDocument.PrintManager oPrintMgr.PrintRange = kPrintAllSheets 'Prints all sheets in the idw. oPrintMgr.NumberOfCopies = 1 ' Set to print one copies. oPrintMgr.PaperSize = kPaperSizeCustom oPrintMgr.PaperHeight = 27.94 '11.0 in oPrintMgr.PaperWidth = 21.59 '8.5 in oPrintMgr.Scalemode = 13825 'Full Scale print @1:1 oPrintMgr.SubmitPrint ' Submit the print. End Sub 'Export to STP sub' Sub ExportToSTEP(oDoc As Document, oNewFileName As String) If oSTP = True Then : Exit Sub : End If Dim oSTEP As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById( _ "{90AF7F40-0C01-11D5-8E83-0010B541CD80}") If IsNothing(oSTEP) Then MsgBox("STEP Translator Add-in not found. Exiting.", vbCritical, "") 'Logger.Debug("STEP Translator Add-in not found.") Exit Sub End If 'Create needed variables for translator' oTO = ThisApplication.TransientObjects oContext = oTO.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = oTO.CreateNameValueMap oDataMedium = oTO.CreateDataMedium 'Exit sub if file extension exists otherwise continue save as process" If System.IO.File.Exists(oNewFileName) Then Exit Sub End If oDataMedium.FileName = oNewFileName If oSTEP.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then ' Set application protocol. ' 2 = AP 203 - Configuration Controlled Design ' 3 = AP 214 - Automotive Design 'oOptions.Value("ApplicationProtocolType") = 3 'oOptions.Value("IncludeSketches") = True 'oOptions.Value("export_fit_tolerance") = .000393701 'minimum 'oOptions.Value("Author") = ThisApplication.GeneralOptions.UserName 'oOptions.Value("Authorization") = "" 'oOptions.Value("Description") = iProperties.Value("Summary", "Title") 'oOptions.Value("Organization") = iProperties.Value("Summary", "Company") Try oSTEP.SaveCopyAs(oDoc, oContext, oOptions, oDataMedium) Catch MsgBox("Your attempt to export this document as a STEP file FAILED!", vbExclamation, "Export to STEP Error") 'Logger.Error("Export to STEP failed.") End Try End If End Sub 'Find referenced IDW and continue save as process' Function GetDrawing(oModelDoc As Document) As DrawingDocument oWSPath = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath Dim oDrawingsFolder As String = oWSPath & "\DRAWINGS" oFileName = System.IO.Path.GetFileNameWithoutExtension(oModelDoc.FullFileName) Dim oDrawingFile As String = oDrawingsFolder & "\" & oFileName & ".idw" 'Reference IDW, needs to open to be able to print' If System.IO.File.Exists(oDrawingFile) Then Dim oDrawingDoc As DrawingDocument = ThisApplication.Documents.Open(oDrawingFile, True) Return oDrawingDoc Else 'Add name of component with no IDW to list' oNames.Add(oFileName) End If Return Nothing End Function 'Start IDW to DXF' Sub ExportIDWtoDXF(oDrawing As DrawingDocument, oNewFullFileName As String) If oDXFF = True Then : Exit Sub : End If Dim oDXF As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}") If IsNothing(oDXF) Then MsgBox("DXF Translator Add-in not found. Exiting.", vbCritical, "") 'Logger.Debug("DXF Translator Add-in not found.") Exit Sub End If 'Create needed variables for translator' oTO = ThisApplication.TransientObjects oContext = oTO.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = oTO.CreateNameValueMap oDataMedium = oTO.CreateDataMedium 'Exit sub if file extension exists otherwise continue save as process" If System.IO.File.Exists(oNewFullFileName) Then Exit Sub End If oDataMedium.FileName = oNewFullFileName '<<<< CHANGE THIS IF NEEDED, INI FILE CONFIGURATION LOCATION >>>>' Dim oINI_File As String = "C:\Users\Public\Documents\Autodesk\Inventor 2021\Design Data\DWG-DXF\exportdxf.ini" If Not System.IO.File.Exists(oINI_File) Then MsgBox("Couldn't find this INI file: " & oINI_File & ". Exiting.", vbExclamation, "") Exit Sub End If 'Set save as options' If oDXF.HasSaveCopyAsOptions(oDrawing, oContext, oOptions) Then oOptions.Value("Export_Acad_IniFile") = oINI_File End If Try oDXF.SaveCopyAs(oDrawing, oContext, oOptions, oDataMedium) Catch oEx As Exception MsgBox("SaveCopyAs method of the ExportIDWtoDXF Sub routine failed." & vbCrLf & _ "While trying to export the following Drawing file: " & vbCrLf & _ oDrawing.FullFileName & vbCrLf & _ "as the following dxf file: " & vbCrLf & _ oNewFileName & vbCrLf & _ oEx.Message & vbCrLf & oEx.StackTrace, vbExclamation, "") 'Logger.Error(oEx.Message & vbCrLf & oEx.StackTrace) oDrawing.ReleaseReference End Try End Sub 'Start IDW to PDF' Sub ExportIDWtoPDF(oDrawing As DrawingDocument, oNewFullFileName As String) If oPDF = True Then : Exit Sub : End If 'get the PDF Translator Add-in Dim oPDFAddin As TranslatorAddIn For Each oAddin As ApplicationAddIn In ThisApplication.ApplicationAddIns If oAddin.DisplayName = "Translator: PDF" Then oPDFAddin = oAddin End If Next 'Create the variables needed by the Translator Add-in oTO = ThisApplication.TransientObjects oContext = oTO.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = oTO.CreateNameValueMap oDataMedium = oTO.CreateDataMedium oDataMedium.FileName = oNewFullFileName 'Exit sub if file extension exists otherwise continue save as process" If System.IO.File.Exists(oNewFullFileName) = True Then Exit Sub End If oDataMedium.FileName = oNewFullFileName 'The following If-Then statement defines the Options available, and their Values. If oPDFAddin.HasSaveCopyAsOptions(oDrawing, oContext, oOptions) Then oOptions.Value("Publish_All_Sheets") = 1 ' 0 = False, 1 = True 'oOptions.Value("Sheet_Range") = PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 1 'oOptions.Value("Custom_End_Sheet") = 4 oOptions.Value("All_Color_AS_Black") = 0 ' 0 = False, 1 = True oOptions.Value("Vector_Resolution") = 720 '150, 200, 400, 600, 720, 1200, 2400, 4800 ' DPI oOptions.Value("Remove_Line_Weights") = 0 ' 0 = False, 1 = True oOptions.Value("Launch_Viewer") = 1 ' 0 = False, 1 = True End If 'Publish PDF oPDFAddin.SaveCopyAs(oDrawing, oContext, oOptions, oDataMedium) End Sub

 

0 Likes
Message 48 of 48

dschulteHR4D5
Advocate
Advocate

Okay so, if someone could test this out for me, comb it over, see what you think, this is a mass export batch rule, seems to work so far for me, i have it configured to prompt yes/no to save found components as STP  IGS, and to print their IDW, save as PDF, DXF, and DWG. I am pretty proud of it but am looking to see if there is anything missing, and maybe someone else could find this useful?

0 Likes