Hi,
Is it possible to set parameter by name in linked model?
I want to set set value for all elements,not only for a certain category.
Hi,
Is it possible to set parameter by name in linked model?
How can I get certain parameter value of pipes from a linked file?
Hey I was able to edit family type parameters and instance type parameters in linked files using this graph and a few python scripts. Essentially it sets the instance parameters of all elements of a given type. The true false switch allows you to edit the type parameters of all family types in a given family. I’m not sure what you need to use it for but I was using it for window and door schedules. It should theoretically work for any built in category. Also make sure you read and understand the code before using it because it’s opening files in the background and then syncing with the link’s central model. If you’re not entirely sure how to apply this to your specific workflow, then don’t use the script cause it can seriously break your model if you don’t use it right.
I’ll comment the contents of the scripts separately in a different comments because its a bit lengthy to put it all here.
Here’s the code for the “Method Working” node:
# Load the Python Standard and DesignScript Libraries
import sys
import os
import clr
import time
clr.AddReference('ProtoGeometry')
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
clr.AddReference('RevitNodes')
clr.AddReference('System.Windows.Forms')
from Autodesk.Revit.DB import *
from Autodesk.DesignScript.Geometry import *
from RevitServices.Persistence import DocumentManager
from Autodesk.Revit.ApplicationServices import *
from RevitServices.Transactions import TransactionManager
#import Autodesk.Revit.UI
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
modelPath = IN[0]
familyName = IN[1]
familyType = IN[4]
value = IN[2]
paramIn = IN[3]
categoryIn = UnwrapElement(IN[5])
paramType = IN[6]
arglist = []
def asdf(modelPath, familyName, value, paramIn, strItr, categoryIn, paramType):
list = []
filtList = []
param = []
paramVal = []
filePath = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Documents\DoorScheduletet' + strItr + '.rvt')
if os.path.exists(filePath):
os.remove(filePath)
localPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath)
localFile = WorksharingUtils.CreateNewLocal(modelPath, localPath)
options = OpenOptions()
linkedDoc = app.OpenDocumentFile(localPath, options)
#elementS = FilteredElementCollector(linkedDoc).OfCategoryId(categoryIn).WhereElementIsElementType()
#for elem in elementS:
#list.append(UnwrapElement(elem))
if not paramType:
# get family types to edit
elementS = FilteredElementCollector(linkedDoc).OfCategoryId(categoryIn.Id).WhereElementIsElementType()
#unwrap the element types
for elem in elementS:
list.append(UnwrapElement(elem))
# filter familtypes given the input
for i in list:
if i.FamilyName == familyName:
filtList.Add(i)
if paramType:
elementS = FilteredElementCollector(linkedDoc).OfCategoryId(categoryIn.Id).WhereElementIsNotElementType().ToElements()
for elem in elementS:
list.append(UnwrapElement(elem))
for i in list:
if (i.Name == familyType) and (i.Symbol.FamilyName == familyName):
filtList.Add(i)
count = 0
argList = []
for i in filtList:
params = linkedDoc.GetElement(i.Id)
#param.Add(params)
pVal = params.LookupParameter(paramIn)
TransactionManager.Instance.EnsureInTransaction(linkedDoc)
try:
#Make change to type parameter
pVal.Set(IN[2])
except Exception,e:
#Maybe Throw an Error Message...
argList.Add(str(e))
TransactionManager.Instance.ForceCloseTransaction()
while linkedDoc.IsModifiable:
argList.append("Iteration stopped on" + str(count))
time.sleep(2)
if not linkedDoc.IsModifiable:
twc = TransactWithCentralOptions();
rOptions = RelinquishOptions(False);
rOptions.StandardWorksets = True
rOptions.ViewWorksets = True
rOptions.FamilyWorksets = True
rOptions.UserWorksets = True
rOptions.CheckedOutElements = True
swc = SynchronizeWithCentralOptions()
swc.SetRelinquishOptions(rOptions)
swc.SaveLocalBefore = True
swc.SaveLocalAfter = True
argList.Add(str(linkedDoc))
#swc.SetRelinquishOptions(rOptions);
linkedDoc.SynchronizeWithCentral(twc, swc)
argList.Add("Doc Synced")
time.sleep(2)
linkedDoc.Close(True)
count += 1
return argList
# implement the function in for loop
countL = []
i = 0
for model in IN[0]:
itr = str(i)
x = asdf(model, IN[1], IN[2], IN[3], itr, categoryIn, paramType)
countL.Add(x)
i+=1
countL.Add(i)
#listV.Add(pVal)
# Assign your output to the OUT variable.
# out values dont matter, just have these here to check their values
OUT = countL
Heres the code for the “GetLinkedDocs” node
# Load the Python Standard and DesignScript Libraries
import sys
import clr
import os
clr.AddReference('ProtoGeometry')
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
clr.AddReference('RevitNodes')
from Autodesk.Revit.DB import *
from Autodesk.DesignScript.Geometry import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
import Revit
clr.ImportExtensions(Revit.Elements)
filePath = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop')
print filePath
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
# Place your code below this line
doc = DocumentManager.Instance.CurrentDBDocument
category = BuiltInCategory.OST_RvtLinks
linkDoc = FilteredElementCollector(doc).OfCategory(category).WhereElementIsNotElementType().ToElements()
docs = []
docString = []
for i in linkDoc:
link = UnwrapElement(i).GetLinkDocument()
if not docs.Contains(link.GetWorksharingCentralModelPath()):
path = link.GetWorksharingCentralModelPath()
docs.Add(path)
docString.Add(ModelPathUtils.ConvertModelPathToUserVisiblePath(path))
OUT = docs