Expose file location for raster images

Hi All,

I’ve been looking into reloading raster images during a server migration. I’ve found some info to reload raster images based on a link, however what I would like to do is expose the existing path, then run a modifier (lets say change drives from X: to Y: ) then re-link them.

The link location is not a parameter that’s exposed in the element parameters and raster images are not exposed in any node I’ve been able to find (these nodes expose CAD, RVT, IFC etc).

I think there will be a python way of doing this, however I have no experience in python.

Thanks in advance

Hey,

I think something like this should work…

#thanks to Nicklas Østertgaard  nvo@bimshark.com / nvo@shl.fk
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# 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 RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
collector = Autodesk.Revit.DB.FilteredElementCollector(doc)

imageTypes = collector.OfClass(Autodesk.Revit.DB.ImageType)

newDriveLetter = IN[0]
relinkedImages = []

for i in imageTypes:
	path = i.Path
	newPath = ("".join((path[:0],newDriveLetter,path[1:])))
	
	TransactionManager.Instance.EnsureInTransaction(doc)
	i.ReloadFrom(newPath)
	TransactionManager.Instance.TransactionTaskDone()
	
	relinkedImages.append(i)

OUT = relinkedImages

I can’t do the final bit without remaking the server path… But if I comment it out, the rest seems to work…

If you have a list of newDriveLetters we’d need to modify the code a bit.

Hope that’s useful,

Mark