简体   繁体   English

Revit API 更改墙参数:从元数据显示正确的结果,但未反映在 UI 中

[英]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.使用 revit-python-wrapper 创建墙,然后调整墙的高度和墙到地面的偏移。 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.在空的 Revit 项目中成功创建墙。 Using snoop revit DB, only one wall is found.使用 snoop revit DB,只找到一堵墙。 The ID is : 318835身份证号: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.检查属于此墙的参数 - 318835。参数“未连接高度”具有正确的双精度值:2675.0,参数“基础偏移”具有正确的双精度值: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.但是,从 UI 界面来看,创建的唯一墙显示在错误的位置。 In 3D view, it's above the Level 1 which height is 4000.在 3D 视图中,它位于高度为 4000 的 Level 1 之上。

在此处输入图像描述

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. “未连接高度”具有正确的双精度值:815340.0,参数“基本偏移”具有正确的双精度值:13716.0。

在此处输入图像描述

When I digged into deeper, I found actually the value I changed is shown in AsDouble.当我深入研究时,我发现实际上我更改的值显示在 AsDouble 中。 However, the value I changed in the UI is shown AsValueString.但是,我在 UI 中更改的值显示为 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.在内部,Revit 使用英尺而不是毫米。 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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