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: 

Projectlocation set

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
Joris.vd.Meulen
583 Views, 10 Replies

Projectlocation set

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
10 REPLIES 10
Message 2 of 11

Hi!

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

architectbim_0-1667208063860.png

 


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

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
Message 4 of 11

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
Message 5 of 11

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
Message 6 of 11

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
Message 7 of 11

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
Message 8 of 11

Ah that does work!

Thanks!

love python coding
Message 9 of 11

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
Message 10 of 11

Okay!

I am glad it finally helped. 😃


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

You sure did bud!


love python coding

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

Post to forums  

Autodesk Design & Make Report