Message 1 of 3
Export to RVT without dirtying the files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I made a rule that exports all unique subassemblies in my main assembly to RVT files. It works perfectly, but one thing is still bothering me, after running this rule and exporting all the files I have to save all my files again.
Is there a way to do this without dirtying the files?
Here's my rule:
' Set a reference to the main assembly document Dim oMainAsmDoc As AssemblyDocument oMainAsmDoc = ThisDoc.Document ' Set a reference to the main assembly document component definition Dim oMainAsmCompDef As AssemblyComponentDefinition oMainAsmCompDef = oMainAsmDoc.ComponentDefinition ' Create a new array list Dim oFilesList As New ArrayList ' Set a reference to progress bar Dim oStep As Integer = 1 Dim oSteps As Integer = oMainAsmCompDef.Occurrences.Count Dim oProgressBar As Inventor.ProgressBar = ThisApplication.CreateProgressBar(False, oSteps, "Batch Export to RVT", True) oProgressBar.Message = "Starting process..." ' Go through every component within the main assembly document For Each oOcc As ComponentOccurrence In oMainAsmCompDef.Occurrences ' Update process bar message oProgressBar.Message = "Occurrence " & oStep & " Of " & oSteps & ": " & oOcc.Name ' Set a reference to the document referenced by the occurrence Dim oSubDoc As Document oSubDoc = oOcc.ReferencedDocumentDescriptor.ReferencedDocument ' Check if the document referenced by the occurrence is an assembly document If oSubDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then ' Check if the file is not already exported If oFilesList.Contains(oSubDoc.FullFileName) = False Then oFilesList.Add(oSubDoc.FullFileName) Logger.Info("New assembly: " & oSubDoc.FullFileName) ' Set a reference to the subassembly document Dim oSubAsmDoc As AssemblyDocument oSubAsmDoc = oSubDoc ' Set a reference to the subassembly document component definition Dim oSubAsmCompDef As AssemblyComponentDefinition oSubAsmCompDef = oSubAsmDoc.ComponentDefinition ' Create revit export definition Dim oRevitExportDef As RevitExportDefinition oRevitExportDef = oSubAsmCompDef.RevitExports.CreateDefinition oRevitExportDef.Location = "C:\Temp" oRevitExportDef.FileName = oSubAsmDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value & ".rvt" oRevitExportDef.ActiveDesignViewRepresentation = "Default" oRevitExportDef.IsAssociativeDesignView = True oRevitExportDef.Structure = kEachTopLevelComponentStructure oRevitExportDef.UseColorOverrideFromSourceComponent = False oRevitExportDef.EnableUpdating = False ' Create revit export Dim oRevitExport As RevitExport oRevitExport = oSubAsmCompDef.RevitExports.Add(oRevitExportDef) Logger.Info("New export: " & oSubDoc.FullFileName) Else Logger.Info("Existing export: " & oSubDoc.FullFileName) End If Else Logger.Info(oOcc.Name & " is not an assembly document") End If oProgressBar.UpdateProgress oStep = oStep + 1 Next ' Close process bar oProgressBar.Message = "Process Finished" oProgressBar.Close