From Directory Open / Remove all DWG links / Reload all RVT links / Save as Central

Hi !

I am trying to open a series of files which have been copied into a new folder. I need to remove all linked DWGs (or remove everything which is not a RVT), reload all RVTs links (all files will be located in the new directory), and then save each file as a Central.

I saw Links - "Reload From..." and tried to pick up the script but I am having trouble connecting the additional steps.

Help!
(and thanks :slight_smile: )

1 Like

** for record the python script is as below (& from @Nick_Boyts);

#python nodes in dynamo 1.0.0
#originally by 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)
linkInstances = collector.OfClass(Autodesk.Revit.DB.RevitLinkInstance)
folderpath = IN[0]
reloadedlinks = []
for i in linkInstances:
name = i.Name
path = folderpath + “\” + name
path = path.rsplit(’ : ',2)[0]
filepath = FilePath(path)
RevitLinkType = doc.GetElement(i.GetTypeId())
RevitLinkType.LoadFrom(filepath,None)
reloadedlinks.append(RevitLinkType)
OUT= reloadedlinks

Hi,

I made a package to interact with Revit documents in directory.
His name is Genius Loci and some nodes can help you reach your goal :

@Alban_de_Chasteigner remember to give credit where credit is due…

The nodes are actually made by a bunch of other Authors…

@Dimitar_Venkov, @Nick_Boyts, @Einar_Raknes, @Ben_Osborne

1 Like

Hi Jonathan,

Thank you for the credits, I actually responded too quickly.

I actually modified some nodes to work without the current document and used forum scripts to make them into custom nodes.
As you know, customs nodes have some advantages like lacing or levels.

I hope that the way the original code is attributed to the authors is quite clear.
Delete


If this displeases them, I will find another way to distribute the custom nodes within my company than the package.
I am not trying to assign myself the code of other people, on the contrary I learned everything by looking at how they coded and I think I have given my time back to help members of the community.

Cheers,

2 Likes

Hi @Alban_de_Chasteigner - thanks for your help!!

Any notion why the Delete Elements from document might not be accepting element IDs (DWGs) in this case?
I seem to only get nulls…

Does it make a difference if the DWGs are loaded / unloaded?

Thanks!!

Hi,

It’s working for me with ImportInstances and there is no difference if the tDWGs ar loaded or unloaded.

Delete%20CAD%20from%20document

@Alban_de_Chasteigner

I realized my mistake - I was trying to process the filepath rather than the document :stuck_out_tongue:

Does the ‘Elements Delete from document’ node not accept lists?
Capture Unload.DWGs.Multi.dyn (28.4 KB)

Hi,

Don’t forget to set lacing on Longest on the node Delete Elements :

@Alban_de_Chasteigner thank you!!!
:smiley: