From Document to filepath?

How can I continue my process after detaching a model?
I want to Open, detached, process, write to excel, close without saving

The node output of “Application.OpenDocumentFile” is a document, but the input to CAD.ReportInstances is a string. I haven’t found a solution or converter in different threads.

After excel file is written, I need to close the drawing “Applications.CloseDocument”, or don’t I?

CAD.ReportInstances doesn’t require a document, so I don’t understand why you even need to open the file in the first place. You should just be able to go straight to CAD.ReportInstances. Even if you need to open the document for something else it’s not needed for the CAD node, so just skip it.

You could also try getting the information without CAD.ReportInstances. You can get imports using the Element Types and All Elements of Type nodes.

3 Likes

My objectif is to be able to open the rvt files to close all worksets, which gives me faster processing of the model afterwards. If I don’t do this and stick it directly into CAD.ReportInstances, it takes way longer because its looking up all the rvt links. If it takes me less time to open the models in detach and do my process manually, I don’t see the point in using a dynamo graph, since it’s taking more time than saving some. 1 model can have ~12 rvt links on different worksets and I have ~66 models to check.

I’ll also try your suggestion and get back with results.

Understandable, but I don’t think it makes a difference in this situation unfortunately. If you’re opening the model detached then you’re not making any changes to the file (at that filepath) anyway. Your best bet seems to be getting the import instances directly from the document with other nodes. (Archilab and Rhythm should have nodes to help.)

1 Like

Hi @Jonathan_Roy

Are you Python savvy? Because although I’m not familiar with CAD.ReportInstances I had a similar problem where I wanted to background open models without links loaded.

What I did was take the models from a folder, read the transmission data, got the external references (links) ids, iterated through the links and set the desired reference data which changes the “Should load?” status of each link, then I wrote that transmission data to the model path and this opened the file without loading it’s links.

Here is my very scrappy Python code, your rvtFilesNotBackups would be a list of all the models you want to process.

modelPath = [ModelPathUtils.ConvertUserVisiblePathToModelPath(x) for x in rvtFilesNotBackups]


for path in modelPath:

	
transData = TransmissionData.ReadTransmissionData(path)

extReferences = transData.GetAllExternalFileReferenceIds()
newLinkPath = FilePath(ModelPathUtils.ConvertModelPathToUserVisiblePath(path))

for linkRef in extReferences:
	ext = transData.GetLastSavedReferenceData(linkRef )
	if ext.GetLinkedFileStatus() == LinkedFileStatus.Loaded:
		try:
			transData.SetDesiredReferenceData(linkRef ,path, PathType.Absolute,False)
			TransmissionData.WriteTransmissionData(path,transData)
		except:
			errorList.append(['Transmission Data Error with: '+str(newLinkPath)])

openDoc = app.OpenDocumentFile(path,openOption)

Then I went on and performed whatever I wanted to on my open document.

Hope this helps somehow?

Cheers, Pete