Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Toposurface vertex

3 REPLIES 3
Reply
Message 1 of 4
sanjaymann
361 Views, 3 Replies

Toposurface vertex

Hi,

 

When trying to read vertex of a toposurface its giving some strange values. Using spot coordinates values shown are N 532.404 E 155.581 but when programatically reading vertex its gives 1730.12133789063, 508.001983642578. The code is as follows:

public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
ref string message, ElementSet elements)
{
HashSet<String > hset=new HashSet<String>();
UIApplication uiApp = commandData.Application;
UIDocument uiDoc = uiApp.ActiveUIDocument;
StreamWriter sw = new StreamWriter("d://vert.txt");
foreach (Element ele in uiDoc.Selection.Elements)
{
TopographySurface surface = ele as TopographySurface;
Options op = new Options();
op.ComputeReferences = true;
IEnumerator<GeometryObject> geoObjects =
surface.get_Geometry(op).GetEnumerator();

while (geoObjects.MoveNext())
{
GeometryObject geoObj =
geoObjects.Current as GeometryObject;

if (geoObj is Mesh)
{
Mesh mesh = geoObj as Mesh;
//for (int i = 0; i < mesh.NumTriangles; i++)
//{
// MeshTriangle mt = mesh.get_Triangle(i);
// sw.WriteLine(mt.get_Vertex(0).ToString() + "," + mt.get_Vertex(1).ToString() + "," + mt.get_Vertex(2));
//}

IList<XYZ> vertices = mesh.Vertices;

foreach (XYZ point in vertices)
{
string s = string.Empty;
s = s
+ point.X.ToString() + ", "
+ point.Y.ToString() + ", "
+ point.Z.ToString();
//if (hset.Contains(s)==false )
// {
sw.WriteLine(s);
hset.Add(s);
//}


}

//System.Diagnostics.Trace.WriteLine(s);
}
}
}
sw.Close();
sw.Dispose();
MessageBox.Show("Quantified");
return Result.Succeeded;
} // end class

3 REPLIES 3
Message 2 of 4
jeremytammik
in reply to: sanjaymann

The coordinates retrieved progammatically from the Revit database are always imperial feet in the RVT model space.

 

The coordinates shown as north and east depend on the project location:

 

http://thebuildingcoder.typepad.com/blog/2010/01/project-location.html

 

Here is a real world example of using this:

 

http://thebuildingcoder.typepad.com/blog/2012/06/real-world-concrete-corner-coordinates.html#4

 

It is part of the structural concrete setout point add-in:

 

http://thebuildingcoder.typepad.com/blog/2012/08/structural-concrete-setout-point-add-in.html

 

Best regards,

 

Jeremy



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

Message 3 of 4
sanjaymann
in reply to: jeremytammik

Thanks for the help. Converted feet into meters and it was done. 

 

Another thing I want to ask is how do I set the name of the toposurface because when I try to do so:

TopographySurface surface = ele as TopographySurface;
surface.Name = "Test";

 

It raises an alarm that name cannot be assigned.

 

And I also need a personal suggestion from you. From last 2 years I have been programming Revit and Navis. Whats the scope of revit programming from career point of view. Your suggestion will be very valuable for me. You might not remember but in the past also you have directed me in the right directions.

 

Thanks & Regards

Message 4 of 4
jeremytammik
in reply to: sanjaymann

Dear Sanjaymann,

 

Thank you for your appreciation. I am glad it worked and was so simple, and that my advice helped in the past.

 

No idea why the name cannot be assigned. I assume you have opened a transaction. Can you cahnge it in the user interface?

 

Regarding your question on the "scope of revit programming from career point of view", all I can say is "great!"

 

Cheers and good luck, 

 

Jeremy



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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community