Shared Coordinates - Remove

Shared Coordinates - Remove

Dale.Bartlett
Collaborator Collaborator
4,274 Views
3 Replies
Message 1 of 4

Shared Coordinates - Remove

Dale.Bartlett
Collaborator
Collaborator

All, Further to this discussion:

http://forums.autodesk.com/t5/revit-api/shared-coordinate-system-definition/td-p/5928300

Is it possible to programmatically remove Shared Coordinates once they have been set? The actual values (N, E, Elev, Rotation) can be reset manually by acquiring from a template file, but I am sure this is simply setting the Shared Coordinates to those from that file, ie 0, 0, 0, 0. I have yet to test, but I suspect that the template file becomes the source of the Shared Coordinates rather than truly resetting the project back to pre-Shared Coordinates state.

 

I found the following in the comments section of this blog post:

http://revitoped.blogspot.qa/2012/04/reset-shared-coordinates.html

To remove Shared Coordinates: open file> "detach from central"> "detach and discard worksets"> save file as a template> open an new file using this template created from the project then save the file back as the project. All links remain but Shared Coordinates are removed; you also lose the workset but not the element assigned to the workset. Alan C.

 

This is a good suggestion (convert to template), but obviously less than perfect. My need is to remove all references to the project having had Shared Coordinates applied. Again, all comments appreciated, Dale




______________
Yes, I'm Satoshi.
0 Likes
4,275 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

Dear Dale,

 

Thank you for your interesting query.

 

I am checking with the development team...

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 4

jeremytammik
Autodesk
Autodesk

Dear Dale,

 

Thank you for your patience.

 

I heard back from the development team. They say:

 

Some of what you want is available. I don't know if you can remove shared coordinates from a CAD link but you can do it for a Revit link.

 

I don't think there's any function that will allow you to make it as though shared positioning never happened. But you can disable shared positioning for each link individually with RevitLinkType.SavePositions().

 

Normally, RevitLinkType.SavePositions() is used to save shared coordinates changes back to the linked model. However, the function takes an optional argument of type ISaveSharedCoordinatesCallback. If the user defines a callback which always returns SaveModifiedLinksOptions.DisableSharedPositioning, you can use the function to set every instance of that type to have no shared site.

 

Additionally, if you want to get rid of any of the shared sites, I believe you can delete ProjectLocations like any other element. (I am not 100% certain of this, but it would be easy to try. You can get the project's locations via the Document.ProjectLocations property.)

 

Once you've done this, the project will still be in the same position, but there should no longer be an active shared coordinates relationship.

 

So to sum up:

 

  1. Create an implementation of ISaveSharedCoordinatesCallback. Make its function GetSaveModifiedLinksOption always return SaveModifiedLinksOptions.DisableSharedPositioning.
  2. Call RevitLinkType.SavePositions() on any links for which you want to disable shared coordinates. (The link must be loaded at the time for this to work, even though the disable option shouldn’t require it.)
  3. Save the host document.
  4. Repeat steps 1-3 on any other documents in your project which contain links. (This is presumably most or all of them.)
  5. If desired, delete any ProjectLocations you want to get rid of.

 

I hope this helps.

 

Please let us know how it goes for you and hoqw you end up making use of this.

 

If you would like to put together some generic non-confidential code to show this in action, it woud be great.

 

Thank you!

 

Merry Xmas and a Happy New Year to you!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 4

Dale.Bartlett
Collaborator
Collaborator

Jeremy, thanks again for your efforts. This may be a workaround. My vision was a tool that would remove the Shared Coordinates from the open (active) file, ie nothing to do with links. If your suggestion is the only way, then conceptually I could link the Shared Coordinates file into a dummy host, and use SaveModifiedLinksOptions.DisableSharedPositioning to remove the linked file's SC. I will give this a try and report back. Dale




______________
Yes, I'm Satoshi.
0 Likes