C# 在C中使用Revit API提示用户回答布尔选择#
我在C#中创建了一个Revit插件,它允许完全不熟悉3D技术的用户选择一个族,并将其插入到他们的项目中。但是现在用户没有选择是将对象放置在任意点上,还是放置在面上。不是一个就是另一个。 现在,我的代码如下所示:C# 在C中使用Revit API提示用户回答布尔选择#,c#,revit-api,C#,Revit Api,我在C#中创建了一个Revit插件,它允许完全不熟悉3D技术的用户选择一个族,并将其插入到他们的项目中。但是现在用户没有选择是将对象放置在任意点上,还是放置在面上。不是一个就是另一个。 现在,我的代码如下所示: bool useSimpleInsertionPoint = false; //or true bool useFaceReference = true; //or false if (useSimpleInsertionPoint) { //my code for insertion
bool useSimpleInsertionPoint = false; //or true
bool useFaceReference = true; //or false
if (useSimpleInsertionPoint)
{
//my code for insertion on point here
}
if (useFaceReference)
{
//my code for face insertion here
}
我想做的是询问用户他想做什么。
TaskDialog.Show会起作用吗?还是其他什么作用
提前感谢。这应该可以做到:
TaskDialog dialog = new TaskDialog("Decision");
dialog.MainContent = "What do you want to do?";
dialog.AllowCancellation = true;
dialog.CommonButtons = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No;
TaskDialogResult result = dialog.Show();
if(result == TaskDialogResult.Yes){
// Yes
TaskDialog.Show("yes", "YES!!");
}
else
{
// No
TaskDialog.Show("no", "NO!!");
}
2014年,代码在Revit宏中进行了测试并证明可以正常工作,因此在附加模块中的其他任何地方都可以正常工作。Vincent的方法很好。我更喜欢的一件事是在TaskDialog中使用CommandLink选项。这为您提供了可选择的“大选项”按钮,提供了答案以及关于每个答案的可选“解释”行 代码如下所示:
TaskDialog td = new TaskDialog("Decision");
td.MainContent = "What do you want to do?";
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,
"Use Simple Insertion Point",
"This option works for free-floating items");
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink2,
"Use Face Reference",
"Use this option to place the family on a wall or other surface");
switch (td.Show())
{
case TaskDialogResult.CommandLink1:
// do the simple stuff
break;
case TaskDialogResult.CommandLink2:
// do the face reference
break;
default:
// handle any other case.
break;
}
非常感谢,这正是我需要的!我会尽快试一试!非常感谢你!我会尽快试一试!