Set Worksets from a Shared Parameter

Hmm… Any chance you already have a workset which uses one of the names you are providing (ie: you ran the graph a second time after creating the worksets but failing to set the element’s workset?)

So this shouldn’t be the issue. When a Workset already exist the node gives me a warning, but the Worksets still get created.

@AlexiMonge1987
Is the model on a network or in a cloud?
Are there maybe warnings in the Workset Create node when you open it (depends on the node you are using if you can open it)

Did you also try a Workset Create from a different Package (i.e. Archilab or GeniusLoci?).

image

It seems that you need to work on the logic which should follow this process.

  1. Check the project file is a central file, and proceed if it is.
  2. Get all worksets in current model
  3. Get all elements and check what the workset should be called
  4. Compare the current worksets vs what is needed from elements
  5. Any not in the current workset list then you create them
  6. Get the right workset for each element
  7. Apply the workset onto the correct element

@Brendan_Cassidy

Currently it seems OP isn’t able to create a Workset to begin with.

Also when I try it Worksets get created even when some of them already exist.
The node gives me warnings then though.

No, they are similar but not the same, after running the graph only the only 25 worksets are created. Sorry I could not answer ealier. The forum did not allow me to answer more than 16 times in a day.

@Brendan_Cassidy I will try that today and I will see what happens, I thought was gonna be an easier task as I have set worksets before.

1 Like

Hi mate,
Just wondering if this dyn file would be better to split to two.

  1. Workset creation
  • Check current list of workset
  • Does it match Master list
  • No → Create
  • Yes → No action
  1. Workset assignment
  • Excel Export instance parameter and element ID
  • Fill in instance parameter workset information
  • Excel Import instance parameter and element ID
  • SetParam Workset

It is fairly easy to complete, it is all about having the right logic. While also making sure you complete transactions at the right stages as well.

Hello, Since last week I have been trying all the options that you gave me and I opted for the option of first created all the worksets from an excel sheet, and once I have all the worksets I wanted to set the workset value to the same as the NAME ID parameter. I have already created the worksets with that name. Any idea why is not working? it does not give me an error but it does not set the Workset parameter to what I am looking for.

Thank you very much

You’re feeding in strings to the workset input, and worksets to the element input. That wont work unfortunately.

I’ve attached a pair of scripts that will:

  1. Generate worksets for each wall type
  2. Assign those walls to the matching workset

With this example you can hopefully borrow concepts to get your approach to work. Given I don’t have your model I can’t really simulate your approach effectively.

I use the Crumple package, as well a customized version of Element.SetWorkset to handle one workset per element, which I’ve copied below as well and I use it in part 2. Unlike some other packages which make worksets, my nodes anticipate the event that a workset cannot be created, and will output an error report as booleans to carry forward to a filter by boolean mask for continuity.

Whilst I am equally apprehensive to support this workset approach, in the interest of helping you survive probation and hopefully completely change their mind afterwards here are the files:

part 1 make worksets.dyn (15.1 KB)
part 2 set worksets.dyn (27.3 KB)


# Made by Gavin Crump
# Free for use
# BIM Guru, www.bimguru.com.au

# Boilerplate text
import clr

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

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

# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument

# Define list/unwrap list functions
def uwlist(input):
    result = input if isinstance(input, list) else [input]
    return UnwrapElement(result)

# Preparing input from dynamo to revit
elements = uwlist(IN[0])
worksets = uwlist(IN[1])

bools = []

# Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

for e,w in zip(elements,worksets):
	try:
		wsId = w.Id.IntegerValue
		param = e.get_Parameter(BuiltInParameter.ELEM_PARTITION_PARAM)
		param.Set(wsId)
		bools.append(True)
	except:
		bools.append(False)

TransactionManager.Instance.TransactionTaskDone()

# Preparing output to Dynamo
OUT = [elements,bools]

Before/after with workshare display on:


Hello Gavin, Thank you very much for the time and all the information. I was running the scrip (the part 2 set Worksets) in a simple test project with only four walls, (is a worksharing project) and a warning pop out, it seems that the element.name node cannot get the information from the Shared parameter that I have created, the one that I use for naming the worksets. My question is does it matter what kind of parameter is when we use the element.GetParameterValueByName node?

This is the error that appears in the Element.Name node: Warning: Element.Name expects argument type(s) (Revit.Elements.Element), but was called with (string).

Thank you very much for the help,

That node is there to get the type and then its name, so you should actually replace element.name with an extra get parameter node if you want to work that way, or just don’t use element.name if you are reading element instances.

Hello @GavinCrump I understand now the function of the element. name node, I was nit using it correct, I actually omitted the element.name node and use the element.getparameter to grab all the walls with the shared parameter Name ID (that I created, and is the same as the names of the worksets) now the problem that I am seeing is that the list.Indexof node is not populatin the correct list, I have tried flattening the list coming out from list.filterByboolMask but it gives me only one value. I am sorry if i am making this harder than it really is. By the way great fan of BIMGuru, thank you for all the hard work.

Get rid of the second filter by boolean mask, then connect the indices list to the index input of the get item at index node. You are effectively trying to get the matching workset that has the same name as the parameter value of the element.

I did as you mentioned, but I still have the problem that the list.IndexOf does not read the actual proper indices and it get a negative value which is out of range. I am guessing the list.IndexOf is not collecting the proper indices from the worksets list so the List.GetItemAtIndex cannot get the proper items.

part 2 set worksets modified with getparameter 08-06-22.dyn (23.6 KB)

Index the workset names as the list input like you had before…

Yes, I am sorry, I was actually trying both options before and I took the wrong screenshot. everytime I get the same outcome a negative value.


part 2 set worksets modified with getparameter 08-06-22.dyn (23.6 KB)

I’ve attached a script with annotations and corrections. Hopefully it helps you understand the intended workflow. I’d suggest you spend some time researching and learning about list management, in particular the List.FilterbyBooleanMask, List.IndexOf and List.GetItemAtIndex nodes. The way you’ve connected them in your attempts indicates to me you might not be too familiar with them, and that’s OK, but it’s important you learn about these fundamentals before pursuing complete workflows.

There is an area in the primer which covers these nodes and principles:


part 2 set worksets modified with getparameter 08-06-22.dyn (30.9 KB)

1 Like

Thank you very very much @GavinCrump, for the solution and the extra time that it took, all the explanations are really appreciate it. I will with no doubt keep doing research and studying the list nodes. Have a great day and again thank you for the help.

1 Like