-
-
Save ricaun/4f62b8650d29f1ff837e7e77f9e8b552 to your computer and use it in GitHub Desktop.
Revit Addin Commands to create Pipe and FlexPipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Autodesk.Revit.Attributes; | |
using Autodesk.Revit.DB; | |
using Autodesk.Revit.DB.Electrical; | |
using Autodesk.Revit.UI; | |
using System; | |
using System.ComponentModel; | |
namespace RevitAddin.Youtube.Revit.Commands | |
{ | |
[DisplayName("Create Conduit")] | |
[Designer("/UIFrameworkRes;component/ribbon/images/conduit_draw.ico")] | |
[Transaction(TransactionMode.Manual)] | |
public class CommandCreateConduit : IExternalCommand | |
{ | |
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) | |
{ | |
UIApplication uiapp = commandData.Application; | |
Document document = uiapp.ActiveUIDocument.Document; | |
var levels = new FilteredElementCollector(document) | |
.OfClass(typeof(Level)); | |
var levelId = levels.FirstElementId(); | |
var conduitTypes = new FilteredElementCollector(document) | |
.OfClass(typeof(ConduitType)); | |
var conduitTypeId = conduitTypes.FirstElementId(); | |
using (Transaction transaction = new Transaction(document)) | |
{ | |
transaction.Start("Create Conduit"); | |
Conduit.Create(document, conduitTypeId, XYZ.Zero, 10 * XYZ.BasisZ, levelId); | |
transaction.Commit(); | |
} | |
return Result.Succeeded; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Autodesk.Revit.Attributes; | |
using Autodesk.Revit.DB; | |
using Autodesk.Revit.DB.Plumbing; | |
using Autodesk.Revit.UI; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
namespace RevitAddin.Commands | |
{ | |
[DisplayName("Create Pipe")] | |
[Designer("/UIFrameworkRes;component/ribbon/images/pipe_create.ico")] | |
[Transaction(TransactionMode.Manual)] | |
public class CommandCreatePipe : IExternalCommand | |
{ | |
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) | |
{ | |
UIApplication uiapp = commandData.Application; | |
Document document = uiapp.ActiveUIDocument.Document; | |
var levels = new FilteredElementCollector(document) | |
.OfClass(typeof(Level)); | |
var levelId = levels.FirstElementId(); | |
var pipeTypes = new FilteredElementCollector(document) | |
.OfClass(typeof(PipeType)); | |
var pipeTypeId = pipeTypes.FirstElementId(); | |
var pipeSystemTypes = new FilteredElementCollector(document) | |
.OfClass(typeof(PipingSystemType)); | |
var pipeSystemTypeId = pipeSystemTypes.FirstElementId(); | |
using (Transaction transaction = new Transaction(document)) | |
{ | |
transaction.Start("Create Pipe"); | |
Pipe.Create(document, pipeSystemTypeId, pipeTypeId, levelId, XYZ.Zero, 10 * XYZ.BasisX); | |
transaction.Commit(); | |
} | |
return Result.Succeeded; | |
} | |
} | |
[DisplayName("Create FlexPipe")] | |
[Designer("/UIFrameworkRes;component/ribbon/images/flex_pipe_create.ico")] | |
[Transaction(TransactionMode.Manual)] | |
public class CommandCreateFlexPipe : IExternalCommand | |
{ | |
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) | |
{ | |
UIApplication uiapp = commandData.Application; | |
Document document = uiapp.ActiveUIDocument.Document; | |
var levels = new FilteredElementCollector(document) | |
.OfClass(typeof(Level)); | |
var levelId = levels.FirstElementId(); | |
var pipeTypes = new FilteredElementCollector(document) | |
.OfClass(typeof(FlexPipeType)); | |
var pipeTypeId = pipeTypes.FirstElementId(); | |
var pipeSystemTypes = new FilteredElementCollector(document) | |
.OfClass(typeof(PipingSystemType)); | |
var pipeSystemTypeId = pipeSystemTypes.FirstElementId(); | |
using (Transaction transaction = new Transaction(document)) | |
{ | |
transaction.Start("Create FlexPipe"); | |
XYZ startTangent = XYZ.BasisY; | |
XYZ endTangent = XYZ.BasisY; | |
var points = new List<XYZ>() { XYZ.Zero, 5 * XYZ.BasisY + XYZ.BasisZ, 10 * XYZ.BasisY }; | |
FlexPipe.Create(document, pipeSystemTypeId, pipeTypeId, levelId, startTangent, endTangent, points); | |
transaction.Commit(); | |
} | |
return Result.Succeeded; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Command works with: https://github.com/ricaun-io/RevitAddin.CommandLoader