BrowserOrganization Groupby?

image

Is it possible to get the grouping and sorting information by using python? cant find any from revitapi doc.

You should be able to access browser organization class hereā€¦

https://www.revitapidocs.com/2020/4fd57c3f-6127-efd9-f79e-70ad3e5dc1cc.htm

This is a static method, so just do BrowserOrganization.GetCurrentBrowserOrganizationForViews(doc) where doc is the Document you want to get the browser organization for.

You can get the SortingOrder (ascending/descending) as well as sorting parameter id which you can pass into doc.GetElement(id) to get the parameter.

2 Likes

Thank for the reply :slight_smile:
May I know how to get the parameter after getting the browserorganiztion? :frowning:
image

You could probably use Element.Parameters to see which parameters there are and using Element.GetParameterValueByName to actually get the value(s)

Hey,

ā€˜Static Methodsā€™ which I think are the same as ā€˜Propertiesā€™?! (Daniel will correct me :smiley:) are accessed using ā€˜Dot Notationā€™ā€¦

sortingOrder = browsOrg.SortingOrder

Note that ā€˜Propertiesā€™ are not the same as ā€˜Parametersā€™ā€¦ Which are another bundle of excitement to access.

Also, note that while you can ā€˜Getā€™ you canā€™t ā€˜Setā€™? (I donā€™t think).

@Daniel_Woodcock1 for my interest, Iā€™m not sure whether the parameter is usable? I get a null? Any thoughts? :slight_smile: Solved: BrowserOrganization.SortingParameterId - Autodesk Community

Hope that helps,

Mark


1 Like

Ah, right. I thought this would return a valid ElementId that referred to a ParameterElement. Looks like from what JT is saying that this is actually the integer value of a BIP. In this case, simply convert to an enumā€¦

import clr

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc =  DocumentManager.Instance.CurrentDBDocument

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

import System
from System import *

br_org = BrowserOrganization.GetCurrentBrowserOrganizationForSheets(doc)

sort_order = br_org.SortingOrder
sort_param_id = br_org.SortingParameterId

bip = next((e for e in Enum.GetValues(BuiltInParameter) if int(e) == sort_param_id.IntegerValue), None)

OUT = sort_order, bip

image

3 Likes

And no, I donā€™t think you can set these values, or at least I have not seen any API to support setting the Browser Organisation, but Iā€™ve never really looked too far into the Browser and what you can or canā€™t do with it, so could be wrong.

1 Like

Nice, thanks!

JT :smiley: can he sing Cry Me a River?!

2 Likes

Maybeā€¦ Although it should be ā€˜Crying: Me in Revitā€™ (Autodesk.Revit.DB remix feat. Element.Id and the Parameters).

2 Likes

thanks :slight_smile:
can we get the first name of groupby also?
image
Becoz I want to check the first ā€œgroupbyā€ parameter, then set its parameter at its view.

Hey,

Apologies, out of time for today, hopefully this helpsā€¦

Mark


5 Likes

thank you so much!! :slight_smile:
the revitapi makes me dizzyā€¦
really appreciate for the help! :slight_smile:

1 Like

The problem is that you need to learn Python to implement it, but itā€™s written in C#, so youā€™re translating between the two without knowing either!

Donā€™t worry, it gets easier, there are lots of good resources if you dig around on here, and also thereā€™s a nice website here which I useā€¦ Worked Examples

Cheers,

Mark

3 Likes

yesā€¦I was learning both eventually :frowning:

1 Like