Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.

Revit API Forum

Reply

Moving a grid?

474 Views, 9 Replies
03-03-2016 04:36 AM

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

Erik Eriksson
White
Post 2 of 10

Re: Moving a grid?

03-09-2016 11:46 AM in reply to: erikeriksson5686

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,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
Post 3 of 10

Re: Moving a grid?

03-16-2016 08:47 AM in reply to: erikeriksson5686

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,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog

Re: Moving a grid?

03-28-2016 01:06 PM in reply to: rosalesduquej
Hi Jaime,

thank you for your assistance.
Did you hear anything yet?
Im anxious to know.

Thanks!

/Erik
Erik Eriksson
White
Post 5 of 10

Re: Moving a grid?

03-31-2016 10:52 AM in reply to: erikeriksson5686

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,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
Post 6 of 10

Re: Moving a grid?

04-05-2016 10:47 AM in reply to: rosalesduquej

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,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
Post 7 of 10

Re: Moving a grid?

04-06-2016 08:46 AM in reply to: erikeriksson5686

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,

 

 



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
Highlighted

Re: Moving a grid?

04-11-2016 02:55 AM in reply to: rosalesduquej

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

 

Erik Eriksson
White
Post 9 of 10

Re: Moving a grid?

04-13-2016 02:22 PM in reply to: erikeriksson5686

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,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog

Re: Moving a grid?

04-14-2016 05:20 AM in reply to: rosalesduquej

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

Erik Eriksson
White
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post

Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.