简体   繁体   中英

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

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 在此处输入图像描述

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.

在此处输入图像描述

在此处输入图像描述

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.

在此处输入图像描述

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.

在此处输入图像描述

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM