TransmittedModelOptions Enumeration

Hi there, does anybody knows how to apply TransmittedModelOptions to a transmitted revit model when opening it? i had a bunch of transmitted model that requires to be opened and saved as central using that option. Any help is much appreciated

This is just a guess, but would you be able to open the document using the OpenDocumentFile method, detach it from central, and then save as central? I donā€™t see any parts of the API using this enumeration apart from the TransmittedModelExceptions class.

here is the snapshot of the API.


i tried using that method and it doesnt work :frowning:

@stillgotme Have a look below.

Hi @salvatoredragotta, sorry to say but the link you sent me is not of any use for this topic :frowning:

To give a better understanding, when i open a workshared transmitted model, a dialogue will appear as shown below:
image
Obviously i can do it manually to all my workshared transmitted model, but i was hoping that there is an API to do it and hence i will be able to batch do it. So i found the API as stated above

But i do not know where to use that enumeration in anywhere of the script.

I tried using opendocument file and save as central but its still give me the same result.

Since you are here, do you have any idea how to use that particular API??

@stillgotme can you share your dyn? Have you got a sample transmitted Revit file for testing?

Hold onā€¦

here is the sample transmitted file: Sample transmitted files.rvt (352 KB)

and i do not have a specific dyn for transmitted model cause i honestly have no idea where to start :slight_smile: but i can share with you my open and resave as central dyn:
Open and resave as central.dyn (8.1 KB)

I donā€™t often do this, but @erfajo (sorry Erik) or @john_pierson (sorry John) are probably the guys to helpā€¦ Orchid package has nodes for background opening and saving, and I think John was saying he was expanding the Rhythm functionality, but I donā€™t think either have what youā€™re after. Iā€™ve dug around in the API and canā€™t see anything youā€™ve missed.

Sorry,

Mark

1 Like

No apologies needed! :slight_smile:

My nodes do not include functionality for resaving as central, so I donā€™t think Rhythm solves this issue at the moment. If there is any questions regarding how my background document nodes work, Rhythm is open source and the code for Application is here, .

This dialogue is not showing up for me when a document is opened in the background.

Unfortunately, I think that is all of the help I have to offer right now. I do have some updates for Rhythm background document nodes coming, but they are more of a ā€œStability upgradeā€ as referenced in the thread here.

1 Like

Thanks John, you wonā€™t get the message until you open the fileā€¦

I think the OP needs the code to ā€˜save as new central file in same locationā€™ but the API doesnā€™t seem to give guidance on how that might be achieved?

It only defines the enumeration you would use in that method, not the method itself? Would you know where (if) that is squirreled away?

Cheers,

Mark

Ah I see, I missed that part. The new file would still have the property.

This should do it.

https://apidocs.co/apps/revit/2019/63f74ea4-079d-425a-cab6-427d7ea4f816.htm

Setting IsTransmitted to false on the newly saved as file via TransmissionData.

2 Likes

You are a gent :smiley:

1 Like

@john_pierson Does that mean that if i were to edit my another dyn (the one that i used transmission data to unload links without opening it), and set IsTransmitted(false), i will still get my central model with the rvt link that i had unloaded or changed path without the dialogue of saving as new central file?

And thank you @Mark.Ackerley for directing him to this topic :slight_smile:

1 Like

I think soā€¦ I have not had a chance to test myself, but that seems to be the way. I would say to give it a shot and let us know what happens. :grin:

I find some of the API really hard to work out from first principlesā€¦

When you read Transmission Data Class ā€˜A class representing information on all external file references in a document.ā€™

It really puts you off from thinking that it could be applicable to transmitted project files themselves.

right??? totally agree with you man

1 Like

Thanks for the files. Below my solution just for one file (Iā€™ll leave to you to loop for multiple files)

2 Likes

Hi @salvatoredragotta, so sorry to say. It does not transmit the data required when IsTransmitted(false) is setā€¦ it is required to be set to true

okay i got it to work from your concept. However the IsTransmitted=False has to be put after i save as central. below is the attached code if anyone is dealing with transmitted model:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.Attributes import*

import clr
clr.AddReference("RevitAPIUI")
from  Autodesk.Revit.UI import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System.Collections.Generic import *

# Import Revit Nodes
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

# Import python library
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import os
from System.IO import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

worksharingOptions = WorksharingSaveAsOptions()
worksharingOptions.SaveAsCentral = True

SaveOptions = SaveAsOptions()
SaveOptions.MaximumBackups = 50
SaveOptions.SetWorksharingOptions(worksharingOptions)
SaveOptions.OverwriteExistingFile = True
SaveOptions.Compact = True

rOptions = RelinquishOptions(False)
rOptions.StandardWorksets = True
rOptions.ViewWorksets = True
rOptions.FamilyWorksets = True
rOptions.UserWorksets = True
rOptions.CheckedOutElements = True

sOptions = SynchronizeWithCentralOptions()
sOptions.SetRelinquishOptions(rOptions)
sOptions.Compact = True
sOptions.SaveLocalBefore = True
sOptions.SaveLocalAfter = True

tOptions = TransactWithCentralOptions()

TransactionManager.Instance.ForceCloseTransaction()


filepaths = IN[0]

RVer = "R" + app.VersionNumber[-2:]

docpath = []

if IN[1] == True:
	try:
		for filepath in filepaths:
			file = FileInfo(filepath)
			filein = file.FullName
			modelpath = FilePath(filein)
			transData = TransmissionData.ReadTransmissionData(modelpath)
			if transData.IsDocumentTransmitted(modelpath):
				z = TransmittedModelOptions.SaveAsNewCentral
				newdoc = app.OpenDocumentFile(filepath)
				if RVer not in filepath:
					if "Central" in filepath:
						x = filepath.split("_")
						x.insert(len(filepath.split("_"))-1,RVer)
						y = "_".join(x)
					else:
						x = filepath[:-4]
						y = x + "_" + RVer + ".rvt"
				else:
					y = filepath
				newdoc.SaveAs(y,SaveOptions)			
				newdoc.SynchronizeWithCentral(tOptions,sOptions)
				newdoc.Close(True)
				docpath.append(y)
				transData.IsTransmitted = False
				TransmissionData.WriteTransmissionData(modelpath,transData)
			else:
				newdoc = app.OpenDocumentFile(filepath)
				if RVer not in filepath:
					if "Central" in filepath:
						x = filepath.split("_")
						x.insert(len(filepath.split("_"))-1,RVer)
						y = "_".join(x)
					else:
						x = filepath[:-4]
						y = x + "_" + RVer + ".rvt"
				else:
					y = filepath
				newdoc.SaveAs(y,SaveOptions)			
				newdoc.SynchronizeWithCentral(tOptions,sOptions)
				newdoc.Close(True)
				docpath.append(y)							
		OUT = [filepaths,docpath] 	
	except Exception,e:
		OUT = str(e)
else:
	OUT = "Please set it to true"

Huge thanks to @salvatoredragotta & @john_pierson & @Mark.Ackerley for your help :slight_smile:

3 Likes