All parameter to Component Family

I am in a family and want to add parameters. Below is my python node but I am missing something.

import clr

#import module for Revit
clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

#import Revit API
clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *

#import module for the Document and transcactions
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

import System
from System.Collections.Generic import *

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

paramName = IN[0]
exec(“paramGroup = BuiltInParameterGroup.%s” % IN[1])
exec(“paramType = ParameterType.%s” % IN[2])
paramBool = IN[3]

addParam = doc.FamilyManager
TransactionManager.Instance.EnsureInTransaction(doc)

try:
newParam = addParam.AddParameter(paramName,param_Group,paramType,paramBool)
except:
newParam = “could not create new parameter”

TransactionManager.Instance.TransactionTaskDone()

OUT = newParam

When sharing code please paste it as preformatted text - this post here shows a gif on how to do so properly:

However, you do not need to use Python here as there is a node for adding parameters in a Family Document in the Orchid package

2 Likes

Thank you for the reply. Yes I am aware of Orchid and have a previous version to the newest downloaded in Dynamo. The purpose for asking the question is a learning lesson using the API.chm, dynamo and python.
I believe I have all necessary references and variables included. I called for the Family Manager and Add Parameter method with all necessary variables but no joy. In my script the (try and except) is indented as required (not as shown above).
Any help is appreciated.

Patrick

@patsmith4012, Are you missing something in the Orchid package since your are troubling with coding by yourself?

No Orchid work as designed. Just trying to learn to code myself, most of the time I can work thru but this has me stumped

I am sorry but I have seen so much of my code being used in nodes/packages not released --and more important, not maintained-- by me that I have lost the motivation “to give” more code away. I simply don’t understand why someone will release nodes they have not been coded by themselves. Help is one thing, totally copying my code is another thing. That is one of the reasons why my package is now a ZeroTouch package!

I am glad that my node works as intended.

erfajo,

Sorry I didn’t recognize you are the developer of Orchid and be assured I have no desire to post, copy or steal any of your content. I very seldom post on any of the forums any longer. I have been working with Revit from 2003 and I am near the end of my career and just having fun now. Also totally understand your point of view and appreciate you work.

Thanks for your reply.