1

I am wanting to know if there is a methodology to feed calculated values to a built-in Revit command from inside a C# program, and then possibly (based on results, such as whether this makes an element too short or too long for a known "maximum span" of a particular beam) continue with my C# program and change the beam size). I am told you can invoke the Revit built-in command after execution of your c# external command, but you cannot then return to the c# program

As another example, I want to select an element to trim/extend to, and have the code figure out which "Joist" beams to extend to this element. My program would do extended filtering (such as "Reference Level", or "Workset", or "Comments", or "Mark" parameters (etc.)) and then run the built in function, providing the element to extend to and then each of my beams.

I've tried internet searches, as well as the Revit SDK samples, and nothing obviously used this (but there are a lot of csproj's to look through).

Can anyone verify that you cannot go back and forth between the C# program and the Revit built-in command?

4

3 回答 3

3

您可以使用 UIApplication.PostCommand() 方法以编程方式调用内置 Revit 命令。有关更多信息,请参阅文档构建编码器。但是,它直到 API 上下文结束后才会执行。

但是,我认为您无法将参数输入命令,除非某种 Win32 hack。也许您需要在 Revit API 中重新创建内置命令的功能。

不幸的是,我认为我们不能在这里做 (command "_line" pnt1 pnt2) 类型的事情。

于 2014-06-27T18:38:42.973 回答
1

也许从 SDK 示例“MoveLinear”开始。它显示了如何修改线性元素(包括梁)的端点。

示例代码的主要部分是

                Autodesk.Revit.DB.Line line;
                //get start point via "get_EndPoint(0)"
                Autodesk.Revit.DB.XYZ newStart = new XYZ(
                    lineLoc.Curve.GetEndPoint(0).X + 100,
                    lineLoc.Curve.GetEndPoint(0).Y,
                    lineLoc.Curve.GetEndPoint(0).Z);
                //get end point via "get_EndPoint(1)"
                Autodesk.Revit.DB.XYZ newEnd = new XYZ(
                    lineLoc.Curve.GetEndPoint(1).X,
                    lineLoc.Curve.GetEndPoint(1).Y + 100,
                    lineLoc.Curve.GetEndPoint(1).Z);
                //get a new line and use it to move current element 
                //with property "Autodesk.Revit.DB.LocationCurve.Curve"
                line = Line.CreateBound(newStart, newEnd);
                lineLoc.Curve = line;

它将第一个点的 X 和第二个点的 Y 移动 100 英尺。

于 2015-10-01T05:03:21.557 回答
0

你可以试试:

 RevitCommandId commandId = RevitCommandId.LookupPostableCommandId(PostableCommand.PlaceAComponent);
 commandData.Application.PostCommand(commandId);
于 2020-12-02T16:42:36.540 回答