I'm creating tags for rebars:
newIndTag = IndependentTag.Create(doc, vista.Id, New Reference(rebar), True, TagMode.TM_ADDBY_CATEGORY, TagOrientation.Horizontal, New XYZ(0, 0, 0))
Then I'm defining the position of the elbow. It is working for every tag except those referencing rebars with variable length. For those I'm getting an error saying that "the reference is not currently tagged":
I tried all these options and I'm getting the same error for all of them:
option 1:
newIndTag.SetLeaderElbow(New Reference(rebar), position)
option 2:
newIndTag.SetLeaderElbow(newIndTag.GetTaggedReferences.First, position)
option 3:
Dim rebar As Rebar = DirectCast(doc.GetElement(newIndTag.GetTaggedElementIds().First.HostElementId), Rebar)
newIndTag.SetLeaderElbow(New Reference(rebar), position)
option 4:
Dim rebar As Rebar = DirectCast(doc.GetElement(newIndTag.GetTaggedLocalElementIds().First), Rebar)
newIndTag.SetLeaderElbow(New Reference(rebar), position)
option 5:
newIndTag.SetLeaderElbow(New Reference(newIndTag.GetTaggedLocalElements.First), position)
With Revit Lookup if I try to check the list of tagged references of a manually created tag for varying length rebar I also get an error saying "object reference not set to an instance of an object":
I suppose this behaviour isn't normal. Is there a way I can create tags for varying length rebars while also defining the elbow position? I suppose I have to find another way of getting the reference Revit is using for these tags.
Thanks in advance.
Solved! Go to Solution.
Solved by jeremy_tammik. Go to Solution.
Yup, doesn't sound normal.
Can you produce a minimal reproducible case for the development team to analyse?
https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b
I went ahead and asked them whether they have any advice, so maybe we can wait and see what they suggest first.
They did indeed reply as I suspected they would:
Can you please provide a minimal reproducible case and a sample Revit file?
Also, it would be helpful to know which Revit version is the customer using, because the tag's API underwent some significant changes last year.
Thank you!
Hi @jeremy_tammik,
Thank you for you reply.
Please find attached a project file with a wall, a beam and two rebars, with a macro called "test" embedded that should be run in the detail view.
One rebar has variable length, the other doesn't. You can see that only the variable one causes the error.
While making this minimal project I realised that if I purge the other type of the tag family the error doesn't occur, but the elbow isn't placed either.
I left two tags, for both rebars. You can check that if you select the upper one the "Select Host" but is greyed out, while for the other isn't:
You can also check that with Revit Lookup you get the error that I illustrated in my first post only for the upper tag.
I'm testing with Revit 2022.1.
Yes, I did. They say:
LeaderElbow = new XYZ(5, 5, 0);
// Instead Of
//tag.SetLeaderElbow(new Reference(rebar), new XYZ(5,5, 0));
Thank you @jeremy_tammik. I already tested and I can confirm that it works for now.
I hadn't think of using the deprecated property. When the new major version is released I'll update for the new method.
I'll also be looking forward for the subelements implementation. It may at least simplify a few thing when obtaining geometries.
I submitted a development ticket REVIT-183943 [Error setting elbow on tag of varying length rebar] for you reporting this problem.
Can't find what you're looking for? Ask the community or share your knowledge.