PDA

View Full Version : Coordinate System API functions



dtownsend
2006-10-20, 12:31 PM
Hello

Does the API work with Revit Coordinate system?

Is there any documentation on how this works?

Thanks

GuyR
2006-10-20, 06:21 PM
What do you mean the Revit coordinate system? Every element that has geometry exposes this geometry via the API in a standard XYZ coordinate system. The only gotcha is all values are imperial so you have to do conversions if you live in the metric world.

HTH,

Guy

Danny Polkinhorn
2006-10-20, 09:13 PM
If you're referring to Shared Coordinates (actually all coordinates), the answer is yes as Guy mentioned. The Site Class has all the properties you need to determine site locations and individual linked Revit project locations.

If you can give us a more accurate description of what you're looking for, we can point you in the right direction.

Hope that helps,
-Danny

GuyR
2006-10-20, 10:40 PM
Good point Danny, I hadn't thought about that one. And in V9.1 accessing site locations is even easier....

Guy

dtownsend
2006-10-26, 12:10 AM
Sorry for the lack of detail.

I would like to switch over my day-to-day 2D CAD work over to the BIM world with Revit. The main thing I use CAD for is for layout out deep foundations (Piles and Pile Caps) and then do as-builds. That is the lack of detail version of what I'm looking for.

I would need to be able to label the piles with a number ie (101,102,103,etc) and with Northing and Easting coordinate ie (5000,3000). This data would ultimately need to make its way to an ASCII file.

POINT#,NORTHING,EASTING
101,5000,3000
102,5000.25,3000

ASBuilts would be imported using an ASCII file and look like this

POINT#,NORTHING,EASTING
2101,5000.1,3000.02
2102,5000.3,3000.4

We add a number ie 2 in front of the normal point number so we can tell asbuilt from plan.

I was thinking that we would have a Plan Phase for the plan pile coordinates and an Asbuilt Phase for the As built pile coordinates.

Another note we start at 5000,3000 as our 0,0 and it is set at the lower left grid line intersect - typically. This is just an internal set-up for out Nikon Instruments, since this data will go from the model to the field.

We get it done in 2D, but it would be great to move this process over to Revit.

Thanks

Danny Polkinhorn
2006-10-26, 09:54 PM
I'm gathering that there's no "coordinate tag" and that you've already investigated that option.

You would be able to grab the coordinate points with the API, but I can't think of a way to get that to display in the model off the top of my head. If you went directly to the ASCII file, that would be a piece of cake. Even importing the data back in to Revit to generate the As-builts for you would be possible.

Hope that helps,

dtownsend
2006-10-27, 05:02 PM
I have not seen a "coordinate tag" I haven't done that much with it, but I'm playing with it now.

How would I go about using the API to export the coordinates to an ASCII file and importing.

Thanks for your help

dtownsend
2006-10-27, 05:21 PM
Is there someway to bring in coordinates into a family.

I make my Pile/Pilecaps parametric so if I can get a northing and easting of any point on the pile cap I can use a formula to figure out the actual coordinates of each pile inside of the cap.

Danny Polkinhorn
2006-10-27, 08:32 PM
To grab the coordinates, iterate through your family instances and grab the Geometry object from each. Iterate through the geometry to determine the elements you want the coordinates for and grab their respective coordinates. Then just write it out to a text file (make sure you include the ObjectID of the family instance).

If the coordinates relate to the Location parameter of the family, you should be able to read the As-built ASCII file, read an ObjectID and it's new coordinates, and change the Location parameter to the new location.

Hopefully you can store additional information (the ObjectIDs) in the ASCII file, otherwise this could get more difficult.

If you're heading to AU in a few weeks, be sure to sit in on my API class where I'll show some basic examples of what you're trying to do. There's another Revit API class on Wednesday.

Hope that helps,

dtownsend
2006-10-30, 12:34 PM
I will not be able to make it to AU this year.

I have really have no clue how to do what you said in your last post. Is there a web site or document or book I can read so I can get up to speed on how to do that or atleast have an understanding of the Revit API.

I'm going to play with it but I have no idea how to "iterate through your family instances and grab the Geometry object from each". If I have some documentation I can usually figure this stuff out.

