Family document add shared parameter

revit
python

#8

@Erik_Falck_Jorgensen Try removing “1:” from your code block and just type “Sheet and Project”. See if that helps!


#9

Thanks @Mostafa_El_Ayoubi ,

Sometimes you need other to confirm you are not a totally idiot concerning the code, but still a bit daft :slight_smile:

The problem was an old-timer working with Dynamo/Revit. I forgot to close the files later in the script since I froze that part. Meaning I tried to reopen the same files over and over again… but that mentioned, there is also the problem you need to restart dynamo when the script has run once. Closing the TransactionManager isn’t working as proper as could be wished.

I am so sorry for the disturbance, but very glad for all the hints I got :slight_smile:

final code if anyone is interested

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

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

#doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

docs = IN[0] #document list
spfile = IN[1] #shared parameter file as string
group_name = IN[2] #group in shared parameter file
param_name = IN[3] #parameter name in shared parameter file
exec("param_group = BuiltInParameterGroup.%s" % IN[4]) #BuiltInParameterGroup as string
#param_group = IN[4] #BuiltInParameterGroup from node
instance = IN[5] #boolean value for instance

result = [] #test list

#ExternalDefinition
def defFile(file, group, param) :
	file = app.OpenSharedParameterFile()
	defGroup = file.Groups.get_Item(group)
	return defGroup.Definitions.get_Item(param)

for doc in docs :
	TransactionManager.Instance.EnsureInTransaction(doc)
	try :
		eDef = defFile(spfile, group_name, param_name)
		doc.FamilyManager.AddParameter(eDef, param_group, instance)
		result.append(True)
	except :
		result.append(False)
	TransactionManager.Instance.ForceCloseTransaction()
OUT = docs, result

Adding Shared Parameters to a family
Adding Shared Parameters to a family
#10

The code is not working, an Error: endline expected error appears :sweat_smile:


#11

@fablabolbia Show us your complete graph with errors expanded.


#12

Hi Kulkul,
I’m using the @Mostafa_El_Ayoubi code without results. (the @erfajo code gave me an error)
with reference to mostafa code, a “false” appear in the OUT watch.
NO changes have been applied to the families stored in the called folder (read only flag has been removed).
The shared parameter file is also attached.
SP.txt (810 Bytes)

ADDING SHARED PARAMETERS_TEST___erfajo.dyn (10.7 KB)
ADDING SHARED PARAMETERS_TEST__mostafa.dyn (10.8 KB)

Thank you in advance !
Anton


#13

@fablabolbia
you need to feed the right data from your Shared Parameter file. I have no idea what “Group 3” and “Group 1” is, these “items” is not a part of the SP file you have uploaded.

And… please try to see this post, use the nodes in DanEDU Dynamo package instead.


#14

HI @erfajo, already tested and not working…I’m going to try again, but it gave me an error: the Run in progress never disappear


#15

Never reaches a stop…

image


#16

Also continous crashes…

image


#17

Hi @fablabolbia ,
could you share dummy files (revit and .txt) that cause the same issues?


#18

i’m having pretty much same issues with it crashing… not sure if it’s because of the same problem as you fablobolbia but i would really appreciate if you could update once you find a solution as i’ve tried to search so much for one that i got headaches and had to take drugs for them, i can’t search further anymore. Mostafa also thanks for answering that guy’s questions. you seem to have some good knowledge… would you mind if i am going to have some questions either? thanks!


#19

At the moment I can not find a solution…I’m not sure if I’m a stupid or if there’s no real working code in the forum but just “suggestions” for people (not me :sweat_smile::sweat_smile::sweat_smile: ) with higher programming skills…


#20

Thank you very much @Mostafa_El_Ayoubi

ADDING SHARED PARAMETERS_TEST___erfajo.dyn (10.7 KB)
ADDING SHARED PARAMETERS_TEST__mostafa.dyn (12.3 KB)
shapa.txt (552 Bytes)
Project2.rvt (2.8 MB)


#21

in your attemps, you replaced these values with your own right?


I see from your shared parameter file that the group is called sp1 and the parameter A1


#22

yes…too much confusion… :open_mouth::open_mouth::open_mouth:
Anton


#23

I wrote exactly what @Mostafa_El_Ayoubi also is showing… if you dont use the right input nothing will work, but it is not the code that is the problem it is the usage!


#24

I know, but usually its not clear where all the inputs have to be set…


#25

The bare minimum must be that you understand how to give the right input before complaints about code you dont seem to understand.

Please use nodes that are built for the purpose instead of using some code while you still are learning. There is to many steps that goes wrong if you dont understand what is happening.

It sends to much noise with such complaints


#26

Hi @erfajo I did not want to offend anybody…sorry. :sweat_smile:


#27

hi @erfajo @Mostafa_El_Ayoubi i have a little dynamo script that associate shared parameters from a shared parameter file with the current family document and its not working and its driving me nuts can u help me plz
test.dyn (7.9 KB)

shapa.txt (552 Bytes)