Function for stationing (chainage)

Is there a function somewhere in the IfcOpenShell or Bonsai ecosystem that can create a stationing string for labels and such?

Example: station_value = 1234.56
String (US): 12+34.56
String (SI): 1+234.56

Comments

  • Im not aware of any. How does it work? We've got code that uses Lark for a variety of input parsing and unit conversion that this might be similar to.

  • Let’s say Pset_Stationing has a Station property of 1234.56. It’s meaningful for IfcReferent.Name/Description to include the station. Stations are represented as (full chains)+(links).(link fraction)

    A surveyor chain is 100ft long made up of 100-1ft links.

    The example station is 12 chains + 34.56 links, or 12+34.56

    IfcReferent.Name=“PC 12+34.56”

    I have some C++ code I can port to python and add it to IfcOpenShell.api.alignment

  • edited February 19

    @Rick_Brice

    If I understand your request:
    we use the same prodedure to convert m to chainage (24,452.89 > 24+452.89) in Excel without affecting the value
    in python should be something like

    meters = 123498
    km = meters//1000
    m = meters % 1000
    print( f"{km}+{m}")
    

    123+498
    I think REGEX can be used too

  • In recently add this in ifcopenshell.util.stationing. The function is station_as_string. Input a value, and optionally the number of digits between the + and the ., as well as number of decimal points, and it returns a stringized version of the station value.

    s = ifcopenshell.util.stationing.station_as_string(123456.789,2,2)
    print(s)
    ‘1234+56.79’
    
    steverugi
Sign In or Register to comment.