dtownsend
2006-10-30, 12:41 PM
I'm reading threw the documents in the SDK now. Do you think that should be enough information for me to know how to do this or is their an additional resource needed.

Also I read that MS Developer Studio 2005 is required to use the REVIT API. Does that mean that MS Visual Basic 2005 Express will not do the trick?

Thanks

dtownsend
2006-10-30, 02:15 PM
It looks like express editions are missing the option to lanch an exe program (revit) under the Debug tab.

GuyR
2006-10-30, 06:34 PM
In addition to the SDK documentation there is a RevitAPI.chm in ..\Program folder. The express editions don't give you the option of building debug and/or release builds. However sharpdevelop (http://www.icsharpcode.net/OpenSource/SD/Download/) works just fine. I'm using 2.1 beta successfully. Also download the .NET2.0 SDK. Includes the debugger and help files. Install this before installing SD. SD also supports plugins like fxcop,nunit etc if needed.

HTH,

Guy

dtownsend
2006-11-02, 12:11 PM
Cool. I'm going to install that today, but I guess I need to start learning C# now. I would dump Visual Basic all together, but I also play with the Navisworks API and all the examples/support is in Visual Basic.

Thanks again for all your help

GuyR
2006-11-02, 06:14 PM
Navisworks API and all the examples/support is in Visual Basic.

Because all .NET languages compile to IL you can convert (with reasonable accuracy) between any .NET language. So in sharpdevelop or VS express you can convert VB.NET code to c#.

HTH,

Guy

dtownsend
2007-03-04, 05:54 AM
To grab the coordinates, iterate through your family instances and grab the Geometry object from each. Iterate through the geometry to determine the elements you want the coordinates for and grab their respective coordinates. Then just write it out to a text file (make sure you include the ObjectID of the family instance).

If the coordinates relate to the Location parameter of the family, you should be able to read the As-built ASCII file, read an ObjectID and it's new coordinates, and change the Location parameter to the new location.

Hopefully you can store additional information (the ObjectIDs) in the ASCII file, otherwise this could get more difficult.

If you're heading to AU in a few weeks, be sure to sit in on my API class where I'll show some basic examples of what you're trying to do. There's another Revit API class on Wednesday.

Hope that helps,Okay Danny I have a new solution to my "problem".

I have decided for now to keep the 2D CAD part of my job when it comes to coordinates, but I am working on integrating Revit and the 2D CAD together for better work flow.

I am going to draw the foundations using Revit - export to a DWG - assign the coordinates in our CAD program and export them to an ASCII file. Now I am working on using the API to open up the ASCII file and populate coordinate parameters I built into to the custom family - they are shared parameters that are instances.

I have a certain type in the family that will typically be used project wide, but the coordinates will be instance parameters.

----

My question is can I populate shared instance parameters based on the objects mark?

How would you approach using the ASCII file? Saving it out as an Excel file and just using the Office API or try parsing the ASCII file?

Danny Polkinhorn
2007-03-05, 07:30 AM
Instead of exporting from CAD to ASCII, just read the cad file directly from Revit. You'll save yourself a lot of headaches that way. When you export to DWG from Revit, the ObjectIDs are also written out. So, in AutoCAD, you can determine what Revit element a line came from by examining its xdata. This can be used by Revit when reading the DWG to determine the coordinates of the individual lines (or whatever) and its corresponding Revit element. If you draw lines in AutoCAD, they won't have the xdata, so you'll have to figure out some way of correlating them with elements in the Revit model.

AutoCAD comes with a COM API called "AutoCAD/ObjectDBX...", which allows you to read and write DWG files (if you have AutoCAD installed).

In answer to your first question, yes, you can select an element based on its ObjectID, then populate any type of parameter it contains.

Hope that helps,

dtownsend
2007-03-06, 12:58 PM
Danny the only problem is we use a add-on to AutoCAD (CGSurvey) to assign the points and the points are not actually apart of the DWG, but a CRD file that can be dumped into ASC - which we have to do anyways. The points I am talking about are used to layout deep foundation piles in the field. Each pile has a PT#, Northing, Eastern, Elevation(typically don't use for this) stored in an ASC file that we then load into a Total Station, Data collector, GPS, etc.