Revit Architecture 2012:如何更改幕墙中的任何墙以及如何管理幕线

发布于 2024-11-26 00:16:04 字数 2589 浏览 3 评论 0原文

我有一个程序可以选择一堵墙并获取不同的参数,但我不知道如何更改幕墙中的墙。然后我想控制墙上的线条数量和具体位置。我加入了我的代码,但它不起作用。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB.Structure;

namespace test2011
{
  [TransactionAttribute(TransactionMode.Automatic)]
  [RegenerationAttribute(RegenerationOption.Manual)]
  public class Class1 : IExternalCommand
  {
    public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, 
      ref string message, ElementSet elements)
    {
      // Select some elements in Revit before invoking this command
      // Get the handle of current document.
      UIDocument uidoc = commandData.Application.ActiveUIDocument;

      // Get the element selection of current document.
      Selection selection = uidoc.Selection;
      ElementSet collection = selection.Elements;

      if (0 == collection.Size)
      {
        // If no elements selected.
        TaskDialog.Show("Revit", "You haven't selected any elements.");
      }
      else
      {
        TaskDialog.Show("revit", "On entre dans le else");
        foreach (Wall wall in collection)
        {
          LocationCurve locationCurve = wall.Location as LocationCurve;
          XYZ endPoint0 = locationCurve.Curve.get_EndPoint(0);
          XYZ endPoint1 = locationCurve.Curve.get_EndPoint(1);
          TaskDialog.Show("revit", "point 0: " + endPoint0.ToString() + 
                                   " \npoint 1: " + endPoint1.ToString()+
                                   " \nWallType: "+ 
                                   wall.WallType.Kind.ToString());
          //Create curtain line
          //Create the Points
          double x1 = endPoint0.X;
          double y1 = endPoint0.Y - 3;
          double z = endPoint0.Z;
          double x2 = endPoint1.X;
          double y2 = endPoint1.Y - 3;
          XYZ point1 = uidoc.Application.Application.Create.NewXYZ(x1, y1, z);
          XYZ point2 = uidoc.Application.Application.Create.NewXYZ(x2, y2, z);

          //Create line
          Line line = 
            uidoc.Application.Application.Create.NewLineBound(point1, point2);

          DetailCurve detailCurve = 
            uidoc.Document.Create.NewDetailCurve(uidoc.Document.ActiveView, 
              line);

          TaskDialog.Show("Done", "Line Created");
        }
      }
      return Result.Succeeded;
    }
  }
}

I have a program which selects a wall and get different parameters, but I don't know how to change a wall in curtain wall. And after I want to control the number and the specific places of lines in the wall. I join my code, but it does not work.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB.Structure;

namespace test2011
{
  [TransactionAttribute(TransactionMode.Automatic)]
  [RegenerationAttribute(RegenerationOption.Manual)]
  public class Class1 : IExternalCommand
  {
    public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, 
      ref string message, ElementSet elements)
    {
      // Select some elements in Revit before invoking this command
      // Get the handle of current document.
      UIDocument uidoc = commandData.Application.ActiveUIDocument;

      // Get the element selection of current document.
      Selection selection = uidoc.Selection;
      ElementSet collection = selection.Elements;

      if (0 == collection.Size)
      {
        // If no elements selected.
        TaskDialog.Show("Revit", "You haven't selected any elements.");
      }
      else
      {
        TaskDialog.Show("revit", "On entre dans le else");
        foreach (Wall wall in collection)
        {
          LocationCurve locationCurve = wall.Location as LocationCurve;
          XYZ endPoint0 = locationCurve.Curve.get_EndPoint(0);
          XYZ endPoint1 = locationCurve.Curve.get_EndPoint(1);
          TaskDialog.Show("revit", "point 0: " + endPoint0.ToString() + 
                                   " \npoint 1: " + endPoint1.ToString()+
                                   " \nWallType: "+ 
                                   wall.WallType.Kind.ToString());
          //Create curtain line
          //Create the Points
          double x1 = endPoint0.X;
          double y1 = endPoint0.Y - 3;
          double z = endPoint0.Z;
          double x2 = endPoint1.X;
          double y2 = endPoint1.Y - 3;
          XYZ point1 = uidoc.Application.Application.Create.NewXYZ(x1, y1, z);
          XYZ point2 = uidoc.Application.Application.Create.NewXYZ(x2, y2, z);

          //Create line
          Line line = 
            uidoc.Application.Application.Create.NewLineBound(point1, point2);

          DetailCurve detailCurve = 
            uidoc.Document.Create.NewDetailCurve(uidoc.Document.ActiveView, 
              line);

          TaskDialog.Show("Done", "Line Created");
        }
      }
      return Result.Succeeded;
    }
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆凄美了谁 2024-12-03 00:16:04

使用一些RevitPythonShell功夫,这里有一些Revit API,用于将选定的墙设置为是幕墙:

# get the selected wall
wall = selection[0]

# find a curtain wall type
wallTypes = list(FilteredElementCollector(doc).OfClass(WallType))
curtainWallType = [wt for wt in wallTypes if wt.Kind == WallKind.Curtain][0]

# set the wall type
transaction = Transaction(doc, 'Setting wall type to curtain wall')
transaction.Start()
wall.WallType = curtainWallType
transaction.Commit()

Using some RevitPythonShell kung-fu, here is a bit of Revit API for setting the selected wall to be a curtain wall:

# get the selected wall
wall = selection[0]

# find a curtain wall type
wallTypes = list(FilteredElementCollector(doc).OfClass(WallType))
curtainWallType = [wt for wt in wallTypes if wt.Kind == WallKind.Curtain][0]

# set the wall type
transaction = Transaction(doc, 'Setting wall type to curtain wall')
transaction.Start()
wall.WallType = curtainWallType
transaction.Commit()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文