Set single Parameter to the same family with the different val. by python

I need help

I try to set Parameter to the family (Singel parameter “H”) to the smae family with the different val EX.[5,6,7] to get the family geometry at each parameter
I use Python and what i have the latest geomety related to the latest H paramere EX. 7

def apply_transformation(H,Sita):
    HH=[]
    doc = DocumentManager.Instance.CurrentDBDocument
    TransactionManager.Instance.EnsureInTransaction(doc)
    
    elementId = IN[0]  # Assuming element ID is passed
    element = doc.GetElement(ElementId(elementId))
    
    param_H = element.LookupParameter("H")
    if param_H and param_H.StorageType == StorageType.Double:
        param_H.Set(UnitUtils.ConvertToInternalUnits(H, UnitTypeId.Meters))

    param_Sita = element.LookupParameter("Sita")
    if param_Sita:
        param_Sita.Set(Sita)
#    doc.Save()
#    doc.Close()
    TransactionManager.Instance.TransactionTaskDone()


    time.sleep(5)

    return [H,Sita]

when i use dynamo node i have error “Starting new transaction is not permitted …”

But when i use Custom node it work and i can get family geomenty related to the each parameter


what i need to edit the python code to get the geometry as in custom node that i need it as python function
Or
Can i call the custom node inside my python code?

Any one Help

This seems somewhat problematic from a speed standpoint, as it will require committing the transaction and refreshing the document N times instead of once. What’s the use case?

Somewhere in my post history is an example of editing the height of a wall until a condition is met, which sounds similar to what you are after. You’ll need to define the transaction in the action, and you’ll wind up with N transactions in your undo history unless you leverage a transaction group, perhaps with a rollback to restore the original state as well.

1 Like

@jacob.small
the use case is to edit the Hight of the family the get the new geomentry until a condition is met. as you referred in your post.
can you send the path of your post

I looked for it before but as I have upwards of 15k posts on here so finding a specific one can be difficult. Second dive picking up where I left off found this post: TypeError: getset_descriptor is not callable - #7 by jacob.small

For what it’s worth when I have seen people try to implement this they give up as it doesn’t scale beyond the simplest of use cases and things WILL break as you iterate in ways which change geometry, and when they inevitably do you get stuck with warnings to dismiss or otherwise handle.

1 Like

Thanks @jacob.small :grinning:

1 Like