Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

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: 

How to move the topoSurface below?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
682 Views, 4 Replies

How to move the topoSurface below?

Hi to all programists!

I import topoSurface into revit :


s1.png

But it's location is too high. I want to have the average value of the points along the axis Z on the level 1:

s2.png

How to do this right? Should I use MovePoints method in TopographyEditScope transaction or something else? Thanks for any help.

Tags (2)
4 REPLIES 4
Message 2 of 5
aignatovich
in reply to: Anonymous

Hi!

 

First of all, get average Z from the surface points (surface.GetPoints()), then calculate the distance (this value minus your level project elevation),

then call ElementTransformUtils.MoveElement(doc, surface.Id, -1*distance*XYZ.BasisZ)

Message 3 of 5
Anonymous
in reply to: aignatovich

Thank you very much for your reply.

Could you please help me with one more problem? With your code i have an exception: "A managed exception was thrown by Revit or by one of its external applications"

My code looks about this:

using (Transaction tr = new Transaction(CurrentRevitDocument, "VIEW_3D"))
{
    tr.Start();
    TopographySurface topoSurface = TopographySurface.Create(CurrentRevitDocument, Points);
    double distance = getCoordinatesOfZAxis(Points, 3).Average();
    ElementTransformUtils.MoveElement(CurrentRevitDocument, topoSurface.Id, -1 * distance * Autodesk.Revit.DB.XYZ.BasisZ);
    tr.Commit();
}

And in line with moveElement method i have my exception.

Thanks.

Message 4 of 5
aignatovich
in reply to: Anonymous

Hmm. Strange thing.

 

Try to split creation of topography surface and moving it down in separated transactions. You can join them later in a transaction group.

Message 5 of 5
Anonymous
in reply to: aignatovich

Thank you very much for your help.

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

Post to forums  

Autodesk Design & Make Report