I'm new with Fabrication Parts in Revit API, I want to convert MEP Design elements ( ducts and pipes ) to fabrication Part given a service, but at themoment of execute the transaction , convertResult is Success but not make any change in MEP Elements, the mep elements still the same as before, this piece of code is the transaction, designIdSet is a HashSet< ElementId>
public void CreateFabricationPartFromService(Element element, List<Connector> unusedConnectors, int serviceId)
{
using (var transaction = new Transaction(_document, "CreateAndCoupleFabPart"))
{
transaction.Start();
var elementLevel = element.LevelId;
var designIdSet = MEPHelper.CreateMEPElementsFromConnectors(unusedConnectors, _document, 3, elementLevel);
var convertResult = _designToFabrication.Convert(designIdSet, serviceId);
var FabSets = _designToFabrication.GetConvertedFabricationParts();
_document.Regenerate();
_uiDocument.RefreshActiveView();
transaction.Commit();
}
}
i don't know if is because of the way that the CreateMEPElementsFromConnectors method created these parts, for the moment im only make test creating pipes, i don't know if i'm doing something wrong at the moment of creating MEP elements:
public static HashSet<ElementId> CreateMEPElementsFromConnectors(List<Connector> connectors, Document document, float length, ElementId levelId)
{
PipeType pipeType = new FilteredElementCollector(document)
.OfClass(typeof(PipeType))
.Cast<PipeType>()
.FirstOrDefault();
FilteredElementCollector pipingSystemTypes = new FilteredElementCollector(document)
.OfClass(typeof(PipingSystemType));
var systemTypeId = pipingSystemTypes.FirstElementId();
var resultSet = new HashSet<ElementId>();
foreach (var connector in connectors)
{
if (connector.Domain == Domain.DomainPiping)
{
var startPoint = connector.Origin;
var direction = connector.CoordinateSystem.BasisZ;
var endPoint = startPoint + direction * length;
var start2point = startPoint + direction * length / 2;
var pipe = Pipe.Create(document,systemTypeId,pipeType.Id,levelId,start2point,endPoint);
resultSet.Add(pipe.Id);
}
else if (connector.Domain == Domain.DomainHvac)
{
DuctType ductType = new FilteredElementCollector(document)
.OfClass(typeof(DuctType))
.Cast<DuctType>()
.FirstOrDefault(x => x.Shape == connector.Shape);
var startPoint = connector.Origin;
var direction = connector.CoordinateSystem.BasisZ;
var endPoint = startPoint + direction * length;
var duct = Duct.Create(document, ductType.Id, levelId, connector, endPoint);
resultSet.Add(duct.Id);
}
}
return resultSet;
}
Thanks.
I'm new with Fabrication Parts in Revit API, I want to convert MEP Design elements ( ducts and pipes ) to fabrication Part given a service, but at themoment of execute the transaction , convertResult is Success but not make any change in MEP Elements, the mep elements still the same as before, this piece of code is the transaction, designIdSet is a HashSet< ElementId>
public void CreateFabricationPartFromService(Element element, List<Connector> unusedConnectors, int serviceId)
{
using (var transaction = new Transaction(_document, "CreateAndCoupleFabPart"))
{
transaction.Start();
var elementLevel = element.LevelId;
var designIdSet = MEPHelper.CreateMEPElementsFromConnectors(unusedConnectors, _document, 3, elementLevel);
var convertResult = _designToFabrication.Convert(designIdSet, serviceId);
var FabSets = _designToFabrication.GetConvertedFabricationParts();
_document.Regenerate();
_uiDocument.RefreshActiveView();
transaction.Commit();
}
}
i don't know if is because of the way that the CreateMEPElementsFromConnectors method created these parts, for the moment im only make test creating pipes, i don't know if i'm doing something wrong at the moment of creating MEP elements:
public static HashSet<ElementId> CreateMEPElementsFromConnectors(List<Connector> connectors, Document document, float length, ElementId levelId)
{
PipeType pipeType = new FilteredElementCollector(document)
.OfClass(typeof(PipeType))
.Cast<PipeType>()
.FirstOrDefault();
FilteredElementCollector pipingSystemTypes = new FilteredElementCollector(document)
.OfClass(typeof(PipingSystemType));
var systemTypeId = pipingSystemTypes.FirstElementId();
var resultSet = new HashSet<ElementId>();
foreach (var connector in connectors)
{
if (connector.Domain == Domain.DomainPiping)
{
var startPoint = connector.Origin;
var direction = connector.CoordinateSystem.BasisZ;
var endPoint = startPoint + direction * length;
var start2point = startPoint + direction * length / 2;
var pipe = Pipe.Create(document,systemTypeId,pipeType.Id,levelId,start2point,endPoint);
resultSet.Add(pipe.Id);
}
else if (connector.Domain == Domain.DomainHvac)
{
DuctType ductType = new FilteredElementCollector(document)
.OfClass(typeof(DuctType))
.Cast<DuctType>()
.FirstOrDefault(x => x.Shape == connector.Shape);
var startPoint = connector.Origin;
var direction = connector.CoordinateSystem.BasisZ;
var endPoint = startPoint + direction * length;
var duct = Duct.Create(document, ductType.Id, levelId, connector, endPoint);
resultSet.Add(duct.Id);
}
}
return resultSet;
}
Thanks.
Share Improve this question asked Feb 7 at 15:03 Johan MoralesJohan Morales 154 bronze badges1 Answer
Reset to default 0Answered the identical question in the Revit API discussion forum:
- https://forums.autodesk.com/t5/revit-api-forum/can-t-convert-from-mep-design-elements-to-fabricationpart-with/td-p/13305951
Does the conversion process work as expected when driven manually from the end user interface? That mostly provides clearer information in case there is any problem with the model or parts that you are working with. I see a tutorial and instructions for the manual approach here:
- https://help.autodesk.com/view/RVT/2023/ENU/?guid=GUID-FCB75892-1D4E-4E69-91DB-995CD4EC65FA
- https://www.autodesk.com/learn/ondemand/tutorial/convert-revit-design-content-to-fabrication-parts
- https://www.autodesk.com/support/technical/article/caas/tsarticles/ts/5ZHNY1DJphbOgQKRUSmYhC.html
In fact, I see a discussion of issues with such a conversion, with the recommendation to look into the complexities, and that recommendation was accepted as a solution:
- https://forums.autodesk.com/t5/revit-mep-forum/issue-while-converting-design-to-fabrications/td-p/13271306
So, maybe it will help in your case as well?
I found the above searching for "How can I convert from Revit MEP Design elements to FabricationPart objects with the DesignToFabricationConverter class?":
- https://duckduckgo.com/?q=How+can+I+convert+from+Revit+MEP+Design+elements+to+FabricationPart+objects+with+the+DesignToFabricationConverter+class
I hope this helps, and maybe other more knowledgeable and experienced peers will be able to chip in and help too.