So I've been asked to synchronize grid leader locations (along the grid line) between files.
I thought that this would be easy using the new API for DatumPlane, BUT i was wrong. The property I want to change in the Leader is the Anchor, but that property is readonly and the documentation says: " This is a read-only property, for the this point gets always computed based on various properties of the annotation element. "
Well for the grid element there are no annotation elements attached to the Leader, right?
Am i missing something?
Thanks!
/Erik
Hi Erik,
Sorry for keeping you waiting. Let me reach out to the Revit Engineers in order to shed some light with this.
Thank you for your patience and collaboration.
Cheers,
Hi Erik,
I still haven't heard anything from our engineers. Thank you for your patience, As soon as I hear something I will contact you.
Cheers,
Hi Erik,
No 😞 unfortunatley they Still haven't. I think they are pretty busy at the moment with the Revit 2017 version, since will come out soon.
Please bare with me, I will keep reaching out to them, and as soon as I hear back will let you know.
Thank you so much for your patience and collaboration.
Cheers,
Hi Erik,
Thank you once again for your patience. I spoke to the Revit engineers and they are preparing me a Macro with the explained functionality of the DatumPlane method. It is looking promising to what you are trying to do. They will probably send it to me during this week so stay tune.
Cheers,
Hi Erik,
Revit Engineering got back to me with a solution for moving the grid. Here is what they wrote:
"The new API for DatumPlane works and the data should be computed by users according to their requirements. Here is a Macro as a sample showing how to get from A to B. Please open the file and run the ‘SynGridLeaders’, it will get the following result.
After Running the Macro. Result Below.
"
The Anchor property of the leader is read-only as it is computed by the Elbow and End properties set by the users. The new leader should also be set via SetLeader() method to get it work."
You can find the Revit File and the code for the Macro here: https://github.com/jaimerosales/revit-macros/tree/master/SyncGridLeaders-2016
The file attached is saved by R2016R2 version. If running the macro the grid leaders don’t change, please click ‘edit’ button of the macro, compile it then run it again. ( Remember to enable the macro when opening the file.)
Check it out and let me know, hope this solves your question 🙂
Thank you again for your patience and collaboration.
Cheers,
Hi Jaime,
thank you for the solution, sorry that it took me a few days to test.
I've tested it now, and Im afraid it still doesnt solve my problem.
Our grids are always straight and with a straight line I get the following exception:
"Autodesk.Revit.Exceptions.ArgumentException: One of the conditions is not valid: the input leader and view is not null; The leader End, Elbow, Anchor should be in the view; the End of leader should be in the datum plane curves; Elbow is between End and Anchor.
Parameter name: pLeader
at Autodesk.Revit.DB.DatumPlane.SetLeader(DatumEnds datumEnd, View view, Leader pLeader)
at GridLeaders.ThisDocument.SynGridLeaders() in c:\Users\19eer\AppData\Local\Temp\{5178E7AE-4516-4649-BB95-75BD6B9FCAD6}\Architecture\DocHookups17300\4231183040\GridLeaders\Source\GridLeaders\ThisDocument.cs:line 80"
I tried to find the error in the code, but I couldnt.
I've added a 4th grid to the file and tested, please see the image below.
Thank you!
Best regards
Erik
Hi Erik,
This is a bit strange, Is it possible for you to provide us with a minimum sample file (Rvt and Plugin) So I can reproduce your error on my end and be able to investigate further. It will also help engineering in case I requiere help from them.
Thanks,
Hi,
I've only added a grid to your file and turned of 3d propagation.
The code required is in the macro.
I've attached my edited file in this post.
/Erik
Hi @rosalesduquej,
It is worth you copying the code from the macro into this discussion so others may see it. (Your link is broken.)
@Anonymous , I'm figuring you have probably sorted this by now, but I would guess that grid 4 is causing an issue because it doesn't have a leader. Use the AddLeader method to add a leader first. You'll also probably need to do a document.regenerate afterwards, before you set the leader points.
I found your blog post that contains the code: https://adndevblog.typepad.com/aec/2016/04/forge-devcon-early-bird-revit-api-moving-a-grid-with-datu...
@Anonymous After seeing the code I can confirm that my guess was correct.
Dear Matt,
Thank you for picking up and answering this old thread.
So am I correct in summarising the result as follows:
If you want to move a grid, make sure that each and every one of the grid lines has its own leader.
As simple as that?
Can you confirm?
Thank you!
Cheers,
Jeremy
Hi @jeremytammik,
Actually, I think the title to this discussion is a bit misleading.
It's about shortening/extending grids and adjusting the grid leader anchor points.
The macro that @Anonymous was running was failing because it expected each grid to have a leader, which grid 4 did not. In short, you can't modify a grid leader if the grid doesn't have one. You don't need a leader to lengthen/shorten a grid.
Thank you for the clarification. I see now. All clear and obvious.
Can't find what you're looking for? Ask the community or share your knowledge.