Revit API generates wall elements

Source: Internet
Author: User

Due to the version problem of Revit, the code for the generated wall element found on the web, compiled in Revit 2016 on my machine, was not able to pass through multiple debugs and finally found the code to generate the wall elements using the API in Revit 2016, which is now posted.

The following code is passed in the context of Revit + VS2013.

Class Createwall:iexternalcommand {public static Document Revitdoc;        public static Autodesk.Revit.ApplicationServices.Application Revitapp; Public Autodesk.Revit.UI.Result Execute (externalcommanddata commanddata, ref string message, Autodesk.Revit.DB.           ElementSet elements) {Revitapp = commandData.Application.Application;           var uidoc = commandData.Application.ActiveUIDocument;               if (Uidoc = = null) {message = "Please open a document";           return result.failed;           } Revitdoc = CommandData.Application.ActiveUIDocument.Document;                      var uisel = commandData.Application.ActiveUIDocument.Selection;           Transaction Transaction = new Transaction (Revitdoc, "Testscript.createnewinstancewithnewtype"); Transaction.           Start ();               try {var typeFilter = new Elementclassfilter (typeof (Walltype)); FilTeredelementcollector walltypes = new Filteredelementcollector (Revitdoc);               Walltypes = walltypes.wherepasses (TypeFilter);               Walltype walltype = null;                   foreach (Walltype walltype in walltypes) {walltype = Walltype;               Break if (walltype! = null) {//Create new wall type, use duplicate method var NE Wtype = Walltype. Duplicate (Walltype.                              Name + "_new");                   You can modify the parameters of the wall type here, such as modifying the absorption rate var para = walltype.get_parameter (builtinparameter.analytical_absorptance); IF (para! = NULL && para. Storagetype = = Storagetype.double && para. IsReadOnly = = false) {para.                   Set (2.0);                   }//Find an elevation level level = NULL;  var levelfilter = new Elementclassfilter (typeof (level));                 Filteredelementcollector levels = new Filteredelementcollector (Revitdoc); levels = levels.                   Wherepasses (Levelfilter);                       foreach (level element in levels) {level = element;                         Break  }//Create wall var wall = Wall.create (Revitdoc, Line.createbound (new XYZ (0, 0, 0), new XYZ (Ten, 0, 0), Newtype. Id, level.                         Id, 0, False, false); Taskdialog.show ("Wall creation", "wall created, id =" + wall.                     ID);                 } transaction.commit (); } catch (Exception ex) {message = ex.                     ToString (); Transaction.                     RollBack ();                 return result.failed;        } return result.succeeded; }    }

  

Revit API generates wall elements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.