简体   繁体   English

Revit:旋转 ViewSection 时无法创建尺寸

[英]Revit: Cannot create dimensions when ViewSection is rotated

I'm trying to set dimension to the elements in a AssemblyInstance.我正在尝试为 AssemblyInstance 中的元素设置尺寸。 The code operates with coordinates from the first element.该代码使用第一个元素的坐标进行操作。

AssemblyInstance ass; //is found and is not null

ViewSection vsec = RevitAuxilaries.CreateAssemblyViewSection(uiapp, ass, 
AssemblyDetailViewOrientation.ElevationFront, ElementId.InvalidElementId, 25); 
//UIApplication, 
AssemblyInstance, AssemblyDetailViewOrientation, TemplateId, scale // created
BoundingBoxXYZ bbox1 = ass.get_BoundingBox(uiapp.ActiveUIDocument.ActiveView);
XYZ ptmid = (bbox1.Max + bbox1.Min) * 0.5;

Element cropboxelm = RevitAuxilaries.GetViewCropBox(uiapp, vsec); //finds CropBox element, 
//found

BoundingBoxXYZ bcropbox = vsec.CropBox;
XYZ center = new XYZ(ptmid.X, ptmid.Y, 0.5 * (bcropbox.Max.Z + bcropbox.Min.Z));
Line axis = Line.CreateBound(center, center + XYZ.BasisZ);

RevitAuxilaries.RotateElement2(uiapp, cropboxelm, axis, 0.6981); // UIApplication,, Element, 
Line, angle// created
double dw = RevitAuxilaries.GetDimensionFromElement(uiapp, fi, Dimensions.enWidth); //found dw 
 // = 3.937
ptleft = new XYZ(31.501, -23.3878, 32.4803);
ptrght = new XYZ(31.501 + dw * Math.Cos(0.6981), -23.3878 + dw * Math.Sin(0.6981), 32.4803);
Line ln = RevitAuxilaries.CreateLineFromPoints(uiapp, ptleft, ptrght); //created
ReferenceArray refarr = new ReferenceArray();
refarr.Append(ln.GetEndPointReference(0));
refarr.Append(ln.GetEndPointReference(1));
Dimension dim = null;
using (Transaction trans = new Transaction(uiapp.ActiveUIDocument.Document, "CreADim"))
{
    trans.Start();
    dim = uiapp.ActiveUIDocument.Document.Create.NewDimension(viewsec, line, refarr);
    if (!issame)
    {
        try
        { dim.ValueOverride = Convert.ToInt32(UnitUtils.Convert(dim.Value.Value, 
            UnitTypeId.Feet, UnitTypeId.Millimeters)).ToString(); } 
        catch { }
    }

    trans.Commit();
    uiapp.ActiveUIDocument.RefreshActiveView();
}

ERROR: The direction of dimension is invalid Error in function checkDir, line 939 What is here wrong?错误:尺寸方向无效 函数 checkDir 中的错误,第 939 行这里有什么问题?

Have you tried to create the exact same dimension in the exact same context manually through the end user interface?您是否尝试通过最终用户界面在完全相同的上下文中手动创建完全相同的维度? Does that complete as expected?是否按预期完成? If not, what error message does that generate?如果不是,那会产生什么错误消息? If yes, you can analyse the resulting model, its elements and their properties using RevitLookup and possibly discover some required settings that can be added to your API approach.如果是,您可以使用RevitLookup分析生成的模型、其元素及其属性,并可能发现一些可以添加到您的 API 方法中的必要设置。

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

相关问题 维数固定时的维数诅咒 - Curse of dimensionality when dimensions are fixed 创建并填充倍数维的关联数组 - Create and fill an associative array of multiples dimensions View尺寸何时可用于MainActivity? - When do View dimensions become available to MainActivity? 以像素为单位衡量时,PDF尺寸有意义吗? - Are PDF dimensions meaningful when measured in pixels? 使用norm()时矩阵尺寸错误 - Matrix dimensions error when using norm() 无法在财务维度上设置可见属性 - Cannot set visible property on Financial Dimensions 如何创建自定义回形针处理器以检索图像尺寸 Rails 4 - How to create Custom Paperclip Processor to retrieve image dimensions Rails 4 当图层不是整数时,图层的尺寸是向上舍入还是向下舍入? - Is the dimensions of layers rounded up or rounded down when it is not an integer? 在 SUMPRODUCT 中使用时,使用电子表格函数更改数组维度 - Change array dimensions, using spreadsheet functions, when used inside SUMPRODUCT 在为Android平板电脑编程时,屏幕尺寸重要吗? - Do screen dimensions matter when programming for Android tablet?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM