SetParameter problem (any ideas welcome Zerotouch ,Node, python or C#)

Dear Everyone! :smiley:

  • The problem: my C# Zerotouchnode passes the dimensions (SpotCoordinate Elements), but cannot change one of its parameter immediately.

  • I have to rerun the program again to set that parameter. I need to switch the boolean true to false and back and forth to work, and there is a bug in Revit, because i need to reclick on the dimensions to make the text appear (Top Value Prefix).

Can you give me some advice how to fix this strange problem?
Thank you!

It may be caused by the SportDimension has just been crated and the Transaction hasn’t actually “created” it yet so you can set any values. That is why the second run works because now the element is there and the values can be set.

Why are you getting the ElementId ss.Id and then using that to get the Element when you already have the Element as (SpotDimension) ss?

//This should work, and you don’t need to get the parameter unless you plan to set multiple values

    using (Transaction t = new Transaction(doc, "SpotDimension"))

Instead of…
Parameter parameter_e_warped = e_warped.LookupParameter(Top_Value_Prefix);

it should be…
Parameter parameter_e_warped = e_warped.get_Parameter(BuiltInParameter.SPOT_COORDINATE_TOP_PREFIX);

This is the proper way to get to any BuiltInParameters which is via the BuiltInParameter Enum.

Additionally, as @SeanP alludes to, you need to be in an open transaction to create or modify an Element. You also may need to Commit the transaction around the doc.Create.NewSpotCoordinate, then open a new transaction for setting the parameter. You can group these Transactions into a TransactionGroup. And one last thing is Document.Regenerate which forces the Document to regenerate the Elements and data within, often when accessing Geometry of a newly initialised FamilyInstance.


I just wanted to show you that both commandlines aren’t working and you can give me some proper advice if i miss something.
I wasn’t sure that should i use builtinparameter of the element or get the instance parameter of the element.
Thanks for your patience it was very helpful!

1 Like

I haven’t used transactions before, it makes sense. It was very helpful. I’ll try it out tomorrow!

“Why are you getting the ElementId ss.Id and then using that to get the Element when you already have the Element as (SpotDimension) ss?”
Because ss is Autodesk.Revit.DB.Element type and i can return it in Dynamo as Revit.Elements.Element to have fun with it. I convert ss.ToDSType(true).

doc.Regenerate(); is what i was looking for!!!

1 Like