Export to RVT without dirtying the files

Export to RVT without dirtying the files

mat_hijs
Collaborator Collaborator
404 Views
2 Replies
Message 1 of 3

Export to RVT without dirtying the files

mat_hijs
Collaborator
Collaborator

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

 

0 Likes
405 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

This is likely not a solution, just an opinion, but I would think that the documents are likely getting their 'Dirty' flag raised at the points where you are creating the RevitExportDefinition and/or the RevitExport objects, because they are within the context of the AssemblyComponentDefinition.RevitExports.  I know that when you set the 'EnableUpdating' to True it will actually add a BrowserNode to your model browser, but when you set it to False, it won't create that node, so that seems like a 'changing the document' type of action, whether it is visible or not.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

mat_hijs
Collaborator
Collaborator

That's what I already figured out using some messageboxes to check when the file gets dirtied. I'm pretty sure I can't make the export without doing this, so I'm looking for some kind of way to do this, and somehow keep the files clean. Maybe if it's possible to undo this action after the export it won't be seen as dirty anymore?

0 Likes