Message 1 of 5
Batch Saving model to IDW or inventor dwg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have used this code to successfully to create rules to batch save step files and dwg files (AutoCAD) but I really want inventor dwg's . I have simply changed out .stp to .dwg which has worked but if I do .idw I get a parameter error.
Format:HTML Format
Version:1.0
StartHTML: 165
EndHTML: 26203
StartFragment: 314
EndFragment: 26171
StartSelection: 314
EndSelection: 314
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.", "Batch DRAWING File Creation")
Exit Sub
End If
'get user input
RUsure = MessageBox.Show ( _
"This will create a DRAWING file for all components." _
& vbLf & " " _
& vbLf & "Are you sure you want to create DRAWING file for all of the assembly components?" _
& vbLf & "This could take a while.", "Confirm - Batch DRAWING File Creation ",MessageBoxButtons.YesNo)
If RUsure = vbNo Then
Return
Else
End If
'- - - - - - - - - - - - -STEP setup - - - - - - - - - - - -
oPath = ThisDoc.Path
'get DRAWING target folder path
oFolder = oPath & "\DRAWING FILES\"
'Check for the drawing 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 Export- - - - - - - - - - - -
oTime = Now.ToString("HH:mm:ss")
ThisDoc.Document.SaveAs(oFolder & oAsmName & (".idw"), 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
If oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kNormalBOMStructure Then
'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 & ("idw") , True)
Catch
MessageBox.Show("Error processing " & oCurFileName, "DRAWING File Creation Error")
End Try
End If
oCurFile.Close
Next
'- - - - - - - - - - - - -
MessageBox.Show("New Files Created in: " & vbLf & oFolder, "Batch DRAWING File Creation")
'open the folder where the new files are saved
Shell("explorer.exe " & oFolder,vbNormalFocus)
Is there a way of specifying?
Many thanks
Tracey P
(Thnk you to the creator of this code by the way. I don't know who you are but found the code from someone who also used it.)