Projectlocation set

Projectlocation set

Joris.vd.Meulen
Collaborator Collaborator
763 Views
10 Replies
Message 1 of 11

Projectlocation set

Joris.vd.Meulen
Collaborator
Collaborator

Guys, 

 

Just to be sure: Revit API doesn't allow us to set a Projectlocation right?

 

So let's say you have 10 ProjectLocations and you want to set a specific one as the ActiveProjectLocation

love python coding
0 Likes
Accepted solutions (1)
764 Views
10 Replies
Replies (10)
Message 2 of 11

architect.bim
Collaborator
Collaborator

Hi!

I think it allows. In the latest API versions there is SetProjectPosition method

architectbim_0-1667208063860.png

 


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes
Message 3 of 11

architect.bim
Collaborator
Collaborator

I'm sorry! The previous one changes the properties of the location itself. And this property (ActiveProjectLocation) is responsible for the current document location.


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes
Message 4 of 11

Joris.vd.Meulen
Collaborator
Collaborator

Yeah,

 

So one can't set a specific one as ActiveLocation.
no API workflow would be: press the "make current" button

 

JorisvdMeulen_0-1667208693352.png

 

love python coding
0 Likes
Message 5 of 11

architect.bim
Collaborator
Collaborator
Accepted solution

Sorry, I do not understand what the problem is. You simply need to set new value for the ActiveProjectLocation property. Here is Python sample. I create duplicate the existing location and set it as the current:

current_location = doc.ActiveProjectLocation
with DB.Transaction(doc, 'Set New Current Location') as t:
    t.Start()
    new_location = current_location.Duplicate('New Location')
    doc.ActiveProjectLocation = new_location
    t.Commit()

The results are in the screenshot below:

architectbim_0-1667210828631.jpeg

 


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes
Message 6 of 11

architect.bim
Collaborator
Collaborator

To retrieve all the project locations get the ProjectLocations value and iterate through the ProjectLocationSet to get the location you need.


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes
Message 7 of 11

Joris.vd.Meulen
Collaborator
Collaborator

As the screenshot above shows:

 

I have 3 defined sitelocations (each with the own survey point, rotation etc.etc.)

I want to make one of those current: as if I pressed the "make current" button

love python coding
0 Likes
Message 8 of 11

Joris.vd.Meulen
Collaborator
Collaborator
Ah that does work!

Thanks!

love python coding
Message 9 of 11

architect.bim
Collaborator
Collaborator

What stops you from doing so? Setting the ActiveProjectLocation property does the same as you if you push "Make Current" button in Revit UI.

Before:

architectbim_0-1667211700924.jpeg

 

Python Code:

all_locations = doc.ProjectLocations
for location in all_locations:
    if location.Name == 'New Location 2':
        break

with DB.Transaction(doc, 'Set New Current Location') as t:
    t.Start()
    doc.ActiveProjectLocation = location
    t.Commit()

After:

architectbim_1-1667211731359.jpeg

 


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes
Message 10 of 11

architect.bim
Collaborator
Collaborator

Okay!

I am glad it finally helped. 😃


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes
Message 11 of 11

Joris.vd.Meulen
Collaborator
Collaborator
You sure did bud!


love python coding