« F# Programming Contest | Main | PlanTopology Class »

January 09, 2009

Comments

How do I extract the coordinates of the viewports on the sheet? I can place a view on the sheet and supply the specific coordinates, so, I assume I can reverse this and extract the coordinates of the viewpsorts on a sheet. I've tried:
ViewSheet currentSheet = doc.ActiveView as ViewSheet;
foreach (Autodesk.Revit.Elements.View v in currentSheet.Views)
{
BoundingBoxUV loc = v.Outline;
MessageBox.Show("Coordiinates of: " + v.Name + ", " + v.ViewType + "\r\n" + loc.Min.U + ", " + loc.Min.V);
}
but the values returned don't appear correct.

Dear Harry,

I implemented an external command using the sample code you provided and was also initially unable to interpret the resulting coordinates returned by the View Outline property. According to the documentation, it returns the bounds of the view in paper space in inches. Running the code in a simple sample drawing did return something that looked vaguely reasonable:

Coordinates of FloorPlan view 'Level 1': (-0.88,-0.88)
Coordinates of FloorPlan view 'Level 2': (-0.58,-0.38)
Coordinates of Elevation view 'North': (-0.62,-0.06)
Coordinates of Elevation view 'East': (-0.45,-0.06)

On closer inspection, however, these coordinate values have no discernable relationship with the actual position of the views on the sheet.

I checked with my colleagues, and received the answer that you are not doing anything wrong, but unfortunately there is currently simply no API access to this information. Sorry for the bad news!

The information returned by View.Outline is not wrong in any way, it is just describing the size of the view and returning the bounding box of the origin of the view, not its position on the sheet.

Cheers, Jeremy.

Thanks for that answer. At least I won't spend any more time trying to figure this one out. IT would be nice, in a future version of the API to be able to do this. I have 50+- typical sheets in our library and if I could programaticaly extract the position of the views, then I could use my complimentary routine to rebuild the sheets when view in the library is updated. I wrote a program to do this with the locations stored in an XML data file. So all our users can dynamically create typical sheets for their projects using the latest versions of our details. Pre assembled sheets are static and a pain to maintain / update as time goes on.

In that same train of thought. In the future API it would be nice to be able to access the GUI feature to "Insert from File -> Views...". Then my application to dynamically create the typical sheets in a project will be completely automated.

Unless there is a way to put all the drafting views into a family file. Then I could use the currently available API functions to do this.

One more question on views / viewports. Using the API can I assign the viewport type (ie: title family style) and the detail number property of the viewport once the view is placed on a sheet?

Dear Harry,

Yes, definitively, I see your point, and thank you for the suggestions and explanation!

This wish has been registered and this functionality will certainly become available at some point.

Cheers, Jeremy.

Dear Harry,

Yes, definitively, the detail number property is accessible using the built-in parameter VIEWPORT_DETAIL_NUMBER, and its value can be both read and written to.

Use the Revit API intro built-in parameter checker to find out things like this, as described in

http://thebuildingcoder.typepad.com/blog/2009/04/deeper-parameter-exploration.html

I don't know what property 'viewport type (ie: title family style)' might refer to, but I am sure you will see it as soon as you check it out.

Cheers, Jeremy.

Dear Harry,

Please keep good track of these wishes of yours and make sure to submit them all at every official opportunity that is offered, especially when the next API Wish List Survey comes around:

http://thebuildingcoder.typepad.com/blog/2009/07/api-wish-list-survey-reminder.html

Cheers, Jeremy.

Jeremy,

any new info around this thread? Will it come with 2012?

I urgently need the coordinates of each view on a certain sheet.

Unfortunately I searched quite a long time until I had the idea to search in your blog.

Kind regards, Thomas

Dear Thomas,

There is no public information at all about any future versions of any products whatsoever that I know about.

When you say '2012', I must answer that I have no idea what you are talking about.

I am glad you thought about searching the blog, though. I try to make all information that I come across available here. It always applies exclusively to existing public versions, of course. I hope it won't take you so long to think of it next time you need something :-)

Wish list items are better handled by an ADN request, though.

Cheers, Jeremy.

Hi Jeremy,

I know this is an old thread but I didnt find any thread that similar with my problem.
I want to insert an image on the sheet programatically based on the origin (0, 0, 0) at the bottom left. I knew from your blog that the sheet not provide the information about coordinate.
So to get the exact location for my image, I play around with the coordinate value until I get the correct position which is at top right. I have to hardcoded all the position for each type of sheet.
My question is:
Is there any possibility that the origin are different between type of sheet or if user create their own sheet?

Thank you.
Abby

Dear Abby,

I would assume yes.

You would have to research for yourself, though, e.g. using RevitLookup.

Here is another old but slightly less outdated post on a related topic:

http://thebuildingcoder.typepad.com/blog/2010/09/view-location-on-sheet.html

Cheers, Jeremy.

Hi Jeremy,

I can't figure out a way to get a handle on a Viewport's *title* so as to resize or move it on the ViewSheet (note: I'm referring to the viewport's *title*, not the viewport itself)
A worrying fact is that there's no elementID on the title symbol:
- go to a sheet with at least a viewport whose type defines a title symbol,
- click on the title so as to highlight it
- use Revit's "Element ID" to try to reveal its ID
- but it comes back empty!

I suspect that Viewport title is a private member of the Viewport class and the API does not expose anything about it. Shouldn't it at least expose methods to manipulate 1) the title's position and 2) the title line's length?

Warm regards,
Elias

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

Jeremy Tammik

AboutTopicsIndexSource