Shared Parameter value don't show up in element's tag (Dynamo 2.13)

I updated Revit to 2023.1.1 and the tag issue remains…
So, if anyone else could have an idea of what could be wrong, i appreciate in advance.

Are you sure the tag uses the same parameter? Ignore Dynamo for now. Your issue is with Revit recognizing the parameter you have in the project and the one you have in the tag. Obviously a shared parameter has to be the same shared parameter in order to share information, that’s the whole point. If this isn’t working in Revit then there’s something wrong with your parameters. You may have to try completely recreating the parameter in both locations (from the same SPF).

1 Like

Yes, i agree that the issue is related to that connection between the element and the tag.

Manually, i added the shared parameter from the SPF to the project and to the family tag and there’s no problem at all. The tag gets the parameter value from the element tagged.

The issue happens when the parameter is added from Dynamo, which get all the shared parameter properties from the SPF. I tried so many times to find the problem in the graph, that i almost give up to solve it.

I’ll leave here the graph and spreadsheet, hoping someone could find the gap.

GEN-CreateSharedParametersFromSPF_Eng.dyn (125.4 KB)
Shared Parameters Database_FDynamo.xlsx (20.6 KB)

This makes it sound like you’re getting the properties and recreating the parameter.

You never showed us how you were adding the shared parameter to the project to begin with. Are you sure you’re doing that part correctly?

Ok, so let me get it clear to start with.
I have a list of shared parameters in the SPF and a spreadsheet with its properties.

If i add the shared parameters to a project manually, the tag is able to get the value of the element tagged parameter.
In order to automate this process, i wanted to create a dynamo graph to add all the shared parameters to a project, with a several checks to validate the properties and to do not duplicate parameters.
However, when the shared parameters are added by the dynamo graph, the tag can’t read the value of the element tagged parameter.

You never showed us how you were adding the shared parameter to the project to begin with. Are you sure you’re doing that part correctly?

I’m sorry for the misconception between “create” and “add” shared parameters, it seams to me that it led to a wrong interpretation of the topics goal.
Yes, the shared parameters were create in the SPF manually trough Revit.

I have this feeling the GUID is the issue.
So maybe the one which is created using Dynamo / the .xls is a Project Parameter instead of a Shared Parameter then.

To be absolutely clear IF or WHEN both Parameters are Shared Parameters :wink:;

When you create the Parameter manually you use a Shared Parameter .txt file right?

Is the GUID in that .txt the same as the one you create using the .xls.

Or do you mean something else with manually?

That i didn’t get out of all the replies. Sorry if i missed it.

It would still be helpful to see how you’re creating/adding the shared parameter in the project. The fact of the matter is you have two parameters with two GUIDs which means they’re not the same. So we need to figure out how that’s happening.

The manual process (adding Project Parameters):

By dynamo graph:

  1. Checking if parameter exists - There’s none parameter with Name starting with “HID_”

  2. Run the dynamo graph to add the project parameters (30 parameters were added to the project)

  3. Check if parameters is shared (true)

  4. Add a family tag to the project, after i edit the family and its label, and load into project

  5. Check if tag gets the value from the tagged element parameter (false)

  6. Now this is something i notice doing this step by step guide… Checking the existence of the parameters again it counts one more with a differente GUID.

  7. So, to try something different in the dynamo graph and following what @bvs1982 said, i deleted all the parameters that were added by dynamo and replaced the node Parameter.CreateProjectParameter with Parameter.CreateSharedParameter. I thought “They have the same inputs, so… let’s test it.” (and did not added the parameters to the project at all and nothing changed in the SPF)

Concluding…
Something is wrong in the way dynamo is adding the parameters, that is clear. However, I can’t find out why this is happening.
Is it there any other method to add shared parameters to the project in Revit 23 or Dynamo 2.13 (now 2.16)?

This works in Revit 2020 and uses Python. I’ve added notes to explain how it works, and areas where you may encounter changes in Revit 2023. My Python editor is glitching out in 2023 so can’t test there currently.

I’d strongly recommend you have users connect to the shared parameter file to add the parameters, trying to programatically recreate the shared parameters is not a good approach in my experience and looks to have been the cause for this thread/issue. My script operates under the assumption the SP file is pointed to, and the parameters/groups exist in said SP file already.

Test params.txt (890 Bytes)
Add params.dyn (17.0 KB)

# Boilerplate text
import clr
import re

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

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
from Autodesk.Revit.ApplicationServices import *

# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 

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

# Preparing input from dynamo to revit
pnames  = tolist(IN[0])
pgroups = tolist(IN[1])
bipgs   = tolist(IN[2])
cats    = tolist(IN[3])

error = []

 # Open the Shared Parameter File and Get parameter def. in group
sharedParameterFile = Application.OpenSharedParameterFile(app)
groups = sharedParameterFile.Groups

# Create CategorySet
categorySet = CategorySet()
for c in cats:
	category = doc.Settings.Categories.Item[c]
	categorySet.Insert(category)

# Sets as Instance parameter
binding = InstanceBinding(categorySet)
docBinding = doc.ParameterBindings

# Do some action in a Transaction
for pname,pgroup,bipg in zip(pnames,pgroups,bipgs):
    # Get shared parameter
    externalDefinitions = groups.Item[pgroup].Definitions
    # Get Builtin parameter group
    e = externalDefinitions.Item[pname]
    bipg_actual = getattr(BuiltInParameterGroup,bipg)
    # Try to make binding
    try:
	    TransactionManager.Instance.EnsureInTransaction(doc)
	    docBinding.Insert(e, binding, bipg_actual)
	    TransactionManager.Instance.TransactionTaskDone()
	    error.append(True)
    except AttributeError:
        error.append(False)

# Preparing output to Dynamo
OUT = error
3 Likes

Thanks @GavinCrump.
I had a dynamo graph to add shared parameters to a project in Revit 2020 and it worked fine.
All users have the SP file linked to the project, so that’s not a problem, and the dynamo graph can searchs for the parameters and its properties and add them to the project.

My guess is this issue is related to the changes from Revit previous versions to Revit 2023, which somehow affects the way Dynamo add shared parameters. But i’m not an expert in this matter.

Out of curiosity. Did you also use a .xlsx then?
Also i can’t see any GUIDs in your .xlsx.

I do, however, agree with @GavinCrump.

@GavinCrump, I didn’t got the time to test it before. It works in Revit 2023 and Dynamo 2.16.

The dynamo graph adds the parameters and it seems to be all connected. The tag gets the value of tagged element parameter with no problem at all.

Problem solved! Thanks to all of you guys!

1 Like

Chefs kiss

Thanks Gavin, this is literally the exact code I needed and works better than ALL the other shared parameter nodes available out there. Worth including in Crumple?

2 Likes

Probably, Crumple’s been gathering dust on my shelf for a while, a lot of stuff i’d want to add it to it in the next build!

1 Like