Revit API changes wall parameters: from metadata it showed the correct result, not reflected in UI however

408 Views Asked by At

Using revit-python-wrapper to create Wall then adjust the Wall height and Wall offset to the ground. Here is the code

        from rpw import db
        from rpw import DB
        start_point = XYZ(0, 0, 0)
        end_point = XYZ(45, 0, 0)

        # Wrapper Line
        line = Line.new(start_point, end_point)
        
        levels = db.Collector(of_class='Level')
        level_0 = levels.get_first()
        wall = DB.Wall.Create(doc, line.unwrap(), level_0.Id, False)
        w = db.Wall(wall)
        w.parameters['Unconnected Height'].value = 2675 
        w.parameters['Base Offset'].value = 45

Wall created successfully in the empty Revit project. Using snoop revit DB, only one wall is found. The ID is : 318835 enter image description here

Checked the parameters belonging to this Wall - 318835. The parameter 'Unconnected Height' has correct double value: 2675.0 and the parameter "Base Offset" has correct double value: 45.0.

enter image description here

enter image description here

So far, everthing is perfect and per my expectation.

But, from the UI interface, the only Wall created is shown in wrong position. In 3D view, it's above the Level 1 which height is 4000.

enter image description here

And from the proporty tab of the selected Wall, the two parameters are also in the wrong values. 'Unconnected Height' has correct double value: 815340.0 and the parameter "Base Offset" has correct double value: 13716.0.

enter image description here

When I digged into deeper, I found actually the value I changed is shown in AsDouble. However, the value I changed in the UI is shown AsValueString. Both of them are pointing to the same property. However they are different, my understanding they should be the same value but in different data format. Am I wrong?

1

There are 1 best solutions below

0
cdhit On

I figured it out now.

Internally, Revit use feet rather than mm. So, make sure convert the mm to feet then pass it to value.

w.parameters['Unconnected Height'].value = mm_to_feet(2675) 
w.parameters['Base Offset'].value = mm_to_feet(45)