Setting up Survey Point programtically

Setting up Survey Point programtically

Anonymous
Not applicable
2,393 Views
1 Reply
Message 1 of 2

Setting up Survey Point programtically

Anonymous
Not applicable

Hello Everyone,

 

I want to perform a seemingly trivial task. I am trying to setting-up positional values (NS EW Elev) of a Survey point, programtically.

 

One of the articles on this topic says its not possible via API. However the article is almost three years now, so i hope API has got richer in this area.

 

if(basePoint.IsShared)
{
                  basePoint.Pinned = false;
                  basePoint.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM).Set(100);
}

This code throws exception: "There parameter is read-only".

 

Is there a better / another way of doing it in Revit API 2016?

 

Thanks in advance.

 

Best regards,

Kinjal.

 

 

0 Likes
Accepted solutions (1)
2,394 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Finally figured-it-out. It can be achieved uidoc.Document.ActiveProjectLocation.

 

Following is code to set value of Survey point programtically (that is values for NS, EW, Elev):

 

 

//1: Set Survey point values

ProjectLocation projectLocation = uidoc.Document.ActiveProjectLocation;

ProjectPosition projectPosition = projectLocation.get_ProjectPosition(origin);

projectPosition.NorthSouth = <double value>;
projectPosition.EastWest = <double value>;
projectPosition.Elevation = <double value>;;
projectLocation.set_ProjectPosition(origin, projectPosition);

//2: Move survey point wrt Project base coordinate
var locations = collector.OfClass(typeof(BasePoint)).ToElements();

foreach (var locationPoint in locations)
{
        BasePoint basePoint = locationPoint as BasePoint;
        if (basePoint.IsShared)
        {
basePoint.Pinned = false; basePoint.Location.Move(new XYZ(0, 1, 0)); } }

 

 

One issue remains. If survey point is relocated (see step 2 in code above) to Origin instead of a non-origin (0,1,0 in this case), the Survey point doesn't move to origin and appears at negative relational position from Project Base point. But thats separate issue so i will make it to a separate question. Thanks everyone.

 

Regards,

Kinjal